<template>
  <div class="flex flex-col gap-2 h-full w-full overflow-y-auto">
    <div v-if="memberExecutivePositions != null" class="flex flex-col gap-2 w-full">
      <MemberExecutivePositionListItem
        v-for="position in memberExecutivePositions"
        :key="position.id"
        :position="position"
      />
    </div>
    <Spinner v-if="loading == 'loading'" class="mx-auto" />
    <p v-else-if="loading == 'failed'">laden fehlgeschlagen</p>
  </div>
  <div class="flex flex-row gap-4">
    <button primary class="!w-fit" @click="">Vereinsamt hinzufügen</button>
  </div>
</template>

<script setup lang="ts">
import { defineComponent } from "vue";
import { mapActions, mapState } from "pinia";
import Spinner from "@/components/Spinner.vue";
import { useMemberExecutivePositionStore } from "@/stores/admin/memberExecutivePosition";
import MemberExecutivePositionListItem from "@/components/admin/club/member/MemberExecutivePositionListItem.vue";
</script>

<script lang="ts">
export default defineComponent({
  computed: {
    ...mapState(useMemberExecutivePositionStore, ["memberExecutivePositions", "loading"]),
  },
  mounted() {
    this.fetchItem();
  },
  methods: {
    ...mapActions(useMemberExecutivePositionStore, ["fetchMemberExecutivePositionsForMember"]),
    fetchItem() {
      this.fetchMemberExecutivePositionsForMember();
    },
  },
});
</script>
