<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";

/** importComponents*/
import CardDirector from "@/modules/12_evaluatePersonal/components/Detail/viewTab2/CardDirector.vue";
import CardMeet from "@/modules/12_evaluatePersonal/components/Detail/viewTab2/CardMeet.vue";

/** importStore*/
import { useCounterMixin } from "@/stores/mixin";

/** use*/
const $q = useQuasar();
const route = useRoute();
const mixin = useCounterMixin();

const { showLoader, hideLoader, messageError } = mixin;
const id = ref<string>(route.params.id as string);

const director = ref<any[]>();
const meeting = ref<any[]>();

/** function เรียกข้อมูลกรรมการ */
async function getList() {
  showLoader();
  await http
    .get(config.API.evaluationListData(id.value))
    .then((res) => {
      const data = res.data.result;
      director.value = data.directors;
      meeting.value = data.meetings;
    })
    .catch((e) => {
      messageError($q, e);
    })
    .finally(() => {
      hideLoader();
    });
}

onMounted(async () => {
  await getList();
});
</script>

<template>
  <div class="row col-12 q-pa-md">
    <div class="toptitle">กรรมการและการประชุม</div>

    <div class="row col-12 q-gutter-md">
      <CardDirector :data="director" :fetchdata="getList" />
      <CardMeet :data="meeting" :fetchdata="getList" />
    </div>
  </div>
</template>

<style >
.q-stepper--vertical .q-stepper__step-inner {
  padding: 0;
}
</style>
