UI updation in Attendance Toady's and Regularization tab.

This commit is contained in:
Kartik Sharma 2025-10-14 15:44:36 +05:30
parent 765b4356a6
commit a9d1ba08dd
2 changed files with 242 additions and 238 deletions

View File

@ -110,144 +110,146 @@ const Attendance = ({ getRole, handleModalData, searchTerm, projectId, organizat
}, [employeeHandler]); }, [employeeHandler]);
return ( return (
<> <>
<div <div>
className="table-responsive text-nowrap h-100" <div
style={{ minHeight: "200px" }} // Ensures fixed height className="table-responsive text-nowrap h-100"
> style={{ minHeight: "200px" }} // Ensures fixed height
<div className="d-flex text-start align-items-center py-2"> >
<strong>Date : {formatUTCToLocalTime(todayDate)}</strong> <div className="d-flex text-start align-items-center py-2">
<div className="form-check form-switch text-start m-0 ms-5"> <strong>Date : {formatUTCToLocalTime(todayDate)}</strong>
<input <div className="form-check form-switch text-start m-0 ms-5">
type="checkbox" <input
className="form-check-input" type="checkbox"
role="switch" className="form-check-input"
id="inactiveEmployeesCheckbox" role="switch"
disabled={isFetching} id="inactiveEmployeesCheckbox"
checked={ShowPending} disabled={isFetching}
onChange={(e) => setShowPending(e.target.checked)} checked={ShowPending}
/> onChange={(e) => setShowPending(e.target.checked)}
<label className="form-check-label ms-0">Show Pending</label>
</div>
</div>
{attLoading ? (
<div>Loading...</div>
) : currentItems?.length > 0 ? (
<>
<table className="table ">
<thead>
<tr className="border-top-1">
<th colSpan={2}>Name</th>
<th>Role</th>
{/* <th>Organization</th> */}
<th>
<i className="bx bxs-down-arrow-alt text-success"></i>
Check-In
</th>
<th>
<i className="bx bxs-up-arrow-alt text-danger"></i>Check-Out
</th>
<th>Actions</th>
</tr>
</thead>
<tbody className="table-border-bottom-0 ">
{currentItems &&
currentItems
.sort((a, b) => {
const checkInA = a?.checkInTime
? new Date(a.checkInTime)
: new Date(0);
const checkInB = b?.checkInTime
? new Date(b.checkInTime)
: new Date(0);
return checkInB - checkInA;
})
.map((item) => (
<tr key={item.employeeId}>
<td colSpan={2}>
<div className="d-flex justify-content-start align-items-center">
<Avatar
firstName={item.firstName}
lastName={item.lastName}
></Avatar>
<div className="d-flex flex-column">
<a
onClick={(e) =>
navigate(
`/employee/${item.employeeId}?for=attendance`
)
}
className="text-heading text-truncate cursor-pointer"
>
<span className="fw-normal">
{item.firstName} {item.lastName}
</span>
</a>
</div>
</div>
</td>
<td>{item.jobRoleName}</td>
{/* <td>{item.organizationName || "--"}</td> */}
<td>
{item.checkInTime
? convertShortTime(item.checkInTime)
: "--"}
</td>
<td>
{item.checkOutTime
? convertShortTime(item.checkOutTime)
: "--"}
</td>
<td className="text-center">
<RenderAttendanceStatus
attendanceData={item}
handleModalData={handleModalData}
Tab={1}
currentDate={null}
/>
</td>
</tr>
))}
{!attendance && (
<tr>
<td
colSpan={7}
className="text-center text-secondary"
style={{ height: "200px" }}
>
No employees assigned to the project!
</td>
</tr>
)}
</tbody>
</table>
{!loading && finalFilteredData.length > ITEMS_PER_PAGE && (
<Pagination
currentPage={currentPage}
totalPages={totalPages}
onPageChange={paginate}
/> />
)} <label className="form-check-label ms-0">Show Pending</label>
</> </div>
) : (
<div
className="d-flex justify-content-center align-items-center text-muted"
style={{ height: "200px" }}
>
{searchTerm
? "No results found for your search."
: attendanceList.length === 0
? "No employees assigned to the project."
: "No pending records available."}
</div> </div>
{attLoading ? (
<div>Loading...</div>
) : currentItems?.length > 0 ? (
<>
<table className="table ">
<thead>
<tr className="border-top-1">
<th colSpan={2}>Name</th>
<th>Role</th>
{/* <th>Organization</th> */}
<th>
<i className="bx bxs-down-arrow-alt text-success"></i>
Check-In
</th>
<th>
<i className="bx bxs-up-arrow-alt text-danger"></i>Check-Out
</th>
<th>Actions</th>
</tr>
</thead>
<tbody className="table-border-bottom-0 ">
{currentItems &&
currentItems
.sort((a, b) => {
const checkInA = a?.checkInTime
? new Date(a.checkInTime)
: new Date(0);
const checkInB = b?.checkInTime
? new Date(b.checkInTime)
: new Date(0);
return checkInB - checkInA;
})
.map((item) => (
<tr key={item.employeeId}>
<td colSpan={2}>
<div className="d-flex justify-content-start align-items-center">
<Avatar
firstName={item.firstName}
lastName={item.lastName}
></Avatar>
<div className="d-flex flex-column">
<a
onClick={(e) =>
navigate(
`/employee/${item.employeeId}?for=attendance`
)
}
className="text-heading text-truncate cursor-pointer"
>
<span className="fw-normal">
{item.firstName} {item.lastName}
</span>
</a>
</div>
</div>
</td>
<td>{item.jobRoleName}</td>
{/* <td>{item.organizationName || "--"}</td> */}
<td>
{item.checkInTime
? convertShortTime(item.checkInTime)
: "--"}
</td>
<td>
{item.checkOutTime
? convertShortTime(item.checkOutTime)
: "--"}
</td>
<td className="text-center">
<RenderAttendanceStatus
attendanceData={item}
handleModalData={handleModalData}
Tab={1}
currentDate={null}
/>
</td>
</tr>
))}
{!attendance && (
<tr>
<td
colSpan={7}
className="text-center text-secondary"
style={{ height: "200px" }}
>
No employees assigned to the project!
</td>
</tr>
)}
</tbody>
</table>
</>
) : (
<div
className="d-flex justify-content-center align-items-center text-muted"
style={{ height: "200px" }}
>
{searchTerm
? "No results found for your search."
: attendanceList.length === 0
? "No employees assigned to the project."
: "No pending records available."}
</div>
)}
</div>
{!loading && finalFilteredData.length > ITEMS_PER_PAGE && (
<Pagination
currentPage={currentPage}
totalPages={totalPages}
onPageChange={paginate}
/>
)} )}
</div> </div>
</> </>

View File

@ -22,18 +22,18 @@ const Regularization = ({ handleRequest, searchTerm, projectId, organizationId,
const { regularizes, loading, error, refetch } = const { regularizes, loading, error, refetch } =
useRegularizationRequests(selectedProject, organizationId, IncludeInActive); useRegularizationRequests(selectedProject, organizationId, IncludeInActive);
useEffect(() => { useEffect(() => {
if (regularizes && regularizes.length) { if (regularizes && regularizes.length) {
setregularizedList((prev) => { setregularizedList((prev) => {
const prevIds = prev.map((i) => i.id).join(","); const prevIds = prev.map((i) => i.id).join(",");
const newIds = regularizes.map((i) => i.id).join(","); const newIds = regularizes.map((i) => i.id).join(",");
if (prevIds !== newIds) { if (prevIds !== newIds) {
return regularizes; return regularizes;
} }
return prev; return prev;
}); });
} }
}, [regularizes]); }, [regularizes]);
const sortByName = (a, b) => { const sortByName = (a, b) => {
@ -132,108 +132,110 @@ useEffect(() => {
return ( return (
<div className="table-responsive text-nowrap pb-4" style={{ minHeight: "200px" }}> <div>
{loading ? ( <div className="table-responsive text-nowrap pb-4" style={{ minHeight: "200px" }}>
<div className="d-flex justify-content-center align-items-center" style={{ height: "200px" }}> {loading ? (
<p className="text-secondary">Loading...</p> <div className="d-flex justify-content-center align-items-center" style={{ height: "200px" }}>
</div> <p className="text-secondary">Loading...</p>
) : currentItems?.length > 0 ? ( </div>
<table className="table mb-0"> ) : currentItems?.length > 0 ? (
<thead> <table className="table mb-0">
<tr> <thead>
<th colSpan={2}>Name</th> <tr>
<th>Date</th> <th colSpan={2}>Name</th>
{/* <th>Organization</th> */} <th>Date</th>
<th> {/* <th>Organization</th> */}
<i className="bx bxs-down-arrow-alt text-success"></i>Check-In <th>
</th> <i className="bx bxs-down-arrow-alt text-success"></i>Check-In
<th> </th>
<i className="bx bxs-up-arrow-alt text-danger"></i>Check-Out <th>
</th> <i className="bx bxs-up-arrow-alt text-danger"></i>Check-Out
</th>
<th>Request By</th> <th>Request By</th>
<th>Requested At</th> <th>Requested At</th>
<th>Action</th> <th>Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{currentItems?.map((att, index) => ( {currentItems?.map((att, index) => (
<tr key={index}> <tr key={index}>
<td colSpan={2}> <td colSpan={2}>
<div className="d-flex justify-content-start align-items-center"> <div className="d-flex justify-content-start align-items-center">
<Avatar <Avatar
firstName={att.firstName} firstName={att.firstName}
lastName={att.lastName} lastName={att.lastName}
/> />
<div className="d-flex flex-column"> <div className="d-flex flex-column">
{/* <a href="#" className="text-heading text-truncate"> {/* <a href="#" className="text-heading text-truncate">
<span className="fw-normal"> <span className="fw-normal">
{att.firstName} {att.lastName} {att.firstName} {att.lastName}
</span> </span>
</a> */} </a> */}
<a <a
onClick={() => onClick={() =>
navigate(`/employee/${att.employeeId}?for=attendance`) navigate(`/employee/${att.employeeId}?for=attendance`)
} }
className="text-heading text-truncate cursor-pointer" className="text-heading text-truncate cursor-pointer"
> >
<span className="fw-normal"> <span className="fw-normal">
{att.firstName} {att.lastName} {att.firstName} {att.lastName}
</span> </span>
</a> </a>
</div>
</div> </div>
</div> </td>
</td>
<td>{moment(att.checkOutTime).format("DD-MMM-YYYY")}</td> <td>{moment(att.checkOutTime).format("DD-MMM-YYYY")}</td>
{/* <td>{att.organizationName || "--"}</td> */} {/* <td>{att.organizationName || "--"}</td> */}
<td>{convertShortTime(att.checkInTime)}</td> <td>{convertShortTime(att.checkInTime)}</td>
<td> <td>
{att.checkOutTime ? convertShortTime(att.checkOutTime) : "--"} {att.checkOutTime ? convertShortTime(att.checkOutTime) : "--"}
</td> </td>
<td> <td>
{att.requestedBy {att.requestedBy
? `${att.requestedBy?.firstName} ${att.requestedBy?.lastName}` ? `${att.requestedBy?.firstName} ${att.requestedBy?.lastName}`
: "--"} : "--"}
</td> </td>
<td> <td>
{att.requestedAt {att.requestedAt
? moment(att.requestedAt).format("DD-MMM-YYYY") ? moment(att.requestedAt).format("DD-MMM-YYYY")
: "--"} : "--"}
</td> </td>
<td className="text-center "> <td className="text-center ">
<RegularizationActions <RegularizationActions
attendanceData={att} attendanceData={att}
handleRequest={handleRequest} handleRequest={handleRequest}
refresh={refetch} refresh={refetch}
/> />
</td> </td>
</tr> </tr>
))} ))}
</tbody> </tbody>
</table> </table>
) : ( ) : (
<div <div
className="d-flex justify-content-center align-items-center" className="d-flex justify-content-center align-items-center"
style={{ height: "200px" }} style={{ height: "200px" }}
> >
<span className="text-secondary"> <span className="text-secondary">
{searchTerm {searchTerm
? "No results found for your search." ? "No results found for your search."
: "No Requests Found !"} : "No Requests Found !"}
</span> </span>
</div> </div>
)} )}
{!loading && totalPages > 1 && ( </div>
<Pagination {!loading && totalPages > 1 && (
currentPage={currentPage} <Pagination
totalPages={totalPages} currentPage={currentPage}
onPageChange={paginate} totalPages={totalPages}
/> onPageChange={paginate}
)} />
)}
</div> </div>
); );
}; };