import React, { useEffect, useState } from "react"; import Avatar from "../common/Avatar"; import { convertShortTime } from "../../utils/dateUtils"; import RegularizationActions from "./RegularizationActions"; import { useSelector } from "react-redux"; import { useRegularizationRequests } from "../../hooks/useAttendance"; import moment from "moment"; import usePagination from "../../hooks/usePagination"; const Regularization = ({ handleRequest }) => { var selectedProject = useSelector( ( store ) => store.localVariables.projectId ); const [regularizesList, setregularizedList] = useState([]); const { regularizes, loading, error, refetch } = useRegularizationRequests(selectedProject); useEffect(() => { setregularizedList(regularizes); }, [ regularizes ] ); const sortByName = (a, b) => { const nameA = a.firstName.toLowerCase() + a.lastName.toLowerCase(); const nameB = b.firstName.toLowerCase() + b.lastName.toLowerCase(); return nameA.localeCompare(nameB); }; const filteredData = regularizesList.sort(sortByName) const { currentPage, totalPages, currentItems, paginate } = usePagination( filteredData, 5 ); return (
{loading && } {!loading && (regularizes?.length > 0 ? ( regularizes?.map((att, index) => ( )) ) : ( ))}
Name Date Check-In Check-Out Action
Loading...
{moment(att.checkOutTime).format("DD-MMM-YYYY")} {convertShortTime(att.checkInTime)} {att.checkOutTime ? convertShortTime(att.checkOutTime) : "--"} {/*
*/} {/*
*/}
No Record Found
{!loading && ( )}
); }; export default Regularization;