In Employee selection double Date is shown in Front. #173
@ -59,13 +59,28 @@ const AttendancesEmployeeRecords = ({ employee }) => {
|
|||||||
.sort(sortByName);
|
.sort(sortByName);
|
||||||
const group5 = data.filter((d) => d.activity === 5).sort(sortByName);
|
const group5 = data.filter((d) => d.activity === 5).sort(sortByName);
|
||||||
|
|
||||||
const sortedFinalList = [
|
// const sortedFinalList = [
|
||||||
...group1,
|
// ...group1,
|
||||||
...group2,
|
// ...group2,
|
||||||
...group3,
|
// ...group3,
|
||||||
...group4,
|
// ...group4,
|
||||||
...group5,
|
// ...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 currentDate = new Date().toLocaleDateString("en-CA");
|
||||||
const { currentPage, totalPages, currentItems, paginate } = usePagination(
|
const { currentPage, totalPages, currentItems, paginate } = usePagination(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user