increase page size
This commit is contained in:
parent
a2f23ee5ae
commit
3607bdc77d
@ -1,4 +1,4 @@
|
|||||||
import React, { useState,useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import Avatar from "../common/Avatar";
|
import Avatar from "../common/Avatar";
|
||||||
import { convertShortTime } from "../../utils/dateUtils";
|
import { convertShortTime } from "../../utils/dateUtils";
|
||||||
@ -32,7 +32,7 @@ const Attendance = ({ attendance, getRole, handleModalData }) => {
|
|||||||
|
|
||||||
const { currentPage, totalPages, currentItems, paginate } = usePagination(
|
const { currentPage, totalPages, currentItems, paginate } = usePagination(
|
||||||
filteredData,
|
filteredData,
|
||||||
5
|
10
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -116,7 +116,7 @@ const Attendance = ({ attendance, getRole, handleModalData }) => {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
{!attendance && (
|
{!attendance && (
|
||||||
<span>No employees assigned to the project</span>
|
<span>No employees assigned to the project</span>
|
||||||
)}
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -66,7 +66,7 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
|
|||||||
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(
|
||||||
sortedFinalList,
|
sortedFinalList,
|
||||||
5
|
10
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -86,8 +86,8 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
|
|||||||
const attendanceDate = [
|
const attendanceDate = [
|
||||||
...new Set(sortedFinalList.map((item) => item.checkInTime.split("T")[0])),
|
...new Set(sortedFinalList.map((item) => item.checkInTime.split("T")[0])),
|
||||||
].sort((a, b) => new Date(b) - new Date(a));
|
].sort((a, b) => new Date(b) - new Date(a));
|
||||||
if(attendanceDate != dates){
|
if (attendanceDate != dates) {
|
||||||
setDates(attendanceDate);
|
setDates(attendanceDate);
|
||||||
}
|
}
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
@ -134,11 +134,15 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
|
|||||||
{dates.map((date, i) => {
|
{dates.map((date, i) => {
|
||||||
return (
|
return (
|
||||||
<React.Fragment key={i}>
|
<React.Fragment key={i}>
|
||||||
{currentItems.some(item => item.checkInTime.split("T")[0] === date) && <tr className="table-row-header">
|
{currentItems.some(
|
||||||
<td colSpan={7} className="text-start">
|
(item) => item.checkInTime.split("T")[0] === date
|
||||||
<strong>{date}</strong>
|
) && (
|
||||||
</td>
|
<tr className="table-row-header">
|
||||||
</tr>}
|
<td colSpan={7} className="text-start">
|
||||||
|
<strong>{date}</strong>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
{currentItems
|
{currentItems
|
||||||
?.filter((item) => item.checkInTime.includes(date))
|
?.filter((item) => item.checkInTime.includes(date))
|
||||||
.map((attendance, index) => (
|
.map((attendance, index) => (
|
||||||
|
@ -23,11 +23,11 @@ const Regularization = ({ handleRequest }) => {
|
|||||||
return nameA.localeCompare(nameB);
|
return nameA.localeCompare(nameB);
|
||||||
};
|
};
|
||||||
|
|
||||||
const filteredData = regularizesList.sort(sortByName)
|
const filteredData = regularizesList.sort(sortByName);
|
||||||
|
|
||||||
const { currentPage, totalPages, currentItems, paginate } = usePagination(
|
const { currentPage, totalPages, currentItems, paginate } = usePagination(
|
||||||
filteredData,
|
filteredData,
|
||||||
5
|
10
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -94,50 +94,46 @@ const Regularization = ({ handleRequest }) => {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{!loading && (
|
{!loading && (
|
||||||
<nav aria-label="Page ">
|
<nav aria-label="Page ">
|
||||||
<ul className="pagination pagination-sm justify-content-end py-1">
|
<ul className="pagination pagination-sm justify-content-end py-1">
|
||||||
<li
|
<li className={`page-item ${currentPage === 1 ? "disabled" : ""}`}>
|
||||||
className={`page-item ${
|
<button
|
||||||
currentPage === 1 ? "disabled" : ""
|
className="page-link btn-xs"
|
||||||
}`}
|
onClick={() => paginate(currentPage - 1)}
|
||||||
>
|
>
|
||||||
<button
|
«
|
||||||
className="page-link btn-xs"
|
</button>
|
||||||
onClick={() => paginate(currentPage - 1)}
|
</li>
|
||||||
>
|
{[...Array(totalPages)].map((_, index) => (
|
||||||
«
|
<li
|
||||||
</button>
|
key={index}
|
||||||
</li>
|
className={`page-item ${
|
||||||
{[...Array(totalPages)].map((_, index) => (
|
currentPage === index + 1 ? "active" : ""
|
||||||
<li
|
}`}
|
||||||
key={index}
|
>
|
||||||
className={`page-item ${
|
<button
|
||||||
currentPage === index + 1 ? "active" : ""
|
className="page-link "
|
||||||
}`}
|
onClick={() => paginate(index + 1)}
|
||||||
>
|
>
|
||||||
<button
|
{index + 1}
|
||||||
className="page-link "
|
</button>
|
||||||
onClick={() => paginate(index + 1)}
|
</li>
|
||||||
>
|
))}
|
||||||
{index + 1}
|
<li
|
||||||
</button>
|
className={`page-item ${
|
||||||
</li>
|
currentPage === totalPages ? "disabled" : ""
|
||||||
))}
|
}`}
|
||||||
<li
|
>
|
||||||
className={`page-item ${
|
<button
|
||||||
currentPage === totalPages ? "disabled" : ""
|
className="page-link "
|
||||||
}`}
|
onClick={() => paginate(currentPage + 1)}
|
||||||
>
|
>
|
||||||
<button
|
»
|
||||||
className="page-link "
|
</button>
|
||||||
onClick={() => paginate(currentPage + 1)}
|
</li>
|
||||||
>
|
</ul>
|
||||||
»
|
</nav>
|
||||||
</button>
|
)}
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -70,7 +70,7 @@ const AttendancesEmployeeRecords = ({ employee }) => {
|
|||||||
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(
|
||||||
sortedFinalList,
|
sortedFinalList,
|
||||||
5
|
10
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -84,7 +84,7 @@ const AttendancesEmployeeRecords = ({ employee }) => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, [dateRange, employee,isRefreshing]);
|
}, [dateRange, employee, isRefreshing]);
|
||||||
|
|
||||||
const openModal = (id) => {
|
const openModal = (id) => {
|
||||||
setAttendanecId(id);
|
setAttendanecId(id);
|
||||||
@ -132,20 +132,18 @@ const AttendancesEmployeeRecords = ({ employee }) => {
|
|||||||
<i
|
<i
|
||||||
className={`bx bx-refresh cursor-pointer fs-4 ${
|
className={`bx bx-refresh cursor-pointer fs-4 ${
|
||||||
loading ? "spin" : ""
|
loading ? "spin" : ""
|
||||||
}`}
|
}`}
|
||||||
data-toggle="tooltip"
|
data-toggle="tooltip"
|
||||||
title="Refresh"
|
title="Refresh"
|
||||||
onClick={() => setIsRefreshing(!isRefreshing)}
|
onClick={() => setIsRefreshing(!isRefreshing)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="table-responsive text-nowrap">
|
<div className="table-responsive text-nowrap">
|
||||||
{(!loading && data.length === 0) &&
|
{!loading && data.length === 0 && <span>No employee logs</span>}
|
||||||
<span>No employee logs</span>
|
{error && <div className="text-center">{error}</div>}
|
||||||
}
|
{loading && !data && <div className="text-center">Loading...</div>}
|
||||||
{error && <div className="text-center">{error }</div>}
|
{data && data.length > 0 && (
|
||||||
{(loading && !data ) && <div className="text-center">Loading...</div>}
|
|
||||||
{(data && data.length > 0 ) && (
|
|
||||||
<table className="table mb-0">
|
<table className="table mb-0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -165,7 +163,7 @@ const AttendancesEmployeeRecords = ({ employee }) => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{currentItems?.map( ( attendance, index ) => (
|
{currentItems?.map((attendance, 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">
|
||||||
@ -184,12 +182,12 @@ const AttendancesEmployeeRecords = ({ employee }) => {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{" "}
|
{" "}
|
||||||
{moment( attendance.checkInTime ).format( "DD-MMM-YYYY" )}
|
{moment(attendance.checkInTime).format("DD-MMM-YYYY")}
|
||||||
</td>
|
</td>
|
||||||
<td>{convertShortTime( attendance.checkInTime )}</td>
|
<td>{convertShortTime(attendance.checkInTime)}</td>
|
||||||
<td>
|
<td>
|
||||||
{attendance.checkOutTime
|
{attendance.checkOutTime
|
||||||
? convertShortTime( attendance.checkOutTime )
|
? convertShortTime(attendance.checkOutTime)
|
||||||
: "--"}
|
: "--"}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@ -200,18 +198,18 @@ const AttendancesEmployeeRecords = ({ employee }) => {
|
|||||||
tabIndex="0"
|
tabIndex="0"
|
||||||
aria-controls="DataTables_Table_0"
|
aria-controls="DataTables_Table_0"
|
||||||
data-bs-toggle="modal"
|
data-bs-toggle="modal"
|
||||||
onClick={() => openModal( attendance.id )}
|
onClick={() => openModal(attendance.id)}
|
||||||
>
|
>
|
||||||
View
|
View
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
) )}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
) }
|
)}
|
||||||
</div>
|
</div>
|
||||||
{(!loading && data.length > 5) && (
|
{!loading && data.length > 5 && (
|
||||||
<nav aria-label="Page ">
|
<nav aria-label="Page ">
|
||||||
<ul className="pagination pagination-sm justify-content-end py-1">
|
<ul className="pagination pagination-sm justify-content-end py-1">
|
||||||
<li
|
<li
|
||||||
|
Loading…
x
Reference in New Issue
Block a user