<template>
  <RouterLink
    :to="{ name: 'admin-club-member-overview', params: { memberId: member.id } }"
    class="flex flex-col h-fit w-full border border-primary rounded-md"
  >
    <div class="bg-primary p-2 text-white flex flex-row justify-between items-center">
      <p>{{ member.lastname }}, {{ member.firstname }} {{ member.nameaffix ? `- ${member.nameaffix}` : "" }}</p>
    </div>
    <div class="p-2">
      <p v-if="member.internalId">Interne ID: {{ member.internalId }}</p>
      <p v-if="member.note">Notiz: {{ member.note }}</p>
      <p>beigetreten: {{ member.firstMembershipEntry?.start }}</p>
      <p v-if="member.lastMembershipEntry?.end">
        ausgetreten: {{ member.lastMembershipEntry?.end }}, da
        {{ member.lastMembershipEntry?.terminationReason ?? "- kein Grund angegeben" }}
      </p>
    </div>
  </RouterLink>
</template>

<script setup lang="ts">
import { defineComponent, type PropType } from "vue";
import { mapState, mapActions } from "pinia";
import { useAbilityStore } from "@/stores/ability";
import type { MemberViewModel } from "@/viewmodels/admin/club/member/member.models";
</script>

<script lang="ts">
export default defineComponent({
  props: {
    member: { type: Object as PropType<MemberViewModel>, default: {} },
  },
  computed: {
    ...mapState(useAbilityStore, ["can"]),
  },
});
</script>
