import { defineStore } from "pinia";
import { ref } from "vue";

import type { DataOption } from "@/modules/09_leave/interface/index/Main";

export const useSpecialTimeStore = defineStore("LeaveSpecialTime", () => {
  const optionStatus = ref<DataOption[]>([
    { id: "NORMAL", name: "ปกติ" },
    { id: "LATE", name: "สาย" },
    { id: "ABSENT", name: "ขาดราชการ" },
    { id: "NOT_COMPLETE", name: "ปฏิบัติงานไม่ครบตามกำหนดเวลา" },
  ]);

  // convertSatatus
  function convertStatus(val: string) {
    const value = val ? val.toUpperCase() : null;
    switch (value) {
      case "NORMAL":
        return "ปกติ";
      case "LATE":
        return "สาย";
      case "ABSENT":
        return "ขาดราชการ";
      default:
        value;
    }
  }

  return {
    optionStatus,
    convertStatus,
  };
});
