<template>
  <QuickNav />

  <!-- CONTENT -->
  <section id="Content" class="p-6 pb-24 max-w-3xl mx-auto">
    <!-- Breadcrumb -->
    <div class="mb-8">
      <!-- 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">
        Your Identity
      </h1>
    </div>

    <div class="flex justify-center py-12">
      <span />
      <span v-if="loading">
        <span class="text-xl">Creating...&nbsp;</span>
        <fa
          icon="spinner"
          class="fa-spin fa-spin-pulse"
          color="green"
          size="128"
        ></fa>
      </span>
      <span v-else>
        <span class="text-xl">Created!</span>
        <fa
          icon="burst"
          class="fa-beat px-12"
          color="green"
          style="
            --fa-animation-duration: 1s;
            --fa-animation-direction: reverse;
            --fa-animation-iteration-count: 1;
            --fa-beat-scale: 6;
          "
        ></fa>
      </span>
      <span />
    </div>
  </section>
</template>

<script lang="ts">
import "dexie-export-import";
import { Component, Vue } from "vue-facing-decorator";
import { generateSaveAndActivateIdentity } from "@/libs/util";
import QuickNav from "@/components/QuickNav.vue";

@Component({ components: { QuickNav } })
export default class NewIdentifierView extends Vue {
  loading = true;

  async mounted() {
    await generateSaveAndActivateIdentity();
    this.loading = false;
    setTimeout(() => {
      this.$router.push({ name: "home" });
    }, 1000);
  }
}
</script>