<template>
  <section
    id="Content"
    class="p-6 pb-24 min-h-screen flex flex-col justify-center"
  >
    <!-- Breadcrumb -->
    <div>
      <!-- Back -->
      <div class="text-lg text-center font-light relative px-7">
        <h1
          class="text-lg text-center px-2 py-1 absolute -left-2 -top-1"
          @click="$router.back()"
        >
          <fa icon="chevron-left" class="fa-fw"></fa>
        </h1>
      </div>

      <!-- Heading -->
      <h1 id="ViewHeading" class="text-4xl text-center font-light pt-4 mb-8">
        Start Here
      </h1>
    </div>

    <!-- id used by puppeteer test script -->
    <div id="start-question" class="mt-8">
      <p class="text-center text-xl font-light">
        Do you want a new identifier of your own?
      </p>
      <p class="text-center font-light">
        If you haven't used this before, click "Yes" to generate a new
        identifier.
      </p>
      <p class="text-center mb-4 font-light">
        Only click "No" if you have a seed of 12 or 24 words generated
        elsewhere.
      </p>
      <a
        @click="onClickYes()"
        class="block w-full text-center text-lg uppercase bg-blue-600 text-white px-2 py-3 rounded-md"
      >
        Yes
      </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"
      >
        No
      </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 New Address from Seed Imported Previously
      </a>
    </div>
  </section>
</template>

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

@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>
