<template>
  <MainTemplate>
    <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">Benutzer</h1>
      </div>
    </template>
    <template #diffMain>
      <div class="flex flex-col gap-4 grow pl-7">
        <div class="flex flex-col gap-2 grow overflow-y-scroll pr-7">
          <UserListItem v-for="user in users" :key="user.id" :user="user" />
        </div>
        <div class="flex flex-row gap-4">
          <button primary class="!w-fit">Nutzer einladen</button>
          <button primary-outline class="!w-fit">offene Einladungen</button>
        </div>
      </div>
    </template>
  </MainTemplate>
</template>

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

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