<template lang="pug">
  .w-full.h-full.flex.flex-col
    .flex.w-full.gap-x-2.pb-2
      medical-header(
        v-model="currentMenuItem",
        :change-shown-remove-modal="changeShownRemoveModal",
      )
      medical-records
    component(
      v-if="currentMenuItem",
      v-bind:is="currentMenuItem",
    )
    base-modal(
      v-model="isShownRemoveModal",
      title="Удаление медкарты"
    )
      medical-remove-modal(:change-shown-remove-modal="changeShownRemoveModal")
</template>

<script>
import MedicalHeader from "@/pages/newMedicalCard/components/MedicalHeader.vue";
import MedicalRecords from "@/pages/newMedicalCard/components/MedicalRecords.vue";
import MedicalBaseInfo from "@/pages/newMedicalCard/components/MedicalBaseInfo.vue";
import BaseModal from "@/components/base/BaseModal.vue";
import MedicalRemoveModal from "@/pages/newMedicalCard/components/MedicalRemoveModal.vue";
import { mapState } from "vuex";
export default {
  name: "TheMedicalCard",
  components: {
    MedicalHeader,
    MedicalRecords,
    MedicalBaseInfo,
    BaseModal,
    MedicalRemoveModal,
  },
  data() {
    return {
      currentMenuItem: "MedicalBaseInfo",
      isShownRemoveModal: false,
    };
  },
  methods: {
    changeShownRemoveModal(value) {
      this.isShownRemoveModal = value;
    },
  },
  computed: mapState({
    medical: (state) => state.medical.medicalCard,
  }),
  created() {
    this.$store.dispatch("getMedicalDataById", this.$route.params.id);
  },
};
</script>
