diff --git a/src/components/Activities/AttendcesLogs.jsx b/src/components/Activities/AttendcesLogs.jsx index fd4ba69b..3f520604 100644 --- a/src/components/Activities/AttendcesLogs.jsx +++ b/src/components/Activities/AttendcesLogs.jsx @@ -12,6 +12,7 @@ import { useAttendancesLogs } from "../../hooks/useAttendance"; import { queryClient } from "../../layouts/AuthLayout"; import { ITEMS_PER_PAGE } from "../../utils/constants"; import Pagination from "../common/Pagination"; +import { useNavigate } from "react-router-dom"; const usePagination = (data, itemsPerPage) => { const [currentPage, setCurrentPage] = useState(1); @@ -34,7 +35,7 @@ const usePagination = (data, itemsPerPage) => { }; }; -const AttendanceLog = ({ handleModalData, searchTerm ,organizationId}) => { +const AttendanceLog = ({ handleModalData, searchTerm, organizationId }) => { // const selectedProject = useSelector( // (store) => store.localVariables.projectId // ); @@ -46,6 +47,7 @@ const AttendanceLog = ({ handleModalData, searchTerm ,organizationId}) => { const [isRefreshing, setIsRefreshing] = useState(false); const [processedData, setProcessedData] = useState([]); + const navigate = useNavigate(); const today = new Date(); today.setHours(0, 0, 0, 0); @@ -86,48 +88,48 @@ const AttendanceLog = ({ handleModalData, searchTerm ,organizationId}) => { organizationId ); const filtering = useCallback((dataToFilter) => { - const filteredData = showPending - ? dataToFilter.filter((item) => item.checkOutTime === null) - : dataToFilter; + const filteredData = showPending + ? dataToFilter.filter((item) => item.checkOutTime === null) + : dataToFilter; - const group1 = filteredData - .filter((d) => d.activity === 1 && isSameDay(d.checkInTime)) - .sort(sortByName); - const group2 = filteredData - .filter((d) => d.activity === 4 && isSameDay(d.checkOutTime)) - .sort(sortByName); - const group3 = filteredData - .filter((d) => d.activity === 1 && isBeforeToday(d.checkInTime)) - .sort(sortByName); - const group4 = filteredData.filter( - (d) => d.activity === 4 && isBeforeToday(d.checkOutTime) - ); - const group5 = filteredData - .filter((d) => d.activity === 2 && isBeforeToday(d.checkOutTime)) - .sort(sortByName); - const group6 = filteredData - .filter((d) => d.activity === 5) - .sort(sortByName); + const group1 = filteredData + .filter((d) => d.activity === 1 && isSameDay(d.checkInTime)) + .sort(sortByName); + const group2 = filteredData + .filter((d) => d.activity === 4 && isSameDay(d.checkOutTime)) + .sort(sortByName); + const group3 = filteredData + .filter((d) => d.activity === 1 && isBeforeToday(d.checkInTime)) + .sort(sortByName); + const group4 = filteredData.filter( + (d) => d.activity === 4 && isBeforeToday(d.checkOutTime) + ); + const group5 = filteredData + .filter((d) => d.activity === 2 && isBeforeToday(d.checkOutTime)) + .sort(sortByName); + const group6 = filteredData + .filter((d) => d.activity === 5) + .sort(sortByName); - const sortedList = [...group1, ...group2, ...group3, ...group4, ...group5, ...group6]; + const sortedList = [...group1, ...group2, ...group3, ...group4, ...group5, ...group6]; - // Group by date - const groupedByDate = sortedList.reduce((acc, item) => { - const date = (item.checkInTime || item.checkOutTime)?.split("T")[0]; - if (date) { - acc[date] = acc[date] || []; - acc[date].push(item); - } - return acc; - }, {}); + // Group by date + const groupedByDate = sortedList.reduce((acc, item) => { + const date = (item.checkInTime || item.checkOutTime)?.split("T")[0]; + if (date) { + acc[date] = acc[date] || []; + acc[date].push(item); + } + return acc; + }, {}); - const sortedDates = Object.keys(groupedByDate).sort( - (a, b) => new Date(b) - new Date(a) - ); + const sortedDates = Object.keys(groupedByDate).sort( + (a, b) => new Date(b) - new Date(a) + ); - const finalData = sortedDates.flatMap((date) => groupedByDate[date]); - setProcessedData(finalData); -}, [showPending]); + const finalData = sortedDates.flatMap((date) => groupedByDate[date]); + setProcessedData(finalData); + }, [showPending]); useEffect(() => { @@ -146,31 +148,31 @@ const AttendanceLog = ({ handleModalData, searchTerm ,organizationId}) => { }); }, [processedData, searchTerm]); -// const filteredSearchData = useMemo(() => { -// let tempData = processedData; + // const filteredSearchData = useMemo(() => { + // let tempData = processedData; -// if (searchTerm) { -// const lowercasedSearchTerm = searchTerm.toLowerCase(); -// tempData = tempData.filter((item) => { -// const fullName = `${item.firstName} ${item.lastName}`.toLowerCase(); -// return fullName.includes(lowercasedSearchTerm); -// }); -// } + // if (searchTerm) { + // const lowercasedSearchTerm = searchTerm.toLowerCase(); + // tempData = tempData.filter((item) => { + // const fullName = `${item.firstName} ${item.lastName}`.toLowerCase(); + // return fullName.includes(lowercasedSearchTerm); + // }); + // } -// if (filters?.selectedOrganization) { -// tempData = tempData.filter( -// (item) => item.organization?.name === filters.selectedOrganization -// ); -// } + // if (filters?.selectedOrganization) { + // tempData = tempData.filter( + // (item) => item.organization?.name === filters.selectedOrganization + // ); + // } -// if (filters?.selectedServices?.length > 0) { -// tempData = tempData.filter((item) => -// filters.selectedServices.includes(item.service?.name) -// ); -// } + // if (filters?.selectedServices?.length > 0) { + // tempData = tempData.filter((item) => + // filters.selectedServices.includes(item.service?.name) + // ); + // } -// return tempData; -// }, [processedData, searchTerm, filters]); + // return tempData; + // }, [processedData, searchTerm, filters]); const { @@ -265,7 +267,7 @@ const AttendanceLog = ({ handleModalData, searchTerm ,organizationId}) => { - +
{isLoading ? ( @@ -326,7 +328,12 @@ const AttendanceLog = ({ handleModalData, searchTerm ,organizationId}) => { lastName={attendance.lastName} />
- + + navigate(`/employee/${attendance.employeeId}?for=attendance`) + } + className="text-heading text-truncate cursor-pointer" + > {attendance.firstName} {attendance.lastName} @@ -373,11 +380,11 @@ const AttendanceLog = ({ handleModalData, searchTerm ,organizationId}) => {
)} {filteredSearchData.length > ITEMS_PER_PAGE && ( - + )} ); diff --git a/src/components/Activities/Regularization.jsx b/src/components/Activities/Regularization.jsx index 34c8d1da..24aa831e 100644 --- a/src/components/Activities/Regularization.jsx +++ b/src/components/Activities/Regularization.jsx @@ -10,12 +10,14 @@ import eventBus from "../../services/eventBus"; import { cacheData, clearCacheKey, useSelectedProject } from "../../slices/apiDataManager"; import { useQueryClient } from "@tanstack/react-query"; import Pagination from "../common/Pagination"; +import { useNavigate } from "react-router-dom"; -const Regularization = ({ handleRequest, searchTerm,projectId, organizationId, IncludeInActive }) => { +const Regularization = ({ handleRequest, searchTerm, projectId, organizationId, IncludeInActive }) => { const queryClient = useQueryClient(); // var selectedProject = useSelector((store) => store.localVariables.projectId); const selectedProject = useSelectedProject(); const [regularizesList, setregularizedList] = useState([]); + const navigate = useNavigate(); const { regularizes, loading, error, refetch } = useRegularizationRequests(selectedProject, organizationId, IncludeInActive); @@ -149,7 +151,17 @@ const Regularization = ({ handleRequest, searchTerm,projectId, organizationId, I lastName={att.lastName} />
- + {/* + + {att.firstName} {att.lastName} + + */} + + navigate(`/employee/${att.employeeId}?for=attendance`) + } + className="text-heading text-truncate cursor-pointer" + > {att.firstName} {att.lastName} @@ -191,10 +203,10 @@ const Regularization = ({ handleRequest, searchTerm,projectId, organizationId, I )} {!loading && totalPages > 1 && ( + currentPage={currentPage} + totalPages={totalPages} + onPageChange={paginate} + /> )}
);