Merge branch 'Feature_Expense' of https://git.marcoaiot.com/admin/marco.pms.web into Feature_DisplayList#779
This commit is contained in:
commit
71dabd5f3b
@ -1,5 +1,4 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
|
|
||||||
import CreateRole from "./CreateRole";
|
import CreateRole from "./CreateRole";
|
||||||
import DeleteMaster from "./DeleteMaster";
|
import DeleteMaster from "./DeleteMaster";
|
||||||
import EditRole from "./EditRole";
|
import EditRole from "./EditRole";
|
||||||
@ -19,66 +18,41 @@ import EditContactCategory from "./EditContactCategory";
|
|||||||
import EditContactTag from "./EditContactTag";
|
import EditContactTag from "./EditContactTag";
|
||||||
import { useDeleteMasterItem } from "../../hooks/masterHook/useMaster";
|
import { useDeleteMasterItem } from "../../hooks/masterHook/useMaster";
|
||||||
|
|
||||||
|
|
||||||
const MasterModal = ({ modaldata, closeModal }) => {
|
const MasterModal = ({ modaldata, closeModal }) => {
|
||||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||||
const { mutate: deleteMasterItem, isPending } = useDeleteMasterItem();
|
const { mutate: deleteMasterItem, isPending } = useDeleteMasterItem();
|
||||||
|
|
||||||
// const handleSelectedMasterDeleted = async () =>
|
|
||||||
// {
|
|
||||||
// debugger
|
|
||||||
// const deleteFn = MasterRespository[modaldata.masterType];
|
|
||||||
// if (!deleteFn) {
|
|
||||||
// showToast(`No delete strategy defined for master type`,"error");
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// const response = await deleteFn( modaldata?.item?.id );
|
|
||||||
// const selected_cachedData = getCachedData( modaldata?.masterType );
|
|
||||||
// const updated_master = selected_cachedData?.filter(item => item.id !== modaldata?.item.id);
|
|
||||||
// cacheData( modaldata?.masterType, updated_master )
|
|
||||||
|
|
||||||
// showToast(`${modaldata?.masterType} is deleted successfully`, "success");
|
|
||||||
// handleCloseDeleteModal()
|
|
||||||
|
|
||||||
// } catch ( error )
|
|
||||||
// {
|
|
||||||
// const message = error.response.data.message || error.message || "Error occured api during call"
|
|
||||||
// showToast(message, "success");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
const handleSelectedMasterDeleted = () => {
|
const handleSelectedMasterDeleted = () => {
|
||||||
if (!modaldata?.masterType || !modaldata?.item?.id) {
|
const { masterType, item, validateFn } = modaldata || {};
|
||||||
|
if (!masterType || !item?.id) {
|
||||||
showToast("Missing master type or item", "error");
|
showToast("Missing master type or item", "error");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteMasterItem(
|
deleteMasterItem(
|
||||||
{
|
{ masterType, item, validateFn },
|
||||||
masterType: modaldata.masterType,
|
{ onSuccess: handleCloseDeleteModal }
|
||||||
item: modaldata.item,
|
|
||||||
validateFn: modaldata.validateFn, // optional
|
|
||||||
},
|
|
||||||
{
|
|
||||||
onSuccess: () => {
|
|
||||||
handleCloseDeleteModal();
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCloseDeleteModal = () => {
|
||||||
|
setIsDeleteModalOpen(false);
|
||||||
|
closeModal();
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (modaldata?.modalType === "delete") {
|
if (modaldata?.modalType === "delete") {
|
||||||
setIsDeleteModalOpen(true);
|
setIsDeleteModalOpen(true);
|
||||||
}
|
}
|
||||||
}, [modaldata]);
|
}, [modaldata]);
|
||||||
|
|
||||||
const handleCloseDeleteModal = () => {
|
if (!modaldata?.modalType) {
|
||||||
setIsDeleteModalOpen(false);
|
|
||||||
closeModal();
|
closeModal();
|
||||||
};
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (modaldata?.modalType === "delete" && isDeleteModalOpen) {
|
if (modaldata.modalType === "delete" && isDeleteModalOpen) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="modal fade show"
|
className="modal fade show"
|
||||||
@ -90,86 +64,63 @@ const MasterModal = ({ modaldata, closeModal }) => {
|
|||||||
<ConfirmModal
|
<ConfirmModal
|
||||||
type="delete"
|
type="delete"
|
||||||
header={`Delete ${modaldata.masterType}`}
|
header={`Delete ${modaldata.masterType}`}
|
||||||
message={"Are you sure you want delete?"}
|
message="Are you sure you want delete?"
|
||||||
onSubmit={handleSelectedMasterDeleted}
|
onSubmit={handleSelectedMasterDeleted}
|
||||||
onClose={handleCloseDeleteModal}
|
onClose={handleCloseDeleteModal}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const renderModalContent = () => {
|
||||||
|
const { modalType, item, masterType } = modaldata;
|
||||||
|
|
||||||
|
const modalComponents = {
|
||||||
|
"Application Role": <CreateRole masmodalType={masterType} onClose={closeModal} />,
|
||||||
|
"Edit-Application Role": <EditRole master={modaldata} onClose={closeModal} />,
|
||||||
|
"Job Role": <CreateJobRole onClose={closeModal} />,
|
||||||
|
"Edit-Job Role": <EditJobRole data={item} onClose={closeModal} />,
|
||||||
|
"Activity": <CreateActivity onClose={closeModal} />,
|
||||||
|
"Edit-Activity": <EditActivity activityData={item} onClose={closeModal} />,
|
||||||
|
"Work Category": <CreateWorkCategory onClose={closeModal} />,
|
||||||
|
"Edit-Work Category": <EditWorkCategory data={item} onClose={closeModal} />,
|
||||||
|
"Contact Category": <CreateCategory data={item} onClose={closeModal} />,
|
||||||
|
"Edit-Contact Category": <EditContactCategory data={item} onClose={closeModal} />,
|
||||||
|
"Contact Tag": <CreateContactTag data={item} onClose={closeModal} />,
|
||||||
|
"Edit-Contact Tag": <EditContactTag data={item} onClose={closeModal} />,
|
||||||
|
};
|
||||||
|
|
||||||
|
return modalComponents[modalType] || null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const isLargeModal = ["Application Role", "Edit-Application Role"].includes(
|
||||||
|
modaldata.modalType
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="modal fade"
|
className="modal fade show"
|
||||||
id="master-modal"
|
id="master-modal"
|
||||||
tabIndex="-1"
|
tabIndex="-1"
|
||||||
aria-hidden="true"
|
|
||||||
role="dialog"
|
role="dialog"
|
||||||
|
aria-hidden="true"
|
||||||
aria-labelledby="modalToggleLabel"
|
aria-labelledby="modalToggleLabel"
|
||||||
|
style={{ display: "block" }}
|
||||||
>
|
>
|
||||||
<div
|
<div className={`modal-dialog mx-sm-auto mx-1 ${isLargeModal ? "modal-lg" : "modal-md"} modal-simple`}>
|
||||||
className={`modal-dialog mx-sm-auto mx-1 ${
|
|
||||||
["Application Role", "Edit-Application Role"].includes(
|
|
||||||
modaldata?.modalType
|
|
||||||
)
|
|
||||||
? "modal-lg"
|
|
||||||
: "modal-md"
|
|
||||||
} modal-simple`}
|
|
||||||
>
|
|
||||||
<div className="modal-content">
|
<div className="modal-content">
|
||||||
<div className="modal-body p-sm-4 p-0">
|
<div className="modal-body p-sm-4 p-0">
|
||||||
<div className="d-flex justify-content-between">
|
<div className="d-flex justify-content-between">
|
||||||
<h6>{`${modaldata?.modalType} `}</h6>
|
<h6>{modaldata?.modalType}</h6>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn-close"
|
className="btn-close"
|
||||||
data-bs-dismiss="modal"
|
data-bs-dismiss="modal"
|
||||||
aria-label="Close"
|
aria-label="Close"
|
||||||
onClick={closeModal}
|
onClick={closeModal}
|
||||||
></button>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
{renderModalContent()}
|
||||||
{modaldata.modalType === "Application Role" && (
|
|
||||||
<CreateRole
|
|
||||||
masmodalType={modaldata.masterType}
|
|
||||||
onClose={closeModal}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{modaldata.modalType === "Edit-Application Role" && (
|
|
||||||
<EditRole master={modaldata} onClose={closeModal} />
|
|
||||||
)}
|
|
||||||
{modaldata.modalType === "Job Role" && (
|
|
||||||
<CreateJobRole onClose={closeModal} />
|
|
||||||
)}
|
|
||||||
{modaldata.modalType === "Edit-Job Role" && (
|
|
||||||
<EditJobRole data={modaldata.item} onClose={closeModal} />
|
|
||||||
)}
|
|
||||||
{modaldata.modalType === "Activity" && (
|
|
||||||
<CreateActivity onClose={closeModal} />
|
|
||||||
)}
|
|
||||||
{modaldata.modalType === "Edit-Activity" && (
|
|
||||||
<EditActivity
|
|
||||||
activityData={modaldata.item}
|
|
||||||
onClose={closeModal}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{modaldata.modalType === "Work Category" && (
|
|
||||||
<CreateWorkCategory onClose={closeModal} />
|
|
||||||
)}
|
|
||||||
{modaldata.modalType === "Edit-Work Category" && (
|
|
||||||
<EditWorkCategory data={modaldata.item} onClose={closeModal} />
|
|
||||||
)}
|
|
||||||
{modaldata.modalType === "Contact Category" && (
|
|
||||||
<CreateCategory data={modaldata.item} onClose={closeModal} />
|
|
||||||
)}
|
|
||||||
{modaldata.modalType === "Edit-Contact Category" && (
|
|
||||||
<EditContactCategory data={modaldata.item} onClose={closeModal} />
|
|
||||||
)}
|
|
||||||
{modaldata.modalType === "Contact Tag" && (
|
|
||||||
<CreateContactTag data={modaldata.item} onClose={closeModal} />
|
|
||||||
)}
|
|
||||||
{modaldata.modalType === "Edit-Contact Tag" && (
|
|
||||||
<EditContactTag data={modaldata.item} onClose={closeModal} />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,153 +1,157 @@
|
|||||||
// it important ------
|
// it important ------
|
||||||
export const mastersList = [ {id: 1, name: "Application Role"}, {id: 2, name: "Job Role"}, {id: 3, name: "Activity"},{id: 4, name:"Work Category"},{id:5,name:"Contact Category"},{id:6,name:"Contact Tag"}]
|
export const mastersList = [
|
||||||
|
{ id: 1, name: "Application Role" },
|
||||||
|
{ id: 2, name: "Job Role" },
|
||||||
|
{ id: 3, name: "Activity" },
|
||||||
|
{ id: 4, name: "Work Category" },
|
||||||
|
{ id: 5, name: "Contact Category" },
|
||||||
|
{ id: 6, name: "Contact Tag" },
|
||||||
|
{ id: 7, name: "Expense Type" },
|
||||||
|
{ id: 8, name: "Payment Mode" },
|
||||||
|
{ id: 9, name: "Expense Status" },
|
||||||
|
];
|
||||||
// -------------------
|
// -------------------
|
||||||
|
|
||||||
export const dailyTask = [
|
// export const dailyTask = [
|
||||||
{
|
// {
|
||||||
id:1,
|
// id:1,
|
||||||
project:{
|
// project:{
|
||||||
projectName:"Project Name1",
|
// projectName:"Project Name1",
|
||||||
building:"buildName1",
|
// building:"buildName1",
|
||||||
floor:"floorName1",
|
// floor:"floorName1",
|
||||||
workArea:"workarea1"
|
// workArea:"workarea1"
|
||||||
},
|
// },
|
||||||
target:80,
|
// target:80,
|
||||||
employees:[
|
// employees:[
|
||||||
{
|
// {
|
||||||
id:1,
|
// id:1,
|
||||||
name:"Vishal Patil",
|
// name:"Vishal Patil",
|
||||||
role:"helper"
|
// role:"helper"
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
id:202,
|
// id:202,
|
||||||
name:"Vishal Patil",
|
// name:"Vishal Patil",
|
||||||
role:"helper"
|
// role:"helper"
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
id:101,
|
// id:101,
|
||||||
name:"Kushal Patil",
|
// name:"Kushal Patil",
|
||||||
role:"Engineer"
|
// role:"Engineer"
|
||||||
}
|
// }
|
||||||
]
|
// ]
|
||||||
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:2,
|
|
||||||
project:{
|
|
||||||
projectName:"Project Name1",
|
|
||||||
building:"buildName1",
|
|
||||||
floor:"floorName1",
|
|
||||||
workArea:"workarea1"
|
|
||||||
},
|
|
||||||
target:90,
|
|
||||||
employees:[
|
|
||||||
{
|
|
||||||
id:1,
|
|
||||||
name:"Vishal Patil",
|
|
||||||
role:"welder"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:202,
|
|
||||||
name:"Vishal Patil",
|
|
||||||
role:"welder"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:101,
|
|
||||||
name:"Kushal Patil",
|
|
||||||
role:"Site Engineer"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const jobRoles =[
|
|
||||||
{
|
|
||||||
id:1,
|
|
||||||
name:"Project Manager"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:2,
|
|
||||||
name:"Software Developer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:3,
|
|
||||||
name:"Estimation Engineer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:4,
|
|
||||||
name:"Designer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:5,
|
|
||||||
name:"Site Engineer"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
export const employee =[
|
|
||||||
{
|
|
||||||
id:1,
|
|
||||||
FirtsName:"Pramod",
|
|
||||||
LastName:"Mahajan",
|
|
||||||
JobRoleId:2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:2,
|
|
||||||
FirtsName:"Akahsy",
|
|
||||||
LastName:"Patil",
|
|
||||||
JobRoleId:1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:3,
|
|
||||||
FirtsName:"janvi",
|
|
||||||
LastName:"Potdar",
|
|
||||||
JobRoleId:3,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:4,
|
|
||||||
FirtsName:"Aboli",
|
|
||||||
LastName:"Patil",
|
|
||||||
JobRoleId:2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:5,
|
|
||||||
FirtsName:"Shubham",
|
|
||||||
LastName:"Tamboli",
|
|
||||||
JobRoleId:1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:6,
|
|
||||||
FirtsName:"Alwin",
|
|
||||||
LastName:"Joy",
|
|
||||||
JobRoleId:4,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:7,
|
|
||||||
FirtsName:"John",
|
|
||||||
LastName:"kwel",
|
|
||||||
JobRoleId:4,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:8,
|
|
||||||
FirtsName:"Gita",
|
|
||||||
LastName:"shaha",
|
|
||||||
JobRoleId:1,
|
|
||||||
},{
|
|
||||||
id:9,
|
|
||||||
FirtsName:"Pratik",
|
|
||||||
LastName:"Joshi",
|
|
||||||
JobRoleId:5,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id:10,
|
|
||||||
FirtsName:"Nikil",
|
|
||||||
LastName:"Patil",
|
|
||||||
JobRoleId:5,
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:2,
|
||||||
|
// project:{
|
||||||
|
// projectName:"Project Name1",
|
||||||
|
// building:"buildName1",
|
||||||
|
// floor:"floorName1",
|
||||||
|
// workArea:"workarea1"
|
||||||
|
// },
|
||||||
|
// target:90,
|
||||||
|
// employees:[
|
||||||
|
// {
|
||||||
|
// id:1,
|
||||||
|
// name:"Vishal Patil",
|
||||||
|
// role:"welder"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:202,
|
||||||
|
// name:"Vishal Patil",
|
||||||
|
// role:"welder"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:101,
|
||||||
|
// name:"Kushal Patil",
|
||||||
|
// role:"Site Engineer"
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
|
||||||
|
// export const jobRoles =[
|
||||||
|
// {
|
||||||
|
// id:1,
|
||||||
|
// name:"Project Manager"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:2,
|
||||||
|
// name:"Software Developer"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:3,
|
||||||
|
// name:"Estimation Engineer"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:4,
|
||||||
|
// name:"Designer"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:5,
|
||||||
|
// name:"Site Engineer"
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
|
||||||
|
// export const employee =[
|
||||||
|
// {
|
||||||
|
// id:1,
|
||||||
|
// FirtsName:"Pramod",
|
||||||
|
// LastName:"Mahajan",
|
||||||
|
// JobRoleId:2,
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:2,
|
||||||
|
// FirtsName:"Akahsy",
|
||||||
|
// LastName:"Patil",
|
||||||
|
// JobRoleId:1,
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:3,
|
||||||
|
// FirtsName:"janvi",
|
||||||
|
// LastName:"Potdar",
|
||||||
|
// JobRoleId:3,
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:4,
|
||||||
|
// FirtsName:"Aboli",
|
||||||
|
// LastName:"Patil",
|
||||||
|
// JobRoleId:2,
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:5,
|
||||||
|
// FirtsName:"Shubham",
|
||||||
|
// LastName:"Tamboli",
|
||||||
|
// JobRoleId:1,
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:6,
|
||||||
|
// FirtsName:"Alwin",
|
||||||
|
// LastName:"Joy",
|
||||||
|
// JobRoleId:4,
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:7,
|
||||||
|
// FirtsName:"John",
|
||||||
|
// LastName:"kwel",
|
||||||
|
// JobRoleId:4,
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:8,
|
||||||
|
// FirtsName:"Gita",
|
||||||
|
// LastName:"shaha",
|
||||||
|
// JobRoleId:1,
|
||||||
|
// },{
|
||||||
|
// id:9,
|
||||||
|
// FirtsName:"Pratik",
|
||||||
|
// LastName:"Joshi",
|
||||||
|
// JobRoleId:5,
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id:10,
|
||||||
|
// FirtsName:"Nikil",
|
||||||
|
// LastName:"Patil",
|
||||||
|
// JobRoleId:5,
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
|||||||
@ -12,213 +12,6 @@ import showToast from "../../services/toastService";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// const useMaster = () => {
|
|
||||||
|
|
||||||
// const selectedMaster = useSelector((store)=>store.localVariables.selectedMaster);
|
|
||||||
// const [data, setData] = useState([]);
|
|
||||||
// const [loading, setLoading] = useState(true);
|
|
||||||
// const [error, setError] = useState("");
|
|
||||||
// useEffect(() => {
|
|
||||||
// const fetchData = async () => {
|
|
||||||
// if (!selectedMaster) return;
|
|
||||||
// setLoading(true);
|
|
||||||
// try {
|
|
||||||
// const cachedData = getCachedData(selectedMaster);
|
|
||||||
// if (cachedData) {
|
|
||||||
|
|
||||||
// setData(cachedData);
|
|
||||||
|
|
||||||
// } else {
|
|
||||||
// let response;
|
|
||||||
// switch (selectedMaster) {
|
|
||||||
// case "Application Role":
|
|
||||||
// response = await MasterRespository.getRoles();
|
|
||||||
// response = response.data;
|
|
||||||
// break;
|
|
||||||
// case "Job Role":
|
|
||||||
// response = await MasterRespository.getJobRole();
|
|
||||||
// response = response.data
|
|
||||||
// break;
|
|
||||||
// case "Activity":
|
|
||||||
// response = await MasterRespository.getActivites();
|
|
||||||
// response = response.data
|
|
||||||
// break;
|
|
||||||
// case "Work Category":
|
|
||||||
// response = await MasterRespository.getWorkCategory();
|
|
||||||
// response = response.data
|
|
||||||
// break;
|
|
||||||
// case "Contact Category":
|
|
||||||
// response = await MasterRespository.getContactCategory();
|
|
||||||
// response = response.data
|
|
||||||
// break;
|
|
||||||
// case "Contact Tag":
|
|
||||||
// response = await MasterRespository.getContactTag();
|
|
||||||
// response = response.data
|
|
||||||
// break;
|
|
||||||
// case "Status":
|
|
||||||
// response = [{description: null,featurePermission: null,id: "02dd4761-363c-49ed-8851-3d2489a3e98d",status:"status 1"},{description: null,featurePermission: null,id: "03dy9761-363c-49ed-8851-3d2489a3e98d",status:"status 2"},{description: null,featurePermission: null,id: "03dy7761-263c-49ed-8851-3d2489a3e98d",status:"Status 3"}];
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// response = [];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (response) {
|
|
||||||
// setData(response);
|
|
||||||
// cacheData(selectedMaster, response);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (err) {
|
|
||||||
// setError("Failed to fetch data.");
|
|
||||||
// } finally {
|
|
||||||
// setLoading(false);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// if ( selectedMaster )
|
|
||||||
// {
|
|
||||||
|
|
||||||
// fetchData();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }, [selectedMaster]);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// return { data, loading, error }
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// export const useActivitiesMaster = () =>
|
|
||||||
// {
|
|
||||||
// const [ activities, setActivites ] = useState( [] )
|
|
||||||
// const [ loading, setloading ] = useState( false );
|
|
||||||
// const [ error, setError ] = useState()
|
|
||||||
// const fetchActivities =async () => {
|
|
||||||
// setloading(true);
|
|
||||||
// try {
|
|
||||||
// const response = await MasterRespository.getActivites();
|
|
||||||
// setActivites(response.data);
|
|
||||||
// cacheData( "ActivityMaster", response.data );
|
|
||||||
// setloading(false);
|
|
||||||
// } catch (err) {
|
|
||||||
// setError(err);
|
|
||||||
// setloading(false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// useEffect( () =>
|
|
||||||
// {
|
|
||||||
// const cacheddata = getCachedData( "ActivityMaster" );
|
|
||||||
// if ( !cacheddata )
|
|
||||||
// {
|
|
||||||
// fetchActivities()
|
|
||||||
// } else
|
|
||||||
// {
|
|
||||||
// setActivites(cacheddata);
|
|
||||||
// }
|
|
||||||
// }, [] )
|
|
||||||
|
|
||||||
// return {activities,loading,error}
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export const useWorkCategoriesMaster = () =>
|
|
||||||
// {
|
|
||||||
// const [ categories, setCategories ] = useState( [] )
|
|
||||||
// const [ categoryLoading, setloading ] = useState( false );
|
|
||||||
// const [ categoryError, setError ] = useState( "" )
|
|
||||||
|
|
||||||
// const fetchCategories =async () => {
|
|
||||||
// const cacheddata = getCachedData("Work Category");
|
|
||||||
|
|
||||||
// if (!cacheddata) {
|
|
||||||
// setloading(true);
|
|
||||||
// try {
|
|
||||||
// const response = await MasterRespository.getWorkCategory();
|
|
||||||
// setCategories(response.data);
|
|
||||||
// cacheData("Work Category", response.data);
|
|
||||||
// } catch (err) {
|
|
||||||
// setError(err);
|
|
||||||
// console.log(err);
|
|
||||||
// } finally {
|
|
||||||
// setloading(false);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// setCategories(cacheddata);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// useEffect( () =>
|
|
||||||
// {
|
|
||||||
// fetchCategories()
|
|
||||||
// }, [] )
|
|
||||||
|
|
||||||
// return {categories,categoryLoading,categoryError}
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export const useContactCategory = () =>
|
|
||||||
// {
|
|
||||||
// const [ contactCategory, setContactCategory ] = useState( [] )
|
|
||||||
// const [ loading, setLoading ] = useState( false )
|
|
||||||
// const [ Error, setError ] = useState()
|
|
||||||
|
|
||||||
// const fetchConatctCategory = async() =>
|
|
||||||
// {
|
|
||||||
// const cache_Category = getCachedData( "Contact Category" );
|
|
||||||
// if ( !cache_Category )
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// let resp = await MasterRespository.getContactCategory();
|
|
||||||
// setContactCategory( resp.data );
|
|
||||||
// cacheData("Contact Category",resp.data)
|
|
||||||
// } catch ( error )
|
|
||||||
// {
|
|
||||||
// setError(error)
|
|
||||||
// }
|
|
||||||
// } else
|
|
||||||
// {
|
|
||||||
// setContactCategory(cache_Category)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// useEffect( () =>
|
|
||||||
// {
|
|
||||||
// fetchConatctCategory()
|
|
||||||
// }, [] )
|
|
||||||
// return { contactCategory,loading,Error}
|
|
||||||
// }
|
|
||||||
// export const useContactTags = () => {
|
|
||||||
// const [contactTags, setContactTags] = useState([]);
|
|
||||||
// const [loading, setLoading] = useState(false);
|
|
||||||
// const [error, setError] = useState(null);
|
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// const fetchContactTag = async () => {
|
|
||||||
// const cache_Tags = getCachedData("Contact Tag");
|
|
||||||
|
|
||||||
// if (!cache_Tags) {
|
|
||||||
// setLoading(true);
|
|
||||||
// try {
|
|
||||||
// const resp = await MasterRespository.getContactTag();
|
|
||||||
// setContactTags(resp.data);
|
|
||||||
// cacheData("Contact Tag", resp.data);
|
|
||||||
// } catch (err) {
|
|
||||||
// setError(err);
|
|
||||||
// } finally {
|
|
||||||
// setLoading(false);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// setContactTags(cache_Tags);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// fetchContactTag();
|
|
||||||
// }, []);
|
|
||||||
|
|
||||||
// return { contactTags, loading, error };
|
|
||||||
// };
|
|
||||||
|
|
||||||
// Separate matser-------------
|
|
||||||
|
|
||||||
export const useActivitiesMaster = () =>
|
export const useActivitiesMaster = () =>
|
||||||
{
|
{
|
||||||
@ -316,6 +109,12 @@ const fetchMasterData = async (masterType) => {
|
|||||||
return (await MasterRespository.getContactCategory()).data;
|
return (await MasterRespository.getContactCategory()).data;
|
||||||
case "Contact Tag":
|
case "Contact Tag":
|
||||||
return (await MasterRespository.getContactTag()).data;
|
return (await MasterRespository.getContactTag()).data;
|
||||||
|
case "Expense Type":
|
||||||
|
return (await MasterRespository.getExpenseType()).data;
|
||||||
|
case "Payment Mode":
|
||||||
|
return (await MasterRespository.getPaymentMode()).data;
|
||||||
|
case "Expense Status":
|
||||||
|
return (await MasterRespository.getExpenseStatus()).data;
|
||||||
case "Status":
|
case "Status":
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -16,6 +16,8 @@ const MasterTable = ({ data, columns, loading, handleModalData }) => {
|
|||||||
"tenantId",
|
"tenantId",
|
||||||
"checkLists",
|
"checkLists",
|
||||||
"isSystem",
|
"isSystem",
|
||||||
|
"isActive",
|
||||||
|
"noOfPersonsRequired"
|
||||||
];
|
];
|
||||||
|
|
||||||
const safeData = Array.isArray(data) ? data : [];
|
const safeData = Array.isArray(data) ? data : [];
|
||||||
|
|||||||
@ -56,6 +56,14 @@ export const MasterRespository = {
|
|||||||
createContactTag: (data ) => api.post( `/api/master/contact-tag`, data ),
|
createContactTag: (data ) => api.post( `/api/master/contact-tag`, data ),
|
||||||
updateContactTag: ( id, data ) => api.post( `/api/master/contact-tag/edit/${ id }`, data ),
|
updateContactTag: ( id, data ) => api.post( `/api/master/contact-tag/edit/${ id }`, data ),
|
||||||
|
|
||||||
getAuditStatus:()=>api.get('/api/Master/work-status')
|
getAuditStatus:()=>api.get('/api/Master/work-status'),
|
||||||
|
|
||||||
|
getExpenseType:()=>api.get('/api/Master/expenses-types'),
|
||||||
|
|
||||||
|
|
||||||
|
getPaymentMode:()=>api.get('/api/Master/payment-modes'),
|
||||||
|
|
||||||
|
|
||||||
|
getExpenseStatus:()=>api.get('/api/Master/expenses-status')
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user