handled loading properly

This commit is contained in:
Pramod Mahajan 2025-05-06 23:12:08 +05:30
parent 7ef148ac32
commit 9802746267

View File

@ -65,7 +65,8 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
})
);
}
}, [dateRange, projectId, isRefreshing]);
}, [ dateRange, projectId, isRefreshing ] );
return (
<>
@ -82,12 +83,13 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
loading ? "spin":""
}`}
title="Refresh"
onClick={()=>setIsRefreshing(!isRefreshing)}
onClick={() => setIsRefreshing( !isRefreshing )}
/>
</div>
</div>
<div className="table-responsive text-nowrap">
{data && data.length > 0 ? (
{(data && data.length > 0 ) && (
<table className="table mb-0">
<thead>
<tr>
@ -107,14 +109,7 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
</thead>
<tbody>
{loading && <td colSpan={5}>Loading...</td>}
{error && <td colSpan={5}>{error}</td>}
{data && data.length === 0 && (
<tr>
<td colSpan={5}>No Data Found</td>
</tr>
)}
{currentItems?.map((attendance, index) => (
{currentItems?.map( ( attendance, index ) => (
<tr key={index}>
<td colSpan={2}>
<div className="d-flex justify-content-start align-items-center">
@ -133,12 +128,12 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
</td>
<td>
{" "}
{moment(attendance.checkInTime).format("DD-MMM-YYYY")}
{moment( attendance.checkInTime ).format( "DD-MMM-YYYY" )}
</td>
<td>{convertShortTime(attendance.checkInTime)}</td>
<td>{convertShortTime( attendance.checkInTime )}</td>
<td>
{attendance.checkOutTime
? convertShortTime(attendance.checkOutTime)
? convertShortTime( attendance.checkOutTime )
: "--"}
</td>
<td className="text-center">
@ -150,12 +145,14 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
/>
</td>
</tr>
))}
) )}
</tbody>
</table>
) : (
) }
{(!loading && data.length === 0) &&
<span>No employee logs</span>
)}
}
{error && <td colSpan={5}>{error}</td>}
</div>
{!loading && (
<nav aria-label="Page ">
@ -201,7 +198,7 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
</li>
</ul>
</nav>
)}
)}
</>
);
};