<template>
  <MainTemplate>
    <template #headerInsert>
      <RouterLink :to="{ name: 'admin-user-user' }" class="text-primary">zurück zur Nutzerliste</RouterLink>
    </template>
    <template #topBar>
      <div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
        <h1 class="font-bold text-xl h-8">offene Einladungen</h1>
      </div>
    </template>
    <template #diffMain>
      <div class="flex flex-col gap-2 grow overflow-y-scroll px-7">
        <InviteListItem v-for="invite in invites" :key="invite.username" :invite="invite" />
      </div>
    </template>
  </MainTemplate>
</template>

<script setup lang="ts">
import { defineComponent, markRaw, defineAsyncComponent } from "vue";
import { mapState, mapActions } from "pinia";
import MainTemplate from "@/templates/Main.vue";
import { useInviteStore } from "@/stores/admin/user/invite";
import InviteListItem from "@/components/admin/user/user/InviteListItem.vue";
</script>

<script lang="ts">
export default defineComponent({
  computed: {
    ...mapState(useInviteStore, ["invites"]),
  },
  mounted() {
    this.fetchInvites();
  },
  methods: {
    ...mapActions(useInviteStore, ["fetchInvites"]),
  },
});
</script>
