diff --git a/src/components/Activities/Attendance.jsx b/src/components/Activities/Attendance.jsx index bb90bfc5..71b0b966 100644 --- a/src/components/Activities/Attendance.jsx +++ b/src/components/Activities/Attendance.jsx @@ -5,9 +5,15 @@ import { convertShortTime } from "../../utils/dateUtils"; import RenderAttendanceStatus from "./RenderAttendanceStatus"; import usePagination from "../../hooks/usePagination"; import { useNavigate } from "react-router-dom"; -import {ITEMS_PER_PAGE} from "../../utils/constants"; +import { ITEMS_PER_PAGE } from "../../utils/constants"; -const Attendance = ({ attendance, getRole, handleModalData }) => { +const Attendance = ({ + attendance, + getRole, + handleModalData, + setshowOnlyCheckout, + showOnlyCheckout, +}) => { const [loading, setLoading] = useState(false); const navigate = useNavigate(); const [todayDate, setTodayDate] = useState(new Date()); @@ -19,7 +25,7 @@ const Attendance = ({ attendance, getRole, handleModalData }) => { const sortByName = (a, b) => { const nameA = (a.firstName + a.lastName).toLowerCase(); const nameB = (b.firstName + b.lastName).toLowerCase(); - return nameA.localeCompare(nameB); + return nameA?.localeCompare(nameB); }; // Filter employees based on activity @@ -39,41 +45,47 @@ const Attendance = ({ attendance, getRole, handleModalData }) => { return ( <>
+
+ Date : {todayDate.toLocaleDateString("en-GB")} + +
+ setshowOnlyCheckout(e.target.checked)} + /> + +
+
{attendance && attendance.length > 0 && ( <> - - - - - - - - - + + + - - + - + {currentItems && currentItems .sort((a, b) => { // If checkInTime exists, compare it, otherwise, treat null as earlier than a date - const checkInA = a.checkInTime + const checkInA = a?.checkInTime ? new Date(a.checkInTime) : new Date(0); - const checkInB = b.checkInTime + const checkInB = b?.checkInTime ? new Date(b.checkInTime) : new Date(0); return checkInB - checkInA; // Sort in descending order of checkInTime @@ -131,12 +143,13 @@ const Attendance = ({ attendance, getRole, handleModalData }) => {
- Date : {todayDate.toLocaleDateString('en-GB')} -
- Name - Role +
NameRole Check-In + Check-Out ActionsActions
- {!loading>20 && ( + {!loading > 20 && (
@@ -240,6 +242,7 @@ const AttendancePage = () => {