Merge branch 'Issues_Aug_1W' of https://git.marcoaiot.com/admin/marco.pms.web into Issues_Aug_1W

This commit is contained in:
Kartik Sharma 2025-08-18 10:23:03 +05:30
commit 7283140a3a

View File

@ -176,7 +176,8 @@ export const useEmployeeProfile = (employeeId) => {
export const useEmployeesName = (projectId, search) => {
return useQuery({
queryKey: ["employees", projectId, search],
queryFn: async() => await EmployeeRepository.getEmployeeName(projectId, search),
queryFn: async () =>
await EmployeeRepository.getEmployeeName(projectId, search),
staleTime: 5 * 60 * 1000, // Optional: cache for 5 minutes
});
@ -194,7 +195,6 @@ export const useEmployeesNameByProject = (projectId) => {
});
};
// Mutation------------------------------------------------------------------
export const useUpdateEmployee = () => {
@ -232,27 +232,58 @@ export const useUpdateEmployee = () => {
});
};
// export const useSuspendEmployee = ({ setIsDeleteModalOpen, setemployeeLodaing }) => {
// const queryClient = useQueryClient();
// const selectedProject = useSelector((store)=>store.localVariables.projectId)
// return useMutation({
// mutationFn: (id) => {
// setemployeeLodaing(true);
// return EmployeeRepository.deleteEmployee(id);
// },
// onSuccess: () => {
// // queryClient.invalidateQueries( ['allEmployee',false]);
// queryClient.invalidateQueries( {queryKey: [ 'projectEmployees' ]} );
// queryClient.invalidateQueries( {queryKey:[ 'employeeListByProject' ,selectedProject]} );
// showToast("Employee deleted successfully.", "success");
// setIsDeleteModalOpen(false);
// },
// onError: (error) => {
// const message =
// error.response?.data?.message ||
// error.message ||
// "An unexpected error occurred";
// showToast(message, "error");
// setIsDeleteModalOpen(false);
// },
// onSettled: () => {
// setemployeeLodaing(false);
// },
// });
// };
// Manage Role
export const useSuspendEmployee = ({
setIsDeleteModalOpen,
setemployeeLodaing,
}) => {
const queryClient = useQueryClient();
const selectedProject = useSelector(
const selectedProjectId = useSelector(
(store) => store.localVariables.projectId
);
return useMutation({
mutationFn: async (employeeId) => {
setemployeeLodaing(true);
return await EmployeeRepository.deleteEmployee(employeeId);
},
onSuccess: () => {
// queryClient.invalidateQueries( ['allEmployee',false]);
queryClient.invalidateQueries({ queryKey: ["projectEmployees"] });
queryClient.invalidateQueries({
queryKey: ["employeeListByProject", selectedProject],
});
showToast("Employee deleted successfully.", "success");
onSuccess: (_, employeeId) => {
showToast("Employee suspended successfully.", "success");
setIsDeleteModalOpen(false);
// Invalidate only the required employee-related queries
@ -278,8 +309,6 @@ export const useSuspendEmployee = ({
});
};
// Manage Role
export const useUpdateEmployeeRoles = ({
onClose,
resetForm,