Optimized to avoid unnecessary API calls
This commit is contained in:
parent
8676ff24a5
commit
10ee3796d3
@ -28,6 +28,7 @@ const { mutate: updateEmployee, isPending } = useUpdateEmployee();
|
||||
employee,
|
||||
error,
|
||||
loading: empLoading,
|
||||
refetch
|
||||
} = useEmployeeProfile(employeeId);
|
||||
|
||||
useEffect(() => {
|
||||
@ -129,7 +130,12 @@ const { mutate: updateEmployee, isPending } = useUpdateEmployee();
|
||||
.min(1, { message: "Phone Number is required" })
|
||||
.regex(mobileNumberRegex, { message: "Invalid phone number " }),
|
||||
jobRoleId: z.string().min(1, { message: "Role is required" }),
|
||||
});
|
||||
} );
|
||||
|
||||
useEffect( () =>
|
||||
{
|
||||
refetch()
|
||||
},[])
|
||||
|
||||
const {
|
||||
register,
|
||||
|
@ -403,7 +403,7 @@ export const useCreateJobRole = (onSuccessCallback) => {
|
||||
onSuccess: (data) => {
|
||||
showToast("JobRole added successfully.", "success");
|
||||
|
||||
queryClient.invalidateQueries(["masterData", "Job Role"]);
|
||||
queryClient.invalidateQueries({queryKey:["masterData", "Job Role"]});
|
||||
|
||||
if (onSuccessCallback) onSuccessCallback(data);
|
||||
},
|
||||
@ -427,7 +427,7 @@ export const useCreateApplicationRole = (onSuccessCallback) =>
|
||||
},
|
||||
onSuccess: ( data ) =>
|
||||
{
|
||||
queryClient.invalidateQueries( [ "masterData", "Application Role" ] )
|
||||
queryClient.invalidateQueries( {queryKey:[ "masterData", "Application Role" ]} )
|
||||
showToast( "Application Role added successfully", "success" );
|
||||
if(onSuccessCallback) onSuccessCallback(data)
|
||||
},
|
||||
@ -476,7 +476,7 @@ export const useCreateActivity = (onSuccessCallback) =>
|
||||
},
|
||||
onSuccess: ( data ) =>
|
||||
{
|
||||
queryClient.invalidateQueries( [ "masterData", "Activity" ] )
|
||||
queryClient.invalidateQueries( {queryKey:[ "masterData", "Activity" ]} )
|
||||
showToast( "Activity added successfully", "success" );
|
||||
if(onSuccessCallback) onSuccessCallback(data)
|
||||
},
|
||||
@ -526,7 +526,7 @@ export const useCreateWorkCategory = (onSuccessCallback) =>
|
||||
},
|
||||
onSuccess: ( data ) =>
|
||||
{
|
||||
queryClient.invalidateQueries( [ "masterData", "Work Category" ] )
|
||||
queryClient.invalidateQueries({queryKey: [ "masterData", "Work Category" ]} )
|
||||
showToast( "Work Category added successfully", "success" );
|
||||
if(onSuccessCallback) onSuccessCallback(data)
|
||||
},
|
||||
@ -577,7 +577,7 @@ export const useCreateContactCategory = (onSuccessCallback) =>
|
||||
},
|
||||
onSuccess: ( data ) =>
|
||||
{
|
||||
queryClient.invalidateQueries( [ "masterData", "Contact Category" ] )
|
||||
queryClient.invalidateQueries( {queryKey:[ "masterData", "Contact Category" ]} )
|
||||
showToast( "Contact Category added successfully", "success" );
|
||||
if(onSuccessCallback) onSuccessCallback(data)
|
||||
},
|
||||
@ -628,7 +628,7 @@ export const useCreateContactTag = (onSuccessCallback) =>
|
||||
},
|
||||
onSuccess: ( data ) =>
|
||||
{
|
||||
queryClient.invalidateQueries( [ "masterData", "Contact Tag" ] )
|
||||
queryClient.invalidateQueries( {queryKey:[ "masterData", "Contact Tag" ]} )
|
||||
showToast( "Contact Tag added successfully", "success" );
|
||||
if(onSuccessCallback) onSuccessCallback(data)
|
||||
},
|
||||
|
@ -156,6 +156,7 @@ export const useEmployeeProfile = ( employeeId ) =>
|
||||
data = null,
|
||||
isLoading: loading,
|
||||
error,
|
||||
refetch
|
||||
} = useQuery({
|
||||
queryKey: ['employeeProfile', employeeId],
|
||||
queryFn: async () => {
|
||||
@ -170,6 +171,7 @@ export const useEmployeeProfile = ( employeeId ) =>
|
||||
employee: data,
|
||||
loading,
|
||||
error,
|
||||
refetch
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user