<template>
  <section
    id="Content"
    class="p-6 pb-24 min-h-screen flex flex-col justify-center"
  >
    <!-- Heading -->
    <h1 id="ViewHeading" class="text-4xl text-center font-light pt-4 mb-8">
      Start Here
    </h1>

    <div class="mt-8">
      <p class="text-center text-xl mb-4 font-light">
        Do you have an identity to import?
      </p>
      <a
        @click="onClickYes()"
        class="block w-full text-center text-lg uppercase bg-blue-600 text-white px-2 py-3 rounded-md"
      >
        No
      </a>
      <a
        @click="onClickNo()"
        class="block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mt-2"
      >
        Yes
      </a>
      <a
        v-if="numAccounts > 0"
        @click="onClickDerive()"
        class="block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mt-2"
      >
        Derive from Existing Account
      </a>
    </div>
  </section>
</template>

<script lang="ts">
import { Component, Vue } from "vue-facing-decorator";
import { accountsDB } from "@/db";

@Component({
  components: {},
})
export default class StartView extends Vue {
  numAccounts = 0;

  async mounted() {
    await accountsDB.open();
    this.numAccounts = await accountsDB.accounts.count();
  }

  public onClickYes() {
    this.$router.push({ name: "new-identifier" });
  }

  public onClickNo() {
    this.$router.push({ name: "import-account" });
  }

  public onClickDerive() {
    this.$router.push({ name: "import-derive" });
  }
}
</script>
