Attendance page search functionality and Attendance Log Page Resets to First Page After Performing Action on Other Pages.
This commit is contained in:
parent
30b567d020
commit
1f3438e3a9
@ -4,7 +4,7 @@ import Avatar from "../common/Avatar";
|
|||||||
import { convertShortTime } from "../../utils/dateUtils";
|
import { convertShortTime } from "../../utils/dateUtils";
|
||||||
import RenderAttendanceStatus from "./RenderAttendanceStatus";
|
import RenderAttendanceStatus from "./RenderAttendanceStatus";
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { fetchAttendanceData, setAttendanceData } from "../../slices/apiSlice/attedanceLogsSlice"; // Corrected typo: atttendanceLogsSlice to attedanceLogsSlice
|
import { fetchAttendanceData, setAttendanceData } from "../../slices/apiSlice/attedanceLogsSlice";
|
||||||
import DateRangePicker from "../common/DateRangePicker";
|
import DateRangePicker from "../common/DateRangePicker";
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ const usePagination = (data, itemsPerPage) => {
|
|||||||
totalPages: maxPage,
|
totalPages: maxPage,
|
||||||
currentItems,
|
currentItems,
|
||||||
paginate,
|
paginate,
|
||||||
resetPage, // Ensure resetPage is returned here
|
resetPage,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -182,10 +182,10 @@ const AttendanceLog = ({
|
|||||||
resetPage, // Destructure resetPage here
|
resetPage, // Destructure resetPage here
|
||||||
} = usePagination(processedData, 20);
|
} = usePagination(processedData, 20);
|
||||||
|
|
||||||
// Effect to reset pagination when search query or showOnlyCheckout changes
|
// Effect to reset pagination when search query changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
resetPage();
|
resetPage();
|
||||||
}, [searchQuery, showOnlyCheckout, resetPage]); // Add resetPage to dependencies
|
}, [searchQuery, resetPage]); // Add resetPage to dependencies
|
||||||
|
|
||||||
const handler = useCallback(
|
const handler = useCallback(
|
||||||
(msg) => {
|
(msg) => {
|
||||||
@ -196,8 +196,7 @@ const AttendanceLog = ({
|
|||||||
startDate <= checkIn &&
|
startDate <= checkIn &&
|
||||||
checkIn <= endDate
|
checkIn <= endDate
|
||||||
) {
|
) {
|
||||||
// Create a new array to avoid direct mutation of Redux state data
|
const updatedAttendance = data.map((item) =>
|
||||||
const updatedAttendance = attendanceLogsData.map((item) => // Use attendanceLogsData
|
|
||||||
item.id === msg.response.id
|
item.id === msg.response.id
|
||||||
? { ...item, ...msg.response }
|
? { ...item, ...msg.response }
|
||||||
: item
|
: item
|
||||||
@ -205,7 +204,7 @@ const AttendanceLog = ({
|
|||||||
dispatch(setAttendanceData(updatedAttendance)); // Update Redux store
|
dispatch(setAttendanceData(updatedAttendance)); // Update Redux store
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[projectId, dateRange, attendanceLogsData, dispatch] // Added attendanceLogsData to dependencies
|
[projectId, dateRange, data, dispatch]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user