/**ใช้รวมไฟล์ย่อยๆ ของ api แต่ละไฟล์ */

/** API Metadata */
import manageOrganization from "./api/manage/api.organization";
import managePerson from "./api/manage/api.person";
import managePosition from "./api/manage/api.position";
import managePositionEmployee from "./api/manage/api.positionEmployee";
import manageInsignia from "./api/manage/api.insignia";
import manageHoliday from "./api/manage/api.holiday";

/** API Tree List */
import organizationTreeList from "./api/02_organizational/api.treelist";

/** API Structure & Org Chart */
import organizationChart from "./api/02_organizational/api.chart";

/** API Profile List */
import profile from "./api/registry/api.profile";
import registry from "./api/registry/api.registry";

/** API dashboard  */
import message from "./api/00_dashboard/api.message";

/** API โครงสร้างอัตรากำลัง*/
import organization from "./api/02_organizational/api.organization";

import file from "./api/file/api.file";

import log from "./api/03_logs/api.log";

/** API ManagementUsers*/
import menagement from "./api/manage/api.management";

/** API ระเมินผลการปฏิบัติราชการระดับบุคคล*/
import KPI from "./api/14_KPI/api.KPI";

/** API เงินเดือน/ค่าจ้าง*/
import development from "./api/15_development/api.development";

/** API  BackUp/*/
import backup from "./api/04_system/api.backup";

/** API  Command/*/
import command from "./api/05_command/api.command";

/** API Webservices*/
import webservices from "./api/06_webservices/api.webservices";

/** socket */
import socket from "./api/socket";

// environment variables
export const compettitivePanel = import.meta.env.VITE_COMPETITIVE_EXAM_PANEL;
export const qualifyDisableExamPanel = import.meta.env
  .VITE_QUALIFY_DISABLE_EMAM_PANEL;
export const qualifyExamPanel = import.meta.env.VITE_QUALIFY_EXAM_PANEL;

const path = import.meta.env.VITE_MANUAL_URL ?? "";

const generatePopupPath = (check: any) => {
  // if (routeName.includes("viewLogs")) {
  //   return `${path}/chapter-2-superadmin-maintenance`;
  // }
  // if (routeName.includes("manageUsers")) {
  //   return `${path}/chapter-2-superadmin-maintenance`;
  // }
  // if (routeName.includes("manageRoles")) {
  //   return `${path}/chapter-2-superadmin-maintenance`;
  // }
  // if (routeName.includes("managePermission")) {
  //   return `${path}/chapter-2-superadmin-maintenance`;
  // }
  if (!check) {
    return `${path}/chapter-1-superadmin-maintenance`;
  } else if (check) {
    return `${path}/chapter-2-superadmin-maintenance`;
  } else {
    return manualConfig[check as keyof typeof manualConfig];
  }
};

const manualConfig = {
  dashboard: `${path}/chapter-2-superadmin-maintenance`,
};
const API = {
  //Metadata
  ...manageOrganization,
  ...managePerson,
  ...managePosition,
  ...managePositionEmployee,
  ...manageInsignia,
  ...manageHoliday,

  // โครงสร้างอัตรากำลัง
  ...organization,

  //Tree List
  ...organizationTreeList,
  ...organizationChart,

  //profile
  ...profile,
  ...registry,

  //dashboard
  ...message,

  /*file*/
  ...file,

  ...log,
  /**  menagement*/
  ...menagement,
  /** KPI*/
  ...KPI,
  ...development,
  /** backup*/
  ...backup,
  /** command*/
  ...command,
  /** webservices*/
  ...webservices,

  /** socket*/
  ...socket,
};

export default {
  API: API,
  generatePopupPath,
};
