Merge branch 'Project_Branch_Management' of https://git.marcoaiot.com/admin/marco.pms.web into Project_Branch_Management
This commit is contained in:
commit
2dbf5dc109
@ -85,7 +85,7 @@ const PaymentRequestList = ({ filters, filterData, removeFilterChip, clearFilter
|
||||
key: "paymentRequestUID",
|
||||
label: "Request ID",
|
||||
align: "text-start mx-2",
|
||||
getValue: (e) => e.paymentRequestUID || "N/A",
|
||||
getValue: (e) => <div className="d-flex"><span>{e.paymentRequestUID || "N/A"}</span> {e.isAdvancePayment && <span class="ms-1 badge bg-label-warning text-xxs" >Adv</span>}</div>,
|
||||
},
|
||||
{
|
||||
key: "title",
|
||||
|
||||
@ -148,7 +148,7 @@ const ViewPaymentRequest = ({ requestId }) => {
|
||||
<div className="col-12 col-sm-6 ">
|
||||
<div className="row ">
|
||||
<div className="col-12 d-flex justify-content-between mb-6">
|
||||
<div className="d-flex align-items-center"><span className="fw-semibold">PR No : </span><span className="fw-semibold ms-2"> {data?.paymentRequestUID}</span></div>
|
||||
<div className="d-flex align-items-center"><span className="fw-semibold">PR No : </span><span className="fw-semibold ms-2"> {data?.paymentRequestUID}</span> {data.isAdvancePayment && <span class="ms-1 badge bg-label-warning text-xs" >Advance</span>}</div>
|
||||
<span
|
||||
className={`badge bg-label-${getColorNameFromHex(data?.expenseStatus?.color) || "secondary"
|
||||
}`}
|
||||
|
||||
@ -181,7 +181,7 @@ export const useJobComments = (jobId, pageSize, pageNumber) => {
|
||||
);
|
||||
return resp.data;
|
||||
},
|
||||
enabled:!!jobId,
|
||||
enabled: !!jobId,
|
||||
|
||||
initialPageParam: pageNumber,
|
||||
|
||||
@ -282,3 +282,105 @@ export const useUpdateServiceProjectJob = (onSuccessCallback) => {
|
||||
};
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Branch
|
||||
export const useBranches = (
|
||||
projectId,
|
||||
isActive,
|
||||
pageSize,
|
||||
pageNumber,
|
||||
searchString
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: [
|
||||
"branches",
|
||||
projectId,
|
||||
isActive,
|
||||
pageSize,
|
||||
pageNumber,
|
||||
searchString,
|
||||
],
|
||||
queryFn: async () => {
|
||||
const resp = await ServiceProjectRepository.GetBranchList(
|
||||
projectId,
|
||||
isActive,
|
||||
pageSize,
|
||||
pageNumber,
|
||||
searchString
|
||||
);
|
||||
return resp.data;
|
||||
},
|
||||
enabled: !!projectId,
|
||||
});
|
||||
};
|
||||
|
||||
export const useBranch = (id)=>{
|
||||
return useQuery({
|
||||
queryKey:["branch",id],
|
||||
queryFn:()=>{
|
||||
const resp = await ServiceProjectRepository.GetBranchDetail(id);
|
||||
return resp.data ?? resp;
|
||||
},
|
||||
enabled:!!id
|
||||
})
|
||||
}
|
||||
|
||||
export const useCreateBranche =()=>{
|
||||
return useMutation({
|
||||
mutationFn:(payload)=> await ServiceProjectRepository.CreateBranch(payload),
|
||||
onSuccess: (data, variables) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["branches"],
|
||||
});
|
||||
if (onSuccessCallback) onSuccessCallback();
|
||||
showToast("Branch created successfully", "success");
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(
|
||||
error?.response?.data?.message ||
|
||||
error.message ||
|
||||
"Failed to create branch",
|
||||
"error"
|
||||
);
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const useUpdateBranch=()=>{
|
||||
return useMutation({
|
||||
mutationFn:async({id,payload})=> await ServiceProjectRepository.UpdateBranch(id,payload),
|
||||
onSuccess: (_,variables) => {
|
||||
queryClient.invalidateQueries({ queryKey: ["branches"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["branch",variables.id] });
|
||||
if (onSuccessCallback) onSuccessCallback();
|
||||
showToast("Branch Updated successfully", "success");
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(
|
||||
error?.response?.data?.message ||
|
||||
error.message ||
|
||||
"Failed to update branch",
|
||||
"error"
|
||||
);
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const useDeleteBranch=()=>{
|
||||
return useMutation({
|
||||
mutationFn:async(id)=> await ServiceProjectRepository.DeleteBranch(id),
|
||||
onSuccess: (_,variables) => {
|
||||
queryClient.invalidateQueries({ queryKey: ["branches"] });
|
||||
if (onSuccessCallback) onSuccessCallback();
|
||||
showToast("Branch Deleted successfully", "success");
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(
|
||||
error?.response?.data?.message ||
|
||||
error.message ||
|
||||
"Failed to delete branch",
|
||||
"error"
|
||||
);
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
import { api } from "../utils/axiosClient";
|
||||
|
||||
export const ServiceProjectRepository = {
|
||||
//#region Service Project
|
||||
CreateServiceProject: (data) => api.post("/api/ServiceProject/create", data),
|
||||
GetServiceProjects: (pageSize, pageNumber) =>
|
||||
api.get(
|
||||
@ -17,6 +18,8 @@ export const ServiceProjectRepository = {
|
||||
api.get(
|
||||
`/api/ServiceProject/get/allocation/list?projectId=${projectId}&isActive=${isActive} `
|
||||
),
|
||||
//#endregion
|
||||
|
||||
//#region Job
|
||||
|
||||
CreateJob: (data) => api.post(`/api/ServiceProject/job/create`, data),
|
||||
@ -35,13 +38,19 @@ export const ServiceProjectRepository = {
|
||||
api.patch(`/api/ServiceProject/job/edit/${id}`, patchData, {
|
||||
"Content-Type": "application/json-patch+json",
|
||||
}),
|
||||
//#endregion
|
||||
|
||||
//Branch API
|
||||
getServiceBranch: (jobTicketId, pageSize, pageNumber) =>
|
||||
//#region Project Branch
|
||||
CreateBranch: (data) => api.post(`/api/ServiceProject/create`, data),
|
||||
UpdateBranch: (id, data) =>
|
||||
api.put("/api/ServiceProject/branch/edit/${id}", data),
|
||||
GetBranchList: (projectId, isActive, pageSize, pageNumber, searchString) => {
|
||||
api.get(
|
||||
`/api/serviceproject/branch/list?jobTicketId=${jobTicketId}&pageSize=${pageSize}&pageNumber=${pageNumber}`
|
||||
),
|
||||
|
||||
`/api/ServiceProject/branch/list/${projectId}&isActive=${isActive}&pageSize=${pageSize}&pageNumber=${pageNumber}&searchString=${searchString}`
|
||||
);
|
||||
},
|
||||
GetBranchDetail: (id) => api.get(`/api/ServiceProject/branch/details/${id}`),
|
||||
DeleteBranch: (id) => api.delete(`/api/ServiceProject/branch/delete/${id}`),
|
||||
};
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user