From 099a3bcc367dcb236067bb8d3abc29f4d18f4bc2 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Tue, 6 May 2025 22:52:59 +0530 Subject: [PATCH] handled proper loading, pagination only display if record have greather than 5 and added refresh button --- .../employee/AttendancesEmployeeRecords.jsx | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/pages/employee/AttendancesEmployeeRecords.jsx b/src/pages/employee/AttendancesEmployeeRecords.jsx index 077bb386..5d109255 100644 --- a/src/pages/employee/AttendancesEmployeeRecords.jsx +++ b/src/pages/employee/AttendancesEmployeeRecords.jsx @@ -84,7 +84,7 @@ const AttendancesEmployeeRecords = ({ employee }) => { }) ); } - }, [dateRange, employee]); + }, [dateRange, employee,isRefreshing]); const openModal = (id) => { setAttendanecId(id); @@ -132,14 +132,20 @@ const AttendancesEmployeeRecords = ({ employee }) => { setIsRefreshing(!isRefreshing)} />
- {data && data.length > 0 ? ( + {(!loading && data.length === 0) && + No employee logs + } + {error &&
{error }
} + {(loading && !data ) &&
Loading...
} + {(data && data.length > 0 ) && ( @@ -159,15 +165,7 @@ const AttendancesEmployeeRecords = ({ employee }) => { - {loading && } - {error && } - {data && data.length === 0 && ( - - - - )} - - {currentItems?.map((attendance, index) => ( + {currentItems?.map( ( attendance, index ) => ( - + @@ -202,20 +200,18 @@ const AttendancesEmployeeRecords = ({ employee }) => { tabIndex="0" aria-controls="DataTables_Table_0" data-bs-toggle="modal" - onClick={() => openModal(attendance.id)} + onClick={() => openModal( attendance.id )} > View - ))} + ) )}
Loading...{error}
No Data Found
@@ -186,12 +184,12 @@ const AttendancesEmployeeRecords = ({ employee }) => {
{" "} - {moment(attendance.checkInTime).format("DD-MMM-YYYY")} + {moment( attendance.checkInTime ).format( "DD-MMM-YYYY" )} {convertShortTime(attendance.checkInTime)}{convertShortTime( attendance.checkInTime )} {attendance.checkOutTime - ? convertShortTime(attendance.checkOutTime) + ? convertShortTime( attendance.checkOutTime ) : "--"}
- ) : ( - No employee logs - )} + ) }
- {!loading && ( + {(!loading && currentItems < 5) && (