Enhancement implemented in the Attendance component to include search functionality.
This commit is contained in:
parent
820f80562f
commit
e96187cfa1
@ -6,28 +6,36 @@ import RenderAttendanceStatus from "./RenderAttendanceStatus";
|
|||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { fetchAttendanceData } from "../../slices/apiSlice/attedanceLogsSlice";
|
import { fetchAttendanceData } from "../../slices/apiSlice/attedanceLogsSlice";
|
||||||
import DateRangePicker from "../common/DateRangePicker";
|
import DateRangePicker from "../common/DateRangePicker";
|
||||||
import { clearCacheKey, getCachedData } from "../../slices/apiDataManager";
|
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
import AttendanceRepository from "../../repositories/AttendanceRepository";
|
|
||||||
|
|
||||||
const usePagination = (data, itemsPerPage) => {
|
const usePagination = (data, itemsPerPage) => {
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
const maxPage = Math.ceil(data.length / itemsPerPage);
|
const totalItems = Array.isArray(data) ? data.length : 0;
|
||||||
|
const maxPage = Math.ceil(totalItems / itemsPerPage);
|
||||||
|
|
||||||
const currentItems = useMemo(() => {
|
const currentItems = useMemo(() => {
|
||||||
|
if (!Array.isArray(data) || data.length === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
const startIndex = (currentPage - 1) * itemsPerPage;
|
const startIndex = (currentPage - 1) * itemsPerPage;
|
||||||
const endIndex = startIndex + itemsPerPage;
|
const endIndex = startIndex + itemsPerPage;
|
||||||
return data.slice(startIndex, endIndex);
|
return data.slice(startIndex, endIndex);
|
||||||
}, [data, currentPage, itemsPerPage]);
|
}, [data, currentPage, itemsPerPage]);
|
||||||
|
|
||||||
const paginate = useCallback((pageNumber) => setCurrentPage(pageNumber), []);
|
const paginate = useCallback((pageNumber) => {
|
||||||
const resetPage = useCallback(() => setCurrentPage(1), []);
|
if (pageNumber > 0 && pageNumber <= maxPage) {
|
||||||
|
setCurrentPage(pageNumber);
|
||||||
|
}
|
||||||
|
}, [maxPage]);
|
||||||
|
|
||||||
|
const resetPage = useCallback(() => setCurrentPage(1), []); // This is returned by the hook
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentPage,
|
currentPage,
|
||||||
totalPages: maxPage,
|
totalPages: maxPage,
|
||||||
currentItems,
|
currentItems,
|
||||||
paginate,
|
paginate,
|
||||||
resetPage,
|
resetPage, // Ensure resetPage is returned here
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,38 +44,44 @@ const AttendanceLog = ({
|
|||||||
projectId,
|
projectId,
|
||||||
setshowOnlyCheckout,
|
setshowOnlyCheckout,
|
||||||
showOnlyCheckout,
|
showOnlyCheckout,
|
||||||
|
searchQuery, // Prop for search query
|
||||||
}) => {
|
}) => {
|
||||||
const [dateRange, setDateRange] = useState({ startDate: "", endDate: "" });
|
const [dateRange, setDateRange] = useState({ startDate: "", endDate: "" });
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { data, loading, error } = useSelector((store) => store.attendanceLogs);
|
const { data, loading, error } = useSelector((store) => store.attendanceLogs);
|
||||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||||
const [processedData, setProcessedData] = useState([]);
|
|
||||||
|
|
||||||
const today = new Date();
|
const today = useMemo(() => {
|
||||||
today.setHours(0, 0, 0, 0);
|
const d = new Date();
|
||||||
|
d.setHours(0, 0, 0, 0);
|
||||||
|
return d;
|
||||||
|
}, []);
|
||||||
|
|
||||||
const yesterday = new Date();
|
const yesterday = useMemo(() => {
|
||||||
yesterday.setDate(yesterday.getDate() - 1);
|
const d = new Date();
|
||||||
|
d.setDate(d.getDate() - 1);
|
||||||
|
return d;
|
||||||
|
}, []);
|
||||||
|
|
||||||
const isSameDay = (dateStr) => {
|
const isSameDay = useCallback((dateStr) => {
|
||||||
if (!dateStr) return false;
|
if (!dateStr) return false;
|
||||||
const d = new Date(dateStr);
|
const d = new Date(dateStr);
|
||||||
d.setHours(0, 0, 0, 0);
|
d.setHours(0, 0, 0, 0);
|
||||||
return d.getTime() === today.getTime();
|
return d.getTime() === today.getTime();
|
||||||
};
|
}, [today]);
|
||||||
|
|
||||||
const isBeforeToday = (dateStr) => {
|
const isBeforeToday = useCallback((dateStr) => {
|
||||||
if (!dateStr) return false;
|
if (!dateStr) return false;
|
||||||
const d = new Date(dateStr);
|
const d = new Date(dateStr);
|
||||||
d.setHours(0, 0, 0, 0);
|
d.setHours(0, 0, 0, 0);
|
||||||
return d.getTime() < today.getTime();
|
return d.getTime() < today.getTime();
|
||||||
};
|
}, [today]);
|
||||||
|
|
||||||
const sortByName = (a, b) => {
|
const sortByName = useCallback((a, b) => {
|
||||||
const nameA = a.firstName.toLowerCase() + a.lastName.toLowerCase();
|
const nameA = `${a.firstName || ""} ${a.lastName || ""}`.toLowerCase();
|
||||||
const nameB = b.firstName.toLowerCase() + b.lastName.toLowerCase();
|
const nameB = `${b.firstName || ""} ${b.lastName || ""}`.toLowerCase();
|
||||||
return nameA?.localeCompare(nameB);
|
return nameA.localeCompare(nameB);
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const { startDate, endDate } = dateRange;
|
const { startDate, endDate } = dateRange;
|
||||||
@ -81,11 +95,29 @@ const AttendanceLog = ({
|
|||||||
setIsRefreshing(false);
|
setIsRefreshing(false);
|
||||||
}, [dateRange, projectId, dispatch, isRefreshing]);
|
}, [dateRange, projectId, dispatch, isRefreshing]);
|
||||||
|
|
||||||
const filtering = (data) => {
|
const processedData = useMemo(() => {
|
||||||
const filteredData = showOnlyCheckout
|
let filteredData = showOnlyCheckout
|
||||||
? data.filter((item) => item.checkOutTime === null)
|
? data.filter((item) => item.checkOutTime === null)
|
||||||
: data;
|
: data;
|
||||||
|
|
||||||
|
// Apply search query filter
|
||||||
|
if (searchQuery) {
|
||||||
|
const lowerCaseSearchQuery = searchQuery.toLowerCase();
|
||||||
|
filteredData = filteredData.filter((att) => {
|
||||||
|
// Construct a full name from available parts, filtering out null/undefined
|
||||||
|
const fullName = [att.firstName, att.middleName, att.lastName]
|
||||||
|
.filter(Boolean) // This removes null, undefined, or empty string parts
|
||||||
|
.join(" ")
|
||||||
|
.toLowerCase();
|
||||||
|
|
||||||
|
return (
|
||||||
|
att.employeeName?.toLowerCase().includes(lowerCaseSearchQuery) ||
|
||||||
|
att.employeeId?.toLowerCase().includes(lowerCaseSearchQuery) ||
|
||||||
|
fullName.includes(lowerCaseSearchQuery)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const group1 = filteredData
|
const group1 = filteredData
|
||||||
.filter((d) => d.activity === 1 && isSameDay(d.checkInTime))
|
.filter((d) => d.activity === 1 && isSameDay(d.checkInTime))
|
||||||
.sort(sortByName);
|
.sort(sortByName);
|
||||||
@ -130,71 +162,65 @@ const AttendanceLog = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Create the final sorted array
|
// Create the final sorted array
|
||||||
const finalData = sortedDates.flatMap((date) => groupedByDate[date]);
|
return sortedDates.flatMap((date) => groupedByDate[date]);
|
||||||
setProcessedData(finalData);
|
}, [data, showOnlyCheckout, searchQuery, isSameDay, isBeforeToday, sortByName]);
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
filtering(data)
|
|
||||||
}, [data, showOnlyCheckout]);
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
currentPage,
|
currentPage,
|
||||||
totalPages,
|
totalPages,
|
||||||
currentItems: paginatedAttendances,
|
currentItems: paginatedAttendances,
|
||||||
paginate,
|
paginate,
|
||||||
resetPage,
|
resetPage, // Destructure resetPage here
|
||||||
} = usePagination(processedData, 20);
|
} = usePagination(processedData, 20);
|
||||||
|
|
||||||
// Reset to the first page whenever processedData changes (due to switch on/off)
|
// Reset page when processedData changes (due to filters/search)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
resetPage();
|
resetPage();
|
||||||
}, [processedData, resetPage]);
|
}, [processedData, resetPage]); // Add resetPage to dependency array
|
||||||
|
|
||||||
const handler = useCallback(
|
const handler = useCallback(
|
||||||
(msg) => {
|
(msg) => {
|
||||||
const { startDate, endDate } = dateRange;
|
const { startDate, endDate } = dateRange;
|
||||||
const checkIn = msg.response.checkInTime.substring(0, 10);
|
const checkIn = msg.response.checkInTime ? msg.response.checkInTime.substring(0, 10) : null;
|
||||||
if (
|
|
||||||
projectId === msg.projectId &&
|
|
||||||
startDate <= checkIn &&
|
|
||||||
checkIn <= endDate
|
|
||||||
) {
|
|
||||||
const updatedAttendance = data.map((item) =>
|
|
||||||
item.id === msg.response.id
|
|
||||||
? { ...item, ...msg.response }
|
|
||||||
: item
|
|
||||||
);
|
|
||||||
|
|
||||||
filtering(updatedAttendance);
|
if (
|
||||||
resetPage();
|
projectId === msg.projectId &&
|
||||||
}
|
checkIn &&
|
||||||
},
|
startDate <= checkIn &&
|
||||||
[projectId, dateRange, data, filtering, resetPage]
|
checkIn <= endDate
|
||||||
);
|
) {
|
||||||
|
dispatch(
|
||||||
|
fetchAttendanceData({
|
||||||
|
projectId,
|
||||||
|
fromDate: startDate,
|
||||||
|
toDate: endDate,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[projectId, dateRange, dispatch]
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
eventBus.on("attendance_log", handler);
|
eventBus.on("attendance_log", handler);
|
||||||
return () => eventBus.off("attendance_log", handler);
|
return () => eventBus.off("attendance_log", handler);
|
||||||
}, [handler]);
|
}, [handler]);
|
||||||
|
|
||||||
const employeeHandler = useCallback(
|
const employeeHandler = useCallback(
|
||||||
(msg) => {
|
(msg) => {
|
||||||
const { startDate, endDate } = dateRange;
|
const { startDate, endDate } = dateRange;
|
||||||
if (data.some((item) => item.employeeId == msg.employeeId)) {
|
dispatch(
|
||||||
dispatch(
|
fetchAttendanceData({
|
||||||
fetchAttendanceData({
|
projectId,
|
||||||
projectId,
|
fromDate: startDate,
|
||||||
fromDate: startDate,
|
toDate: endDate,
|
||||||
toDate: endDate,
|
})
|
||||||
})
|
);
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[projectId, dateRange,data]
|
[projectId, dateRange, dispatch]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
eventBus.on("employee", employeeHandler);
|
eventBus.on("employee", employeeHandler);
|
||||||
return () => eventBus.off("employee", employeeHandler);
|
return () => eventBus.off("employee", employeeHandler);
|
||||||
}, [employeeHandler]);
|
}, [employeeHandler]);
|
||||||
@ -224,9 +250,8 @@ const AttendanceLog = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="col-md-2 m-0 text-end">
|
<div className="col-md-2 m-0 text-end">
|
||||||
<i
|
<i
|
||||||
className={`bx bx-refresh cursor-pointer fs-4 ${
|
className={`bx bx-refresh cursor-pointer fs-4 ${loading || isRefreshing ? "spin" : ""
|
||||||
loading || isRefreshing ? "spin" : ""
|
}`}
|
||||||
}`}
|
|
||||||
title="Refresh"
|
title="Refresh"
|
||||||
onClick={() => setIsRefreshing(true)}
|
onClick={() => setIsRefreshing(true)}
|
||||||
/>
|
/>
|
||||||
@ -234,9 +259,9 @@ const AttendanceLog = ({
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="table-responsive text-nowrap"
|
className="table-responsive text-nowrap"
|
||||||
style={{ minHeight: "200px", display: 'flex', alignItems: 'center', justifyContent: 'center' }}
|
style={{ minHeight: "200px", display: 'flex' }}
|
||||||
>
|
>
|
||||||
{data && data.length > 0 && (
|
{processedData && processedData.length > 0 ? (
|
||||||
<table className="table mb-0">
|
<table className="table mb-0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -269,9 +294,9 @@ const AttendanceLog = ({
|
|||||||
const previousAttendance = arr[index - 1];
|
const previousAttendance = arr[index - 1];
|
||||||
const previousDate = previousAttendance
|
const previousDate = previousAttendance
|
||||||
? moment(
|
? moment(
|
||||||
previousAttendance.checkInTime ||
|
previousAttendance.checkInTime ||
|
||||||
previousAttendance.checkOutTime
|
previousAttendance.checkOutTime
|
||||||
).format("YYYY-MM-DD")
|
).format("YYYY-MM-DD")
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (!previousDate || currentDate !== previousDate) {
|
if (!previousDate || currentDate !== previousDate) {
|
||||||
@ -289,7 +314,7 @@ const AttendanceLog = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
acc.push(
|
acc.push(
|
||||||
<tr key={index}>
|
<tr key={attendance.id || 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
|
||||||
@ -330,17 +355,22 @@ const AttendanceLog = ({
|
|||||||
}, [])}
|
}, [])}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
)}
|
) : (
|
||||||
{!loading && !isRefreshing && data.length === 0 && (
|
!loading &&
|
||||||
<span className="text-muted">No employee logs</span>
|
!isRefreshing && (
|
||||||
)}
|
<div
|
||||||
{/* {error && !loading && !isRefreshing && (
|
className="d-flex justify-content-center align-items-center text-muted"
|
||||||
<tr>
|
style={{
|
||||||
<td colSpan={6}>{error}</td>
|
width: "100%",
|
||||||
</tr>
|
}}
|
||||||
)} */}
|
>
|
||||||
|
No employee logs.
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
{!loading && !isRefreshing && processedData.length > 10 && (
|
{!loading && !isRefreshing && processedData.length > 20 && (
|
||||||
<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 className={`page-item ${currentPage === 1 ? "disabled" : ""}`}>
|
<li className={`page-item ${currentPage === 1 ? "disabled" : ""}`}>
|
||||||
@ -355,9 +385,8 @@ const AttendanceLog = ({
|
|||||||
(pageNumber) => (
|
(pageNumber) => (
|
||||||
<li
|
<li
|
||||||
key={pageNumber}
|
key={pageNumber}
|
||||||
className={`page-item ${
|
className={`page-item ${currentPage === pageNumber ? "active" : ""
|
||||||
currentPage === pageNumber ? "active" : ""
|
}`}
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
className="page-link"
|
className="page-link"
|
||||||
@ -369,9 +398,8 @@ const AttendanceLog = ({
|
|||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
<li
|
<li
|
||||||
className={`page-item ${
|
className={`page-item ${currentPage === totalPages ? "disabled" : ""
|
||||||
currentPage === totalPages ? "disabled" : ""
|
}`}
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
className="page-link"
|
className="page-link"
|
||||||
@ -387,4 +415,4 @@ const AttendanceLog = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AttendanceLog;
|
export default AttendanceLog;
|
@ -7,51 +7,39 @@ import { useRegularizationRequests } from "../../hooks/useAttendance";
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import usePagination from "../../hooks/usePagination";
|
import usePagination from "../../hooks/usePagination";
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
import { cacheData, clearCacheKey } from "../../slices/apiDataManager";
|
import { cacheData } from "../../slices/apiDataManager";
|
||||||
|
|
||||||
const Regularization = ({ handleRequest }) => {
|
const Regularization = ({ handleRequest, searchQuery }) => {
|
||||||
var selectedProject = useSelector((store) => store.localVariables.projectId);
|
const selectedProject = useSelector((store) => store.localVariables.projectId);
|
||||||
const [regularizesList, setregularizedList] = useState([]);
|
const [regularizesList, setRegularizedList] = useState([]);
|
||||||
const { regularizes, loading, error, refetch } =
|
const { regularizes, loading, refetch } = useRegularizationRequests(selectedProject);
|
||||||
useRegularizationRequests(selectedProject);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setregularizedList(regularizes);
|
setRegularizedList(regularizes);
|
||||||
}, [regularizes]);
|
}, [regularizes]);
|
||||||
|
|
||||||
const sortByName = (a, b) => {
|
const sortByName = (a, b) => {
|
||||||
const nameA = a.firstName.toLowerCase() + a.lastName.toLowerCase();
|
const nameA = (a.firstName + a.lastName).toLowerCase();
|
||||||
const nameB = b.firstName.toLowerCase() + b.lastName.toLowerCase();
|
const nameB = (b.firstName + b.lastName).toLowerCase();
|
||||||
return nameA?.localeCompare(nameB);
|
return nameA.localeCompare(nameB);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handler = useCallback(
|
const handler = useCallback(
|
||||||
(msg) => {
|
(msg) => {
|
||||||
if (selectedProject == msg.projectId) {
|
if (selectedProject == msg.projectId) {
|
||||||
const updatedAttendance = regularizes?.filter( item => item.id !== msg.response.id );
|
const updatedAttendance = regularizes?.filter(item => item.id !== msg.response.id);
|
||||||
cacheData("regularizedList", {
|
cacheData("regularizedList", {
|
||||||
data: updatedAttendance,
|
data: updatedAttendance,
|
||||||
projectId: selectedProject,
|
projectId: selectedProject,
|
||||||
});
|
});
|
||||||
// clearCacheKey("regularizedList")
|
|
||||||
refetch();
|
refetch();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[selectedProject, regularizes]
|
[selectedProject, regularizes]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const filteredData = [...regularizesList]?.sort(sortByName);
|
const employeeHandler = useCallback(
|
||||||
|
|
||||||
const { currentPage, totalPages, currentItems, paginate } = usePagination(
|
|
||||||
filteredData,
|
|
||||||
20
|
|
||||||
);
|
|
||||||
useEffect(() => {
|
|
||||||
eventBus.on("regularization", handler);
|
|
||||||
return () => eventBus.off("regularization", handler);
|
|
||||||
}, [handler]);
|
|
||||||
|
|
||||||
const employeeHandler = useCallback(
|
|
||||||
(msg) => {
|
(msg) => {
|
||||||
if (regularizes.some((item) => item.employeeId == msg.employeeId)) {
|
if (regularizes.some((item) => item.employeeId == msg.employeeId)) {
|
||||||
refetch();
|
refetch();
|
||||||
@ -60,16 +48,36 @@ const Regularization = ({ handleRequest }) => {
|
|||||||
[regularizes]
|
[regularizes]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
eventBus.on("regularization", handler);
|
||||||
|
return () => eventBus.off("regularization", handler);
|
||||||
|
}, [handler]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
eventBus.on("employee", employeeHandler);
|
eventBus.on("employee", employeeHandler);
|
||||||
return () => eventBus.off("employee", employeeHandler);
|
return () => eventBus.off("employee", employeeHandler);
|
||||||
}, [employeeHandler]);
|
}, [employeeHandler]);
|
||||||
|
|
||||||
|
// ✅ Search filter logic added here
|
||||||
|
const filteredData = [...regularizesList]
|
||||||
|
?.filter((item) => {
|
||||||
|
if (!searchQuery) return true;
|
||||||
|
const lowerSearch = searchQuery.toLowerCase();
|
||||||
|
const fullName = `${item.firstName || ""} ${item.lastName || ""}`.toLowerCase();
|
||||||
|
|
||||||
|
return (
|
||||||
|
item.firstName?.toLowerCase().includes(lowerSearch) ||
|
||||||
|
item.lastName?.toLowerCase().includes(lowerSearch) ||
|
||||||
|
fullName.includes(lowerSearch) ||
|
||||||
|
item.employeeId?.toLowerCase().includes(lowerSearch)
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.sort(sortByName);
|
||||||
|
|
||||||
|
const { currentPage, totalPages, currentItems, paginate } = usePagination(filteredData, 20);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className="table-responsive text-nowrap pb-4">
|
||||||
className="table-responsive text-nowrap pb-4"
|
|
||||||
|
|
||||||
>
|
|
||||||
<table className="table mb-0">
|
<table className="table mb-0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -85,66 +93,53 @@ const Regularization = ({ handleRequest }) => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{/* {loading && (
|
{!loading && currentItems?.length > 0 ? (
|
||||||
<td colSpan={6} className="text-center py-5">
|
currentItems.map((att, index) => (
|
||||||
Loading...
|
<tr key={index}>
|
||||||
</td>
|
<td colSpan={2}>
|
||||||
)} */}
|
<div className="d-flex justify-content-start align-items-center">
|
||||||
|
<Avatar firstName={att.firstName} lastName={att.lastName} />
|
||||||
{!loading &&
|
<div className="d-flex flex-column">
|
||||||
(currentItems?.length > 0 ? (
|
<a href="#" className="text-heading text-truncate">
|
||||||
currentItems?.map((att, index) => (
|
<span className="fw-normal">
|
||||||
<tr key={index}>
|
{att.firstName} {att.lastName}
|
||||||
<td colSpan={2}>
|
</span>
|
||||||
<div className="d-flex justify-content-start align-items-center">
|
</a>
|
||||||
<Avatar
|
|
||||||
firstName={att.firstName}
|
|
||||||
lastName={att.lastName}
|
|
||||||
></Avatar>
|
|
||||||
<div className="d-flex flex-column">
|
|
||||||
<a href="#" className="text-heading text-truncate">
|
|
||||||
<span className="fw-normal">
|
|
||||||
{att.firstName} {att.lastName}
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</div>
|
||||||
<td>{moment(att.checkOutTime).format("DD-MMM-YYYY")}</td>
|
</td>
|
||||||
<td>{convertShortTime(att.checkInTime)}</td>
|
<td>{moment(att.checkOutTime).format("DD-MMM-YYYY")}</td>
|
||||||
<td>
|
<td>{convertShortTime(att.checkInTime)}</td>
|
||||||
{att.checkOutTime
|
<td>
|
||||||
? convertShortTime(att.checkOutTime)
|
{att.checkOutTime ? convertShortTime(att.checkOutTime) : "--"}
|
||||||
: "--"}
|
</td>
|
||||||
</td>
|
<td className="text-center">
|
||||||
<td className="text-center ">
|
<RegularizationActions
|
||||||
{/* <div className='d-flex justify-content-center align-items-center gap-3'> */}
|
attendanceData={att}
|
||||||
<RegularizationActions
|
handleRequest={handleRequest}
|
||||||
attendanceData={att}
|
refresh={refetch}
|
||||||
handleRequest={handleRequest}
|
/>
|
||||||
refresh={refetch}
|
|
||||||
/>
|
|
||||||
{/* </div> */}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<tr>
|
|
||||||
<td
|
|
||||||
colSpan={6}
|
|
||||||
className="text-center"
|
|
||||||
style={{
|
|
||||||
height: "200px",
|
|
||||||
verticalAlign: "middle",
|
|
||||||
borderBottom: "none",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
No Record Found
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))
|
||||||
|
) : (
|
||||||
|
<tr>
|
||||||
|
<td
|
||||||
|
colSpan={6}
|
||||||
|
className="text-center"
|
||||||
|
style={{
|
||||||
|
height: "200px",
|
||||||
|
verticalAlign: "middle",
|
||||||
|
borderBottom: "none",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{loading ? "Loading..." : "No Record Found"}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{!loading && totalPages > 1 && (
|
{!loading && totalPages > 1 && (
|
||||||
<nav aria-label="Page ">
|
<nav aria-label="Page ">
|
||||||
<ul className="pagination pagination-sm justify-content-end py-1 mt-3">
|
<ul className="pagination pagination-sm justify-content-end py-1 mt-3">
|
||||||
@ -159,25 +154,18 @@ const Regularization = ({ handleRequest }) => {
|
|||||||
{[...Array(totalPages)].map((_, index) => (
|
{[...Array(totalPages)].map((_, index) => (
|
||||||
<li
|
<li
|
||||||
key={index}
|
key={index}
|
||||||
className={`page-item ${
|
className={`page-item ${currentPage === index + 1 ? "active" : ""}`}
|
||||||
currentPage === index + 1 ? "active" : ""
|
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
<button
|
<button className="page-link" onClick={() => paginate(index + 1)}>
|
||||||
className="page-link "
|
|
||||||
onClick={() => paginate(index + 1)}
|
|
||||||
>
|
|
||||||
{index + 1}
|
{index + 1}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
<li
|
<li
|
||||||
className={`page-item ${
|
className={`page-item ${currentPage === totalPages ? "disabled" : ""}`}
|
||||||
currentPage === totalPages ? "disabled" : ""
|
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
className="page-link "
|
className="page-link"
|
||||||
onClick={() => paginate(currentPage + 1)}
|
onClick={() => paginate(currentPage + 1)}
|
||||||
>
|
>
|
||||||
»
|
»
|
||||||
@ -190,4 +178,4 @@ const Regularization = ({ handleRequest }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Regularization;
|
export default Regularization;
|
||||||
|
@ -10,13 +10,11 @@ import AttendanceLog from "../../components/Activities/AttendcesLogs";
|
|||||||
import Attendance from "../../components/Activities/Attendance";
|
import Attendance from "../../components/Activities/Attendance";
|
||||||
import AttendanceModel from "../../components/Activities/AttendanceModel";
|
import AttendanceModel from "../../components/Activities/AttendanceModel";
|
||||||
import showToast from "../../services/toastService";
|
import showToast from "../../services/toastService";
|
||||||
// import { useProjects } from "../../hooks/useProjects";
|
|
||||||
import Regularization from "../../components/Activities/Regularization";
|
import Regularization from "../../components/Activities/Regularization";
|
||||||
import { useAttendace } from "../../hooks/useAttendance";
|
import { useAttendace } from "../../hooks/useAttendance";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { setProjectId } from "../../slices/localVariablesSlice";
|
import { setProjectId } from "../../slices/localVariablesSlice";
|
||||||
import { markCurrentAttendance } from "../../slices/apiSlice/attendanceAllSlice";
|
import { markCurrentAttendance } from "../../slices/apiSlice/attendanceAllSlice";
|
||||||
import { hasUserPermission } from "../../utils/authUtils";
|
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
import { REGULARIZE_ATTENDANCE } from "../../utils/constants";
|
import { REGULARIZE_ATTENDANCE } from "../../utils/constants";
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
@ -25,10 +23,11 @@ import { useProjectName } from "../../hooks/useProjects";
|
|||||||
|
|
||||||
const AttendancePage = () => {
|
const AttendancePage = () => {
|
||||||
const [activeTab, setActiveTab] = useState("all");
|
const [activeTab, setActiveTab] = useState("all");
|
||||||
const [ShowPending, setShowPending] = useState(false);
|
const [showPending, setShowPending] = useState(false); // Renamed for consistency
|
||||||
|
const [searchQuery, setSearchQuery] = useState("");
|
||||||
const loginUser = getCachedProfileData();
|
const loginUser = getCachedProfileData();
|
||||||
var selectedProject = useSelector((store) => store.localVariables.projectId);
|
const selectedProject = useSelector((store) => store.localVariables.projectId);
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch();
|
||||||
const {
|
const {
|
||||||
attendance,
|
attendance,
|
||||||
loading: attLoading,
|
loading: attLoading,
|
||||||
@ -40,7 +39,7 @@ const AttendancePage = () => {
|
|||||||
const [modelConfig, setModelConfig] = useState();
|
const [modelConfig, setModelConfig] = useState();
|
||||||
const DoRegularized = useHasUserPermission(REGULARIZE_ATTENDANCE);
|
const DoRegularized = useHasUserPermission(REGULARIZE_ATTENDANCE);
|
||||||
const { projectNames, loading: projectLoading, fetchData } = useProjectName();
|
const { projectNames, loading: projectLoading, fetchData } = useProjectName();
|
||||||
|
|
||||||
|
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
markTime: "",
|
markTime: "",
|
||||||
@ -50,12 +49,16 @@ const AttendancePage = () => {
|
|||||||
|
|
||||||
const handler = useCallback(
|
const handler = useCallback(
|
||||||
(msg) => {
|
(msg) => {
|
||||||
if (selectedProject == msg.projectId) {
|
if (selectedProject === msg.projectId) {
|
||||||
const updatedAttendance = attendances.map((item) =>
|
// Ensure attendances is not null before mapping
|
||||||
item.employeeId === msg.response.employeeId
|
const updatedAttendance = attendances
|
||||||
? { ...item, ...msg.response }
|
? attendances.map((item) =>
|
||||||
: item
|
item.employeeId === msg.response.employeeId
|
||||||
);
|
? { ...item, ...msg.response }
|
||||||
|
: item
|
||||||
|
)
|
||||||
|
: [msg.response]; // If attendances is null, initialize with new response
|
||||||
|
|
||||||
cacheData("Attendance", {
|
cacheData("Attendance", {
|
||||||
data: updatedAttendance,
|
data: updatedAttendance,
|
||||||
projectId: selectedProject,
|
projectId: selectedProject,
|
||||||
@ -63,12 +66,12 @@ const AttendancePage = () => {
|
|||||||
setAttendances(updatedAttendance);
|
setAttendances(updatedAttendance);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[selectedProject, attrecall]
|
[selectedProject, attendances] // Removed attrecall as it's not a direct dependency for this state update
|
||||||
);
|
);
|
||||||
|
|
||||||
const employeeHandler = useCallback(
|
const employeeHandler = useCallback(
|
||||||
(msg) => {
|
(msg) => {
|
||||||
if (attendances.some((item) => item.employeeId == msg.employeeId)) {
|
if (attendances?.some((item) => item.employeeId === msg.employeeId)) {
|
||||||
AttendanceRepository.getAttendance(selectedProject)
|
AttendanceRepository.getAttendance(selectedProject)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
cacheData("Attendance", { data: response.data, selectedProject });
|
cacheData("Attendance", { data: response.data, selectedProject });
|
||||||
@ -85,7 +88,7 @@ const AttendancePage = () => {
|
|||||||
const getRole = (roleId) => {
|
const getRole = (roleId) => {
|
||||||
if (!empRoles) return "Unassigned";
|
if (!empRoles) return "Unassigned";
|
||||||
if (!roleId) return "Unassigned";
|
if (!roleId) return "Unassigned";
|
||||||
const role = empRoles.find((b) => b.id == roleId);
|
const role = empRoles.find((b) => b.id === roleId);
|
||||||
return role ? role.role : "Unassigned";
|
return role ? role.role : "Unassigned";
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -105,24 +108,35 @@ const AttendancePage = () => {
|
|||||||
modalElement.classList.remove("show");
|
modalElement.classList.remove("show");
|
||||||
modalElement.style.display = "none";
|
modalElement.style.display = "none";
|
||||||
document.body.classList.remove("modal-open");
|
document.body.classList.remove("modal-open");
|
||||||
document.querySelector(".modal-backdrop")?.remove();
|
const modalBackdrop = document.querySelector(".modal-backdrop");
|
||||||
|
if (modalBackdrop) {
|
||||||
|
modalBackdrop.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = (formData) => {
|
const handleSubmit = (formData) => {
|
||||||
dispatch(markCurrentAttendance(formData))
|
dispatch(markCurrentAttendance(formData))
|
||||||
.then((action) => {
|
.then((action) => {
|
||||||
const updatedAttendance = attendances.map((item) =>
|
// Check if payload and employeeId exist before mapping
|
||||||
item.employeeId === action.payload.employeeId
|
if (action.payload && action.payload.employeeId) {
|
||||||
? { ...item, ...action.payload }
|
const updatedAttendance = attendances
|
||||||
: item
|
? attendances.map((item) =>
|
||||||
);
|
item.employeeId === action.payload.employeeId
|
||||||
cacheData("Attendance", {
|
? { ...item, ...action.payload }
|
||||||
data: updatedAttendance,
|
: item
|
||||||
projectId: selectedProject,
|
)
|
||||||
});
|
: [action.payload]; // If attendances is null, initialize with new payload
|
||||||
setAttendances(updatedAttendance);
|
|
||||||
showToast("Attedance Marked Successfully", "success");
|
cacheData("Attendance", {
|
||||||
|
data: updatedAttendance,
|
||||||
|
projectId: selectedProject,
|
||||||
|
});
|
||||||
|
setAttendances(updatedAttendance);
|
||||||
|
showToast("Attendance Marked Successfully", "success");
|
||||||
|
} else {
|
||||||
|
showToast("Failed to mark attendance: Invalid response", "error");
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
showToast(error.message, "error");
|
showToast(error.message, "error");
|
||||||
@ -130,31 +144,56 @@ const AttendancePage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleToggle = (event) => {
|
const handleToggle = (event) => {
|
||||||
setShowOnlyCheckout(event.target.checked);
|
setShowPending(event.target.checked);
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(selectedProject == null){
|
if (selectedProject === null && projectNames.length > 0) {
|
||||||
dispatch(setProjectId(projectNames[0]?.id));
|
dispatch(setProjectId(projectNames[0]?.id));
|
||||||
}
|
}
|
||||||
},[])
|
}, [selectedProject, projectNames, dispatch]);
|
||||||
|
|
||||||
|
// Open modal when modelConfig is set
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (modelConfig !== null) {
|
if (modelConfig !== null) {
|
||||||
openModel();
|
openModel();
|
||||||
}
|
}
|
||||||
}, [modelConfig, isCreateModalOpen]);
|
}, [modelConfig]); // Removed isCreateModalOpen from here as it's set by openModel()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setAttendances(attendance);
|
setAttendances(attendance);
|
||||||
}, [attendance]);
|
}, [attendance]);
|
||||||
|
|
||||||
|
// Filter and search logic for the 'Today's' tab (Attendance component)
|
||||||
|
const filteredAndSearchedTodayAttendance = useCallback(() => {
|
||||||
|
let currentData = attendances;
|
||||||
|
|
||||||
const filteredAttendance = ShowPending
|
if (showPending) {
|
||||||
? attendances?.filter(
|
currentData = currentData?.filter(
|
||||||
(att) => att?.checkInTime !== null && att?.checkOutTime === null
|
(att) => att?.checkInTime !== null && att?.checkOutTime === null
|
||||||
)
|
);
|
||||||
: attendances;
|
}
|
||||||
|
|
||||||
|
if (searchQuery) {
|
||||||
|
const lowerCaseSearchQuery = searchQuery.toLowerCase();
|
||||||
|
currentData = currentData?.filter((att) => {
|
||||||
|
// Combine first, middle, and last names for a comprehensive search
|
||||||
|
const fullName = [att.firstName, att.middleName, att.lastName]
|
||||||
|
.filter(Boolean) // Remove null or undefined parts
|
||||||
|
.join(" ")
|
||||||
|
.toLowerCase();
|
||||||
|
|
||||||
|
return (
|
||||||
|
att.employeeName?.toLowerCase().includes(lowerCaseSearchQuery) ||
|
||||||
|
att.employeeId?.toLowerCase().includes(lowerCaseSearchQuery) ||
|
||||||
|
fullName.includes(lowerCaseSearchQuery)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return currentData;
|
||||||
|
}, [attendances, showPending, searchQuery]);
|
||||||
|
|
||||||
|
|
||||||
|
// Event bus listeners
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
eventBus.on("attendance", handler);
|
eventBus.on("attendance", handler);
|
||||||
return () => eventBus.off("attendance", handler);
|
return () => eventBus.off("attendance", handler);
|
||||||
@ -190,97 +229,74 @@ const AttendancePage = () => {
|
|||||||
]}
|
]}
|
||||||
></Breadcrumb>
|
></Breadcrumb>
|
||||||
<div className="nav-align-top nav-tabs-shadow">
|
<div className="nav-align-top nav-tabs-shadow">
|
||||||
{/* <ul className="nav nav-tabs" role="tablist">
|
<ul className="nav nav-tabs d-flex justify-content-between align-items-center" role="tablist">
|
||||||
<div
|
<div className="d-flex">
|
||||||
className="dataTables_length text-start py-2 px-2 d-flex "
|
<li className="nav-item">
|
||||||
id="DataTables_Table_0_length"
|
<button
|
||||||
>
|
type="button"
|
||||||
{loginUser && loginUser?.projects?.length > 1 && (
|
className={`nav-link ${activeTab === "all" ? "active" : ""} fs-6`}
|
||||||
<label>
|
onClick={() => setActiveTab("all")}
|
||||||
<select
|
data-bs-toggle="tab"
|
||||||
name="DataTables_Table_0_length"
|
data-bs-target="#navs-top-home"
|
||||||
aria-controls="DataTables_Table_0"
|
>
|
||||||
className="form-select form-select-sm"
|
Today's
|
||||||
value={selectedProject}
|
</button>
|
||||||
onChange={(e) => dispatch(setProjectId(e.target.value))}
|
</li>
|
||||||
aria-label=""
|
<li className="nav-item">
|
||||||
>
|
<button
|
||||||
{!projectLoading &&
|
type="button"
|
||||||
projects
|
className={`nav-link ${activeTab === "logs" ? "active" : ""} fs-6`}
|
||||||
?.filter((project) =>
|
onClick={() => setActiveTab("logs")}
|
||||||
loginUser?.projects?.map(String).includes(project.id)
|
data-bs-toggle="tab"
|
||||||
)
|
data-bs-target="#navs-top-profile"
|
||||||
.map((project) => (
|
>
|
||||||
<option value={project.id} key={project.id}>
|
Logs
|
||||||
{project.name}
|
</button>
|
||||||
</option>
|
</li>
|
||||||
))}
|
<li className={`nav-item ${!DoRegularized && "d-none"}`}>
|
||||||
{projectLoading && (
|
<button
|
||||||
<option value="Loading..." disabled>
|
type="button"
|
||||||
Loading...
|
className={`nav-link ${activeTab === "regularization" ? "active" : ""
|
||||||
</option>
|
} fs-6`}
|
||||||
)}
|
onClick={() => setActiveTab("regularization")}
|
||||||
</select>
|
data-bs-toggle="tab"
|
||||||
</label>
|
data-bs-target="#navs-top-messages"
|
||||||
)}
|
>
|
||||||
|
Regularization
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
{/* Search Box remains here */}
|
||||||
|
<div className="p-2">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control form-control-sm" // Bootstrap small size input
|
||||||
|
placeholder="Search employee..."
|
||||||
|
value={searchQuery}
|
||||||
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
|
// style={{ width: "200px", height: "30px" }} // Optional: further reduce width/height
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ul> */}
|
|
||||||
|
|
||||||
<ul className="nav nav-tabs" role="tablist">
|
|
||||||
<li className="nav-item">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className={`nav-link ${activeTab === "all" ? "active" : ""} fs-6`}
|
|
||||||
onClick={() => setActiveTab("all")}
|
|
||||||
data-bs-toggle="tab"
|
|
||||||
data-bs-target="#navs-top-home"
|
|
||||||
>
|
|
||||||
Today's
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
<li className="nav-item">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className={`nav-link ${activeTab === "logs" ? "active" : ""} fs-6`}
|
|
||||||
onClick={() => setActiveTab("logs")}
|
|
||||||
data-bs-toggle="tab"
|
|
||||||
data-bs-target="#navs-top-profile"
|
|
||||||
>
|
|
||||||
Logs
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
<li className={`nav-item ${!DoRegularized && "d-none"}`}>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className={`nav-link ${
|
|
||||||
activeTab === "regularization" ? "active" : ""
|
|
||||||
} fs-6`}
|
|
||||||
onClick={() => setActiveTab("regularization")}
|
|
||||||
data-bs-toggle="tab"
|
|
||||||
data-bs-target="#navs-top-messages"
|
|
||||||
>
|
|
||||||
Regularization
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
<div className="tab-content attedanceTabs py-0 px-1 px-sm-3">
|
<div className="tab-content attedanceTabs py-0 px-1 px-sm-3">
|
||||||
{activeTab === "all" && (
|
{activeTab === "all" && (
|
||||||
<>
|
<>
|
||||||
{!attLoading && (
|
{!attLoading && (
|
||||||
<div className="tab-pane fade show active py-0">
|
<div className="tab-pane fade show active py-0">
|
||||||
<Attendance
|
<Attendance
|
||||||
attendance={filteredAttendance}
|
attendance={filteredAndSearchedTodayAttendance()}
|
||||||
handleModalData={handleModalData}
|
handleModalData={handleModalData}
|
||||||
getRole={getRole}
|
getRole={getRole}
|
||||||
setshowOnlyCheckout={setShowPending}
|
setshowOnlyCheckout={setShowPending}
|
||||||
showOnlyCheckout={ShowPending}
|
showOnlyCheckout={showPending}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!attLoading && filteredAttendance?.length === 0 && (
|
{!attLoading && filteredAndSearchedTodayAttendance()?.length === 0 && (
|
||||||
<p>
|
<p>
|
||||||
{" "}
|
{" "}
|
||||||
{ShowPending
|
{showPending
|
||||||
? "No Pending Available"
|
? "No Pending Available"
|
||||||
: "No Employee assigned yet."}{" "}
|
: "No Employee assigned yet."}{" "}
|
||||||
</p>
|
</p>
|
||||||
@ -294,18 +310,21 @@ const AttendancePage = () => {
|
|||||||
handleModalData={handleModalData}
|
handleModalData={handleModalData}
|
||||||
projectId={selectedProject}
|
projectId={selectedProject}
|
||||||
setshowOnlyCheckout={setShowPending}
|
setshowOnlyCheckout={setShowPending}
|
||||||
showOnlyCheckout={ShowPending}
|
showOnlyCheckout={showPending}
|
||||||
|
searchQuery={searchQuery} // Pass search query to AttendanceLog
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{activeTab === "regularization" && DoRegularized && (
|
{activeTab === "regularization" && DoRegularized && (
|
||||||
<div className="tab-pane fade show active py-0">
|
<div className="tab-pane fade show active py-0">
|
||||||
<Regularization handleRequest={handleSubmit} />
|
<Regularization
|
||||||
|
handleRequest={handleSubmit}
|
||||||
|
searchQuery={searchQuery} // ✅ Pass it here
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{attLoading && <span>Loading..</span>}
|
|
||||||
{!attLoading && !attendances && <span>Not Found</span>}
|
{!attLoading && !attendances && <span>Not Found</span>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -314,4 +333,4 @@ const AttendancePage = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AttendancePage;
|
export default AttendancePage;
|
Loading…
x
Reference in New Issue
Block a user