<script setup lang="ts">
import { ref, onMounted } from "vue";

import type { DataRows } from "@/modules/09_leave/interface/response/leave";
// importStroe
import { useLeavelistDataStore } from "@/modules/09_leave/stores/LeaveStore";
// importComponets
import TableList from "@/modules/09_leave/components/2_Leave/TableList.vue";
import ToolBar from "@/modules/09_leave/components/2_Leave/ToolBar.vue";
const leaveStore = useLeavelistDataStore();
const { fetchList, clearFilter } = leaveStore;

onMounted(() => {
  fecthLeaveList();
});
// เรียกข้อมูลจาก API
function fecthLeaveList() {
  const data = [
    {
      leaveType: "ลาป่วย",
      name: "นายกัณฐิมา  กาฬสินธ์ุ",
      Date: "2023-11-03",
      status: "NEW",
    },
    {
      leaveType: "ลากิจส่วนตัว",
      name: "นายนครชัย วันดี",
      Date: "2023-11-01",
      status: "APPROVE",
    },
    {
      leaveType: "ลากิจส่วนตัว",
      name: "นายกัณฐิมา  กาฬสินธ์ุ",
      Date: "2023-11-02",
      status: "PENDING",
    },
    {
      leaveType: "ลาป่วย",
      name: "นายปิยรมย์ ศิริธาราฟ",
      Date: "2023-11-01",
      status: "PENDING",
    },
  ];
  fetchList(data); // ส่งข้อมูลไป stores
}
//เปลี่ยน Tab
function changTab() {
  clearFilter();
  fecthLeaveList();
}
</script>
<template>
  <div class="toptitle text-dark col-12 row items-center">รายการลา</div>
  <div>
    <q-card flat bordered class="col-12 q-mt-sm q-pt-sm q-pa-md">
      <ToolBar />
      <TableList />
    </q-card>
  </div>
</template>
