added paymentadjustment head crud operation
This commit is contained in:
parent
51cca64dd5
commit
aa947b791b
@ -34,6 +34,8 @@ const Header = () => {
|
|||||||
const isDashboardPath =
|
const isDashboardPath =
|
||||||
/^\/dashboard$/.test(location.pathname) || /^\/$/.test(location.pathname);
|
/^\/dashboard$/.test(location.pathname) || /^\/$/.test(location.pathname);
|
||||||
const isProjectPath = /^\/projects$/.test(location.pathname);
|
const isProjectPath = /^\/projects$/.test(location.pathname);
|
||||||
|
const isCollectionPath =
|
||||||
|
/^\/collection$/.test(location.pathname) || /^\/$/.test(location.pathname);
|
||||||
|
|
||||||
const showProjectDropdown = (pathname) => {
|
const showProjectDropdown = (pathname) => {
|
||||||
const isDirectoryPath = /^\/directory$/.test(pathname);
|
const isDirectoryPath = /^\/directory$/.test(pathname);
|
||||||
@ -216,7 +218,7 @@ const Header = () => {
|
|||||||
className="dropdown-menu"
|
className="dropdown-menu"
|
||||||
style={{ overflow: "auto", maxHeight: "300px" }}
|
style={{ overflow: "auto", maxHeight: "300px" }}
|
||||||
>
|
>
|
||||||
{isDashboardPath && (
|
{(isDashboardPath|| isCollectionPath) &&(
|
||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
className="dropdown-item"
|
className="dropdown-item"
|
||||||
|
@ -11,7 +11,7 @@ import { formatFigure, localToUtc } from "../../utils/appUtils";
|
|||||||
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||||
import Avatar from "../common/Avatar";
|
import Avatar from "../common/Avatar";
|
||||||
import { PaymentHistorySkeleton } from "./CollectionSkeleton";
|
import { PaymentHistorySkeleton } from "./CollectionSkeleton";
|
||||||
import { usePaymentType } from "../../hooks/masterHook/useMaster";
|
import { usePaymentAjustmentHead } from "../../hooks/masterHook/useMaster";
|
||||||
|
|
||||||
const AddPayment = ({ onClose }) => {
|
const AddPayment = ({ onClose }) => {
|
||||||
const { addPayment } = useCollectionContext();
|
const { addPayment } = useCollectionContext();
|
||||||
@ -23,7 +23,7 @@ const AddPayment = ({ onClose }) => {
|
|||||||
isLoading: isPaymentTypeLoading,
|
isLoading: isPaymentTypeLoading,
|
||||||
isError: isPaymentTypeError,
|
isError: isPaymentTypeError,
|
||||||
error: paymentError,
|
error: paymentError,
|
||||||
} = usePaymentType(true);
|
} = usePaymentAjustmentHead(true);
|
||||||
const methods = useForm({
|
const methods = useForm({
|
||||||
resolver: zodResolver(paymentSchema),
|
resolver: zodResolver(paymentSchema),
|
||||||
defaultValues: defaultPayment,
|
defaultValues: defaultPayment,
|
||||||
|
@ -6,9 +6,11 @@ import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
|||||||
import Pagination from "../common/Pagination";
|
import Pagination from "../common/Pagination";
|
||||||
import { useCollectionContext } from "../../pages/collections/CollectionPage";
|
import { useCollectionContext } from "../../pages/collections/CollectionPage";
|
||||||
import { CollectionTableSkeleton } from "./CollectionSkeleton";
|
import { CollectionTableSkeleton } from "./CollectionSkeleton";
|
||||||
|
import { useSelectedProject } from "../../slices/apiDataManager";
|
||||||
|
|
||||||
const CollectionList = ({ fromDate, toDate, isPending, searchString }) => {
|
const CollectionList = ({ fromDate, toDate, isPending, searchString }) => {
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
const selectedProject = useSelectedProject()
|
||||||
const searchDebounce = useDebounce(searchString, 500);
|
const searchDebounce = useDebounce(searchString, 500);
|
||||||
|
|
||||||
const { data, isLoading, isError, error } = useCollections(
|
const { data, isLoading, isError, error } = useCollections(
|
||||||
@ -18,6 +20,7 @@ const CollectionList = ({ fromDate, toDate, isPending, searchString }) => {
|
|||||||
localToUtc(toDate),
|
localToUtc(toDate),
|
||||||
isPending,
|
isPending,
|
||||||
true,
|
true,
|
||||||
|
selectedProject,
|
||||||
searchDebounce
|
searchDebounce
|
||||||
);
|
);
|
||||||
const { setProcessedPayment, setAddPayment, setViewCollection } =
|
const { setProcessedPayment, setAddPayment, setViewCollection } =
|
||||||
|
@ -76,7 +76,7 @@ const Comment = ({ invoice }) => {
|
|||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<p className="text-muted">No comments yet.</p>
|
<div className="text-center py-2"> <p className="text-muted">No comments yet.</p></div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -7,7 +7,7 @@ const PaymentHistoryTable = ({data}) => {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
{data?.receivedInvoicePayments?.length > 0 && (
|
{data?.receivedInvoicePayments?.length > 0 ? (
|
||||||
<div className="pt-1 data-tabe table-responsive">
|
<div className="pt-1 data-tabe table-responsive">
|
||||||
<table className="table table-bordered table-responsive mt-2">
|
<table className="table table-bordered table-responsive mt-2">
|
||||||
<thead className="table-light">
|
<thead className="table-light">
|
||||||
@ -45,7 +45,7 @@ const PaymentHistoryTable = ({data}) => {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
)}
|
):(<div className='text-center py-2'><p>No History</p></div>)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,10 @@ import ManageDocumentCategory from "./ManageDocumentCategory";
|
|||||||
import ManageDocumentType from "./ManageDocumentType";
|
import ManageDocumentType from "./ManageDocumentType";
|
||||||
import ManageServices from "./Services/ManageServices";
|
import ManageServices from "./Services/ManageServices";
|
||||||
import ServiceGroups from "./Services/ServicesGroups";
|
import ServiceGroups from "./Services/ServicesGroups";
|
||||||
|
import ManagePaymentHead from "./paymentAdjustmentHead/ManagePaymentHead";
|
||||||
|
|
||||||
const MasterModal = ({ modaldata, closeModal }) => {
|
const MasterModal = ({ modaldata, closeModal }) => {
|
||||||
if (!modaldata?.modalType || modaldata.modalType === "delete") {
|
if (!modaldata?.modalType || modaldata.modalType === "delete") {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ const MasterModal = ({ modaldata, closeModal }) => {
|
|||||||
<EditRole master={modaldata} onClose={closeModal} />
|
<EditRole master={modaldata} onClose={closeModal} />
|
||||||
),
|
),
|
||||||
"Job Role": <CreateJobRole onClose={closeModal} />,
|
"Job Role": <CreateJobRole onClose={closeModal} />,
|
||||||
"Edit-Job Role": <EditJobRole data={item} onClose={closeModal} />,
|
"Edit-Job Role": <EditJobRole data={item} onClose={closeModal} />,
|
||||||
"Work Category": <CreateWorkCategory onClose={closeModal} />,
|
"Work Category": <CreateWorkCategory onClose={closeModal} />,
|
||||||
"Edit-Work Category": <EditWorkCategory data={item} onClose={closeModal} />,
|
"Edit-Work Category": <EditWorkCategory data={item} onClose={closeModal} />,
|
||||||
"Contact Category": <CreateCategory data={item} onClose={closeModal} />,
|
"Contact Category": <CreateCategory data={item} onClose={closeModal} />,
|
||||||
@ -58,24 +58,20 @@ const MasterModal = ({ modaldata, closeModal }) => {
|
|||||||
"Edit-Document Type": (
|
"Edit-Document Type": (
|
||||||
<ManageDocumentType data={item} onClose={closeModal} />
|
<ManageDocumentType data={item} onClose={closeModal} />
|
||||||
),
|
),
|
||||||
"Services": (
|
Services: <ManageServices onClose={closeModal} />,
|
||||||
<ManageServices onClose={closeModal} />
|
"Edit-Services": <ManageServices data={item} onClose={closeModal} />,
|
||||||
),
|
"Manage-Services": <ServiceGroups service={item} onClose={closeModal} />,
|
||||||
"Edit-Services": (
|
"Payment Adjustment Head": <ManagePaymentHead onClose={closeModal} />,
|
||||||
<ManageServices data={item} onClose={closeModal} />
|
"Edit-Payment Adjustment Head": <ManagePaymentHead data={item} onClose={closeModal} />
|
||||||
),
|
|
||||||
"Manage-Services": (
|
|
||||||
<ServiceGroups service={item} onClose={closeModal}/>
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-2 p-md-1">
|
<div className="p-2 p-md-1">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<p className="fs-5 fw-semibold" >{`${masterType, " ", modalType}`}</p>
|
<p className="fs-5 fw-semibold">{`${(masterType, " ", modalType)}`}</p>
|
||||||
|
</div>
|
||||||
|
{modalComponents[modalType] || null}
|
||||||
</div>
|
</div>
|
||||||
{ modalComponents[modalType] || null}
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -0,0 +1,107 @@
|
|||||||
|
import React, { useEffect } from "react";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import Label from "../../common/Label";
|
||||||
|
import { useCreatePaymentAjustmentHead, useUpdatePaymentAjustmentHead } from "../../../hooks/masterHook/useMaster";
|
||||||
|
|
||||||
|
export const simpleFormSchema = z.object({
|
||||||
|
name: z.string().min(1, "Name is required"),
|
||||||
|
description: z.string().min(1, "Description is required"),
|
||||||
|
});
|
||||||
|
|
||||||
|
const ManagePaymentHead = ({ data, onClose }) => {
|
||||||
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
reset,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm({
|
||||||
|
resolver: zodResolver(simpleFormSchema),
|
||||||
|
defaultValues: {
|
||||||
|
name: "",
|
||||||
|
description: "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const {mutate:CreateAjustmentHead,isPending} = useCreatePaymentAjustmentHead(()=>{
|
||||||
|
handleClose?.()
|
||||||
|
});
|
||||||
|
const {mutate:UpdateAjustmentHead,isPending:isUpdating} = useUpdatePaymentAjustmentHead(()=>{
|
||||||
|
handleClose?.()
|
||||||
|
})
|
||||||
|
const onSubmit = (formData) => {
|
||||||
|
if(data){
|
||||||
|
let id = data?.id;
|
||||||
|
const payload = {
|
||||||
|
...formData,
|
||||||
|
id:id,
|
||||||
|
}
|
||||||
|
UpdateAjustmentHead({id:id,payload:payload})
|
||||||
|
}else{
|
||||||
|
let payload={
|
||||||
|
...formData
|
||||||
|
}
|
||||||
|
CreateAjustmentHead(payload)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data) {
|
||||||
|
reset({
|
||||||
|
name: data.name,
|
||||||
|
description: data.description,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [data]);
|
||||||
|
const handleClose = () => {
|
||||||
|
reset();
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div className="row text-start">
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)} className="p-4">
|
||||||
|
<div className="mb-3">
|
||||||
|
<Label htmlFor="name" required>
|
||||||
|
Name
|
||||||
|
</Label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
{...register("name")}
|
||||||
|
className={`form-control ${errors.name ? "is-invalid" : ""}`}
|
||||||
|
/>
|
||||||
|
{errors.name && (
|
||||||
|
<div className="invalid-feedback">{errors.name.message}</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-3">
|
||||||
|
<Label htmlFor="description" required>
|
||||||
|
Description
|
||||||
|
</Label>
|
||||||
|
<textarea
|
||||||
|
{...register("description")}
|
||||||
|
className={`form-control ${errors.description ? "is-invalid" : ""}`}
|
||||||
|
/>
|
||||||
|
{errors.description && (
|
||||||
|
<div className="invalid-feedback">{errors.description.message}</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="d-flex flex-row justify-content-end gap-2">
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-label-secondary"
|
||||||
|
onClick={handleClose} disabled={isUpdating || isPending}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button type="submit" className="btn btn-sm btn-primary" disabled={isUpdating || isPending}>
|
||||||
|
{isPending || isUpdating ? "Please Wait" :data ? "Update":"Submit"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ManagePaymentHead;
|
@ -10,10 +10,10 @@ import {
|
|||||||
} from "@tanstack/react-query";
|
} from "@tanstack/react-query";
|
||||||
import showToast from "../../services/toastService";
|
import showToast from "../../services/toastService";
|
||||||
|
|
||||||
export const usePaymentType = (isActive) => {
|
export const usePaymentAjustmentHead = (isActive) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ["paymentType",isActive],
|
queryKey: ["paymentType",isActive],
|
||||||
queryFn: async () => await MasterRespository.getPaymentType(isActive),
|
queryFn: async () => await MasterRespository.getPaymentAdjustmentHead(isActive),
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -303,6 +303,8 @@ const fetchMasterData = async (masterType) => {
|
|||||||
return (await MasterRespository.getDocumentTypes()).data;
|
return (await MasterRespository.getDocumentTypes()).data;
|
||||||
case "Document Category":
|
case "Document Category":
|
||||||
return (await MasterRespository.getDocumentCategories()).data;
|
return (await MasterRespository.getDocumentCategories()).data;
|
||||||
|
case "Payment Adjustment Head":
|
||||||
|
return (await MasterRespository.getPaymentAdjustmentHead(true)).data;
|
||||||
case "Status":
|
case "Status":
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -998,7 +1000,52 @@ export const useUpdateDocumentType = (onSuccessCallback) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// -Delete Master --------
|
// ------------------------------x-x--------x-x------------------------------------
|
||||||
|
|
||||||
|
// ==============================Payment Adjustment Head =============================
|
||||||
|
export const useCreatePaymentAjustmentHead = (onSuccessCallback) => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async (payload) => {
|
||||||
|
const resp = await MasterRespository.createPaymentAjustmentHead(payload);
|
||||||
|
return resp.data;
|
||||||
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["masterData", "Payment Adjustment Head"],
|
||||||
|
});
|
||||||
|
showToast("Payment Ajustment Head successfully", "success");
|
||||||
|
if (onSuccessCallback) onSuccessCallback(data);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
showToast(error.message || "Something went wrong", "error");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export const useUpdatePaymentAjustmentHead = (onSuccessCallback) => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async ({ id, payload }) => {
|
||||||
|
const resp = await MasterRespository.updatePaymentAjustmentHead(id, payload);
|
||||||
|
return resp.data;
|
||||||
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["masterData", "Payment Adjustment Head"],
|
||||||
|
});
|
||||||
|
showToast("Payment Ajustment Head Updated successfully", "success");
|
||||||
|
if (onSuccessCallback) onSuccessCallback(data);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
showToast(error.message || "Something went wrong", "error");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
// ====================x=x====================x=x==================================
|
||||||
|
|
||||||
|
// --------Delete Master --------
|
||||||
export const useDeleteMasterItem = () => {
|
export const useDeleteMasterItem = () => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ export const useCollections = (
|
|||||||
toDate,
|
toDate,
|
||||||
isPending,
|
isPending,
|
||||||
isActive,
|
isActive,
|
||||||
|
projectId,
|
||||||
searchString
|
searchString
|
||||||
) => {
|
) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
@ -20,6 +21,7 @@ export const useCollections = (
|
|||||||
toDate,
|
toDate,
|
||||||
isPending,
|
isPending,
|
||||||
isActive,
|
isActive,
|
||||||
|
projectId,
|
||||||
searchString,
|
searchString,
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -31,6 +33,7 @@ export const useCollections = (
|
|||||||
toDate,
|
toDate,
|
||||||
isPending,
|
isPending,
|
||||||
isActive,
|
isActive,
|
||||||
|
projectId,
|
||||||
searchString
|
searchString
|
||||||
);
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
|
@ -67,6 +67,7 @@ const CollectionPage = () => {
|
|||||||
const handleMarkedPayment = (payload) => {
|
const handleMarkedPayment = (payload) => {
|
||||||
MarkedReceived(payload);
|
MarkedReceived(payload);
|
||||||
};
|
};
|
||||||
|
console.log(fromDate,toDate)
|
||||||
return (
|
return (
|
||||||
<CollectionContext.Provider value={contextMassager}>
|
<CollectionContext.Provider value={contextMassager}>
|
||||||
<div className="container-fluid">
|
<div className="container-fluid">
|
||||||
|
@ -7,12 +7,13 @@ export const CollectionRepository = {
|
|||||||
updateCollection:(id,data)=>{
|
updateCollection:(id,data)=>{
|
||||||
api.put(`/api/Collection/invoice/edit/${id}`,data)
|
api.put(`/api/Collection/invoice/edit/${id}`,data)
|
||||||
},
|
},
|
||||||
getCollections: (pageSize, pageNumber,fromDate,toDate, isPending,isActive, searchString) => {
|
getCollections: (pageSize, pageNumber,fromDate,toDate, isPending,isActive,projectId, searchString) => {
|
||||||
let url = `/api/Collection/invoice/list?pageSize=${pageSize}&pageNumber=${pageNumber}&isPending=${isPending}&isActive=${isActive}&searchString=${searchString}`;
|
let url = `/api/Collection/invoice/list?pageSize=${pageSize}&pageNumber=${pageNumber}&isPending=${isPending}&isActive=${isActive}&searchString=${searchString}`;
|
||||||
|
|
||||||
const params = [];
|
const params = [];
|
||||||
if (fromDate) params.push(`fromDate=${fromDate}`);
|
if (fromDate) params.push(`fromDate=${fromDate}`);
|
||||||
if (toDate) params.push(`toDate=${toDate}`);
|
if (toDate) params.push(`toDate=${toDate}`);
|
||||||
|
if(projectId) params.push(`projectId=${projectId}`)
|
||||||
|
|
||||||
if (params.length > 0) {
|
if (params.length > 0) {
|
||||||
url += `&${params.join("&")}`;
|
url += `&${params.join("&")}`;
|
||||||
|
@ -58,6 +58,7 @@ export const MasterRespository = {
|
|||||||
"Document Type": (id) => api.delete(`/api/Master/document-type/delete/${id}`),
|
"Document Type": (id) => api.delete(`/api/Master/document-type/delete/${id}`),
|
||||||
"Document Category": (id) =>
|
"Document Category": (id) =>
|
||||||
api.delete(`/api/Master/document-category/delete/${id}`),
|
api.delete(`/api/Master/document-category/delete/${id}`),
|
||||||
|
"Payment Adjustment Head":(id,isActive)=>api.delete(`/api/Master/payment-adjustment-head/delete/${id}`,(isActive=false)),
|
||||||
|
|
||||||
getWorkCategory: () => api.get(`/api/master/work-categories`),
|
getWorkCategory: () => api.get(`/api/master/work-categories`),
|
||||||
createWorkCategory: (data) => api.post(`/api/master/work-category`, data),
|
createWorkCategory: (data) => api.post(`/api/master/work-category`, data),
|
||||||
@ -131,6 +132,8 @@ export const MasterRespository = {
|
|||||||
|
|
||||||
getOrganizationType: () => api.get("/api/Master/organization-type/list"),
|
getOrganizationType: () => api.get("/api/Master/organization-type/list"),
|
||||||
|
|
||||||
getPaymentType: (isActive) =>
|
getPaymentAdjustmentHead: (isActive) =>
|
||||||
api.get(`/api/Master/payment-adjustment-head/list?isActive=${isActive}`),
|
api.get(`/api/Master/payment-adjustment-head/list?isActive=${isActive}`),
|
||||||
|
createPaymentAjustmentHead:(data)=>api.post(`/api/Master/payment-adjustment-head`, data),
|
||||||
|
updatePaymentAjustmentHead:(id,data)=>api.put(`/api/Master/payment-adjustment-head/edit/${id}`, data)
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user