<template>
  <div>
    <b-notification type="is-info" aria-close-label="Close notification">
      Dein Konto ist noch nicht aktiv.
      <a @click="activate()">Jetzt aktivieren</a>
    </b-notification>
    <table class="table is-fullwidth">
      <tbody>
        <tr>
          <td>Kontostatus</td>
          <td>nicht aktiviert</td>
        </tr>
        <tr>
          <td>Benutzername</td>
          <td>
            <InlineEditor v-model="user.username" @input="user.save()" />
          </td>
        </tr>
        <tr>
          <td>Vertrauensperson</td>
          <td>
            <inline-editor v-model="user.confidantEmail" @input="user.save()" />
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { User } from "@/api";
import InlineEditor from "@/components/InlineEditor.vue";

@Component({
  components: { InlineEditor },
})
export default class UserTable extends Vue {
  @Prop() private user!: User;

  async activate(): Promise<void> {
    await this.user.activate();
  }
}
</script>
