/**
 * api ระบบจัดการ Tree
 *
 */
import env from "../index";
//Dropdown เพิ่มโครงร้างหน่วยงาน
// const organizationAgency = `${env.API_URI_ORG_SERVICE}/organization-agency/`;
// const organizationGovernmentAgency = `${env.API_URI_ORG_SERVICE}/organization-government-agency/`;
// const organizationPath = `${env.API_URI}/Organization/tree`;
const organizationPath = `${env.API_URI_ORG_SERVICE}/Organization/`;
const postionMasterPath = `${env.API_URI_ORG_SERVICE}/PositionMaster`;
const organizationPosition = `${env.API_URI_ORG_SERVICE}/OrganizationPosition/`;
const organizationEmployee = `${env.API_URI_ORG_EMPLOYEE_SERVICE}/organization-employee/`;

const report = `${env.API_URI}/report/organization/`;

export default {
  getOCType: `${report}oc-type`,
  getReportAccount1: (id: string) => `${report}account1/${id}`,
  getReportAccount2: (id: string) => `${report}account2/${id}`,
  getReportAccount3: (id: string) => `${report}account3/${id}`,

  /**api หน่วยงานต้นสังกัด/ส่วนราชการต้นสังกัด
   * @param organizationType หน่วยงาน หรือ ส่วนราชการ
   * @returns organizationId and organizationName
   */
  listOrganizationAgency: (organizationType: string) =>
    `${organizationPath}type/${organizationType}`,
  listOrganizationHistoryAgency: (organizationType: string) =>
    `${organizationPath}history/type/${organizationType}`,

  /**api Tree
   *
   */
  //   treeList: `${organizationPath}`,
  getTreeRoot: `${organizationPath}treeroot`,
  getDraftTreeRoot: `${organizationPath}history/treeroot`,
  getTreeHistory: `${organizationPath}publish-history`,

  getPublishFileHistory: `${organizationPath}publish-file`,

  getTreeNode: (organizationId: string, keyId: string) =>
    `${organizationPath}tree?organizationId=${organizationId}&keyId=${keyId}`,
  getDraftTreeNode: (organizationId: string, keyId: string) =>
    `${organizationPath}history/tree?organizationId=${organizationId}&keyId=${keyId}`,
  addTreeDraft: `${organizationPosition}history`,
  editTreeOrgDraft: (organizationId: string) =>
    `${organizationPath}history/${organizationId}`,
  getOrgDraft: (organizationId: string) =>
    `${organizationPath}history/${organizationId}`,
  // /api/v1/Organization/history?organizationPositionId=65ab2ddc-b9d2-4422-83d4-b90dd8191b6f
  delTreeOrgDraft: (organizationId: string) =>
    `${organizationPath}history?organizationPositionId=${organizationId}`,
  getPostionMasterDraft: (showAll: boolean) =>
    `${postionMasterPath}/history?showall=${showAll}`,
  getPostionMaster: (showAll: boolean) =>
    `${postionMasterPath}?showall=${showAll}`,
  editTreePositionDraft: (organizationPositionId: string) =>
    `${organizationPosition}history?organizationPositionId=${organizationPositionId}`,
  // /api/v1/OrganizationPosition/history?organizationPositionId=15ec8c2b-796f-4fad-b731-667a232e723e
  delTreePositionDraft: (organizationPositionId: string) =>
    `${organizationPosition}history/${organizationPositionId}`,

  //PUT /api/v1/OrganizationPosition/history/publish
  publishOrgPoDraft: `${organizationPosition}history/publish`,
  //PUT /api/v1/OrganizationPosition/history/sync
  delTreeOrgPoDraft: `${organizationPosition}history/sync`,
  isOrgPohasDraft: `${organizationPosition}history/has-draft`,
  isOrghasDraft: `${organizationPath}history/has-draft`,

  /**
   * api จัดการตำแหน่ง
   */
  getPositionMaster: `${postionMasterPath}/history`,
  getPositionMasterId: (id: string) => `${postionMasterPath}/history/${id}`,
  getPositionMasterPublish: `${postionMasterPath}/history/publish`,
  getPositionMasterSync: `${postionMasterPath}/history/sync`,
  getPositionMasterHistoryId: (id: string) =>
    `${postionMasterPath}/history/publish/${id}`,

  getPositionMasterPositionNumber: `${postionMasterPath}/position-number`,
  getPositionMasterPositionNumberId: (id: string) =>
    `${postionMasterPath}/position-number/${id}`,
  getPositionNumberIdByOcId: (OcId: string) =>
    `${postionMasterPath}/position-number/Oc/${OcId}`,

  organizationEmployee: `${organizationEmployee}`,
  organizationEmployeeId: (id: string) => `${organizationEmployee}${id}`,

  organizationEmployeePositionId: (profileId: string) =>
    `${organizationEmployee}position/${profileId}`,
  organizationEmployeeSendOrder: `${organizationEmployee}report`,

};
