<template>
  <div class="flex flex-col gap-2 h-full w-full overflow-y-auto">
    <div v-if="memberAwards != null" class="flex flex-col gap-2 w-full">
      <MemberAwardListItem v-for="award in memberAwards" :key="award.id" :award="award" />
    </div>
    <Spinner v-if="loading == 'loading'" class="mx-auto" />
    <p v-else-if="loading == 'failed'">laden fehlgeschlagen</p>
  </div>
</template>

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

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