import { isAction } from "@reduxjs/toolkit";
import { api } from "../utils/axiosClient";

export const ServiceProjectRepository = {
  //#region Service Project
  CreateServiceProject: (data) => api.post("/api/ServiceProject/create", data),
  GetServiceProjects: (pageSize, pageNumber,searchString) =>
    api.get(
      `/api/ServiceProject/list?pageSize=${pageSize}&pageNumber=${pageNumber}&searchString=${searchString}`
    ),
  GetServiceProject: (id) => api.get(`/api/ServiceProject/details/${id}`),
  UpdateServiceProject: (id, data) =>
    api.put(`/api/ServiceProject/edit/${id}`, data),
  DeleteServiceProject: (id, isActive = false) =>
    api.delete(`/api/ServiceProject/delete/${id}?isActive=${isActive}`),
  AllocateEmployee: (data) =>
    api.post(`/api/ServiceProject/manage/allocation`, data),
  GetAllocatedEmployees: (projectId, isActive) =>
    api.get(
      `/api/ServiceProject/get/allocation/list?projectId=${projectId}&isActive=${isActive} `
    ),
  //#endregion

  //#region Job

  CreateJob: (data) => api.post(`/api/ServiceProject/job/create`, data),
  GetJobList: (pageSize, pageNumber, isActive, projectId,isArchive) =>
    api.get(
      `/api/ServiceProject/job/list?pageSize=${pageSize}&pageNumber=${pageNumber}&isActive=${isActive}&projectId=${projectId}&isArchive=${isArchive}`
    ),
  GetJobDetails: (id) => api.get(`/api/ServiceProject/job/details/${id}`),
  AddComment: (data) => api.post("/api/ServiceProject/job/add/comment", data),
  GetJobComment: (jobTicketId, pageSize, pageNumber) =>
    api.get(
      `/api/ServiceProject/job/comment/list?jobTicketId=${jobTicketId}&pageSize=${pageSize}&pageNumber=${pageNumber}`
    ),
  GetJobTags: () => api.get(`/api/ServiceProject/job/tag/list`),
  UpdateJob: (id, patchData) =>
    api.patch(`/api/ServiceProject/job/edit/${id}`, patchData, {
      "Content-Type": "application/json-patch+json",
    }),
  //#endregion

  //#region Project Branch
  CreateBranch: (data) => api.post(`/api/ServiceProject/branch/create`, data),
  UpdateBranch: (id, data) =>
    api.put(`/api/ServiceProject/branch/edit/${id}`, data),

  GetBranchList: (projectId, isActive, pageSize, pageNumber, searchString) => {
    return api.get(
      `/api/ServiceProject/branch/list/${projectId}?isActive=${isActive}&pageSize=${pageSize}&pageNumber=${pageNumber}&searchString=${searchString}`
    );
  },

  GetBranchDetail: (id) => api.get(`/api/ServiceProject/branch/details/${id}`),
  DeleteBranch: (id, isActive = false) =>
    api.delete(`/api/ServiceProject/branch/delete/${id}?isActive=${isActive}`),

  GetBranchTypeList: () => api.get(`/api/serviceproject/branch-type/list`),
};
