Attendance Log Page Resets to First Page After Performing Action on Other Pages.
This commit is contained in:
parent
aa43dd4540
commit
276a2ca9f4
@ -147,34 +147,26 @@ const AttendanceLog = ({
|
|||||||
resetPage,
|
resetPage,
|
||||||
} = usePagination(processedData, 20);
|
} = usePagination(processedData, 20);
|
||||||
|
|
||||||
useEffect(() => {
|
const handler = useCallback(
|
||||||
resetPage();
|
(msg) => {
|
||||||
}, [processedData, resetPage]);
|
const { startDate, endDate } = dateRange;
|
||||||
|
const checkIn = msg.response.checkInTime.substring(0, 10);
|
||||||
|
if (
|
||||||
|
projectId === msg.projectId &&
|
||||||
|
startDate <= checkIn &&
|
||||||
|
checkIn <= endDate
|
||||||
|
) {
|
||||||
|
const updatedAttendance = data.map((item) =>
|
||||||
|
item.id === msg.response.id
|
||||||
|
? { ...item, ...msg.response }
|
||||||
|
: item
|
||||||
|
);
|
||||||
|
|
||||||
const handler = useCallback(
|
filtering(updatedAttendance);
|
||||||
(msg) => {
|
}
|
||||||
const { startDate, endDate } = dateRange;
|
},
|
||||||
const checkIn = msg.response.checkInTime.substring(0, 10);
|
[projectId, dateRange, data, filtering] // ✅ removed resetPage from deps
|
||||||
if (
|
);
|
||||||
selectedProject === msg.projectId &&
|
|
||||||
startDate <= checkIn &&
|
|
||||||
checkIn <= endDate
|
|
||||||
) {
|
|
||||||
queryClient.setQueriesData(["attendanceLogs"],(oldData)=>{
|
|
||||||
if(!oldData) {
|
|
||||||
queryClient.invalidateQueries({queryKey:["attendanceLogs"]})
|
|
||||||
}
|
|
||||||
return oldData.map((record) =>
|
|
||||||
record.id === msg.response.id ? { ...record, ...msg.response } : record
|
|
||||||
);
|
|
||||||
})
|
|
||||||
|
|
||||||
filtering(updatedAttendance);
|
|
||||||
resetPage();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[selectedProject, dateRange, data, filtering, resetPage]
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
eventBus.on("attendance_log", handler);
|
eventBus.on("attendance_log", handler);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user