<template>
  <div class="flex flex-col gap-2 h-full w-full overflow-y-auto">
    <div v-if="activeProtocol != null" class="flex flex-col gap-2 w-full">Protokoll Details</div>

    <Spinner v-if="loadingActive == 'loading'" class="mx-auto" />
    <p v-else-if="loadingActive == 'failed'" @click="fetchProtocolByActiveId" class="cursor-pointer">
      &#8634; 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 { useProtocolStore } from "@/stores/admin/protocol";
</script>

<script lang="ts">
export default defineComponent({
  props: {
    protocolId: String,
  },
  computed: {
    ...mapState(useProtocolStore, ["activeProtocol", "loadingActive"]),
  },
  mounted() {
    this.fetchProtocolByActiveId();
  },
  methods: {
    ...mapActions(useProtocolStore, ["fetchProtocolByActiveId"]),
  },
});
</script>
