From 7e05cfbd6143083d44fc3eefe32a392b984770ff Mon Sep 17 00:00:00 2001 From: "kartik.sharma" Date: Mon, 2 Jun 2025 17:31:07 +0530 Subject: [PATCH] In Employee selection double Date is shown in Front. --- .../employee/AttendancesEmployeeRecords.jsx | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/pages/employee/AttendancesEmployeeRecords.jsx b/src/pages/employee/AttendancesEmployeeRecords.jsx index fd98b044..56c7e085 100644 --- a/src/pages/employee/AttendancesEmployeeRecords.jsx +++ b/src/pages/employee/AttendancesEmployeeRecords.jsx @@ -59,13 +59,28 @@ const AttendancesEmployeeRecords = ({ employee }) => { .sort(sortByName); const group5 = data.filter((d) => d.activity === 5).sort(sortByName); - const sortedFinalList = [ - ...group1, - ...group2, - ...group3, - ...group4, - ...group5, - ]; + // const sortedFinalList = [ + // ...group1, + // ...group2, + // ...group3, + // ...group4, + // ...group5, + // ]; + + const uniqueMap = new Map(); + + [...group1, ...group2, ...group3, ...group4, ...group5].forEach((rec) => { + const date = moment(rec.checkInTime || rec.checkOutTime).format("YYYY-MM-DD"); + const key = `${rec.employeeId}-${date}`; + const existing = uniqueMap.get(key); + if (!existing || new Date(rec.checkInTime || rec.checkOutTime) > new Date(existing.checkInTime || existing.checkOutTime)) { + uniqueMap.set(key, rec); + } + }); + + const sortedFinalList = [...uniqueMap.values()].sort((a, b) => + new Date(b.checkInTime || b.checkOutTime) - new Date(a.checkInTime || a.checkOutTime) + ); const currentDate = new Date().toLocaleDateString("en-CA"); const { currentPage, totalPages, currentItems, paginate } = usePagination( -- 2.43.0