Attendance Log Page Resets to First Page After Performing Action on Other Pages.
This commit is contained in:
parent
aa550ed030
commit
9afee2934a
@ -177,33 +177,26 @@ const AttendanceLog = ({
|
||||
resetPage, // Destructure resetPage here
|
||||
} = usePagination(processedData, 20);
|
||||
|
||||
// Reset page when processedData changes (due to filters/search)
|
||||
useEffect(() => {
|
||||
resetPage();
|
||||
}, [processedData, resetPage]); // Add resetPage to dependency array
|
||||
const handler = useCallback(
|
||||
(msg) => {
|
||||
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(
|
||||
(msg) => {
|
||||
const { startDate, endDate } = dateRange;
|
||||
const checkIn = msg.response.checkInTime ? msg.response.checkInTime.substring(0, 10) : null;
|
||||
|
||||
if (
|
||||
projectId === msg.projectId &&
|
||||
checkIn &&
|
||||
startDate <= checkIn &&
|
||||
checkIn <= endDate
|
||||
) {
|
||||
dispatch(
|
||||
fetchAttendanceData({
|
||||
projectId,
|
||||
fromDate: startDate,
|
||||
toDate: endDate,
|
||||
})
|
||||
);
|
||||
}
|
||||
},
|
||||
[projectId, dateRange, dispatch]
|
||||
);
|
||||
filtering(updatedAttendance);
|
||||
}
|
||||
},
|
||||
[projectId, dateRange, data, filtering] // ✅ removed resetPage from deps
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
useEffect(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user