Attendance Tab Should Display All Records for Each Employee
This commit is contained in:
parent
0511ed6d82
commit
654a8c2400
@ -243,6 +243,7 @@ const AttendanceLog = ({ handleModalData, searchTerm, organizationId }) => {
|
||||
return () => eventBus.off("employee", employeeHandler);
|
||||
}, [employeeHandler]);
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
@ -281,8 +282,10 @@ const AttendanceLog = ({ handleModalData, searchTerm, organizationId }) => {
|
||||
<th className="border-top-1" colSpan={2}>
|
||||
Name
|
||||
</th>
|
||||
<th className="border-top-1">Project Name</th>
|
||||
<th className="border-top-1">Date</th>
|
||||
{/* <th>Organization</th> */}
|
||||
|
||||
<th>
|
||||
<i className="bx bxs-down-arrow-alt text-success"></i> Check-In
|
||||
</th>
|
||||
@ -341,6 +344,7 @@ const AttendanceLog = ({ handleModalData, searchTerm, organizationId }) => {
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>{attendance.projectName || "--"}</td>
|
||||
<td>
|
||||
{moment(
|
||||
attendance.checkInTime || attendance.checkOutTime
|
||||
|
@ -11,6 +11,7 @@ import { cacheData, clearCacheKey, useSelectedProject } from "../../slices/apiDa
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import Pagination from "../common/Pagination";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { employee } from "../../data/masters";
|
||||
|
||||
const Regularization = ({ handleRequest, searchTerm, projectId, organizationId, IncludeInActive }) => {
|
||||
const queryClient = useQueryClient();
|
||||
@ -119,6 +120,8 @@ const Regularization = ({ handleRequest, searchTerm, projectId, organizationId,
|
||||
return () => eventBus.off("employee", employeeHandler);
|
||||
}, [employeeHandler]);
|
||||
|
||||
console.log("Kartik",currentItems)
|
||||
|
||||
return (
|
||||
<div className="table-responsive text-nowrap pb-4" style={{ minHeight: "200px" }}>
|
||||
{loading ? (
|
||||
@ -130,6 +133,7 @@ const Regularization = ({ handleRequest, searchTerm, projectId, organizationId,
|
||||
<thead>
|
||||
<tr>
|
||||
<th colSpan={2}>Name</th>
|
||||
<th>Project Name</th>
|
||||
<th>Date</th>
|
||||
{/* <th>Organization</th> */}
|
||||
<th>
|
||||
@ -169,6 +173,7 @@ const Regularization = ({ handleRequest, searchTerm, projectId, organizationId,
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>{att.projectName || "--"}</td>
|
||||
<td>{moment(att.checkOutTime).format("DD-MMM-YYYY")}</td>
|
||||
|
||||
{/* <td>{att.organizationName || "--"}</td> */}
|
||||
|
@ -99,7 +99,7 @@ const EmpAttendance = ({ employee }) => {
|
||||
if (
|
||||
!existing ||
|
||||
new Date(rec.checkInTime || rec.checkOutTime) >
|
||||
new Date(existing.checkInTime || existing.checkOutTime)
|
||||
new Date(existing.checkInTime || existing.checkOutTime)
|
||||
) {
|
||||
uniqueMap.set(key, rec);
|
||||
}
|
||||
@ -123,7 +123,7 @@ const EmpAttendance = ({ employee }) => {
|
||||
};
|
||||
const closeModal = () => setIsModalOpen(false);
|
||||
|
||||
const onSubmit = (formData) => {};
|
||||
const onSubmit = (formData) => { };
|
||||
return (
|
||||
<>
|
||||
{isModalOpen && (
|
||||
@ -152,20 +152,14 @@ const EmpAttendance = ({ employee }) => {
|
||||
</form>
|
||||
</FormProvider>
|
||||
</>
|
||||
</div>
|
||||
<div className="col-md-2 m-0 text-end">
|
||||
<i
|
||||
className={`bx bx-refresh cursor-pointer fs-4 ${
|
||||
isFetching ? "spin" : ""
|
||||
}`}
|
||||
data-toggle="tooltip"
|
||||
title="Refresh"
|
||||
onClick={() => refetch()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="table-responsive text-nowrap">
|
||||
{!loading && data.length === 0 && <span>No employee logs</span>}
|
||||
{!loading && data.length === 0 && (
|
||||
<span style={{ fontSize: "0.9rem" }}>
|
||||
No attendance record found in selected date range
|
||||
</span>
|
||||
)}
|
||||
{isError && <div className="text-center">{error.message}</div>}
|
||||
{loading && !data && <div className="text-center">Loading...</div>}
|
||||
{data && data.length > 0 && (
|
||||
@ -250,9 +244,8 @@ const EmpAttendance = ({ employee }) => {
|
||||
{[...Array(totalPages)].map((_, index) => (
|
||||
<li
|
||||
key={index}
|
||||
className={`page-item ${
|
||||
currentPage === index + 1 ? "active" : ""
|
||||
}`}
|
||||
className={`page-item ${currentPage === index + 1 ? "active" : ""
|
||||
}`}
|
||||
>
|
||||
<button
|
||||
className="page-link "
|
||||
@ -263,9 +256,8 @@ const EmpAttendance = ({ employee }) => {
|
||||
</li>
|
||||
))}
|
||||
<li
|
||||
className={`page-item ${
|
||||
currentPage === totalPages ? "disabled" : ""
|
||||
}`}
|
||||
className={`page-item ${currentPage === totalPages ? "disabled" : ""
|
||||
}`}
|
||||
>
|
||||
<button
|
||||
className="page-link "
|
||||
|
@ -42,7 +42,6 @@ export const useAttendance = (projectId, organizationId, includeInactive = false
|
||||
|
||||
export const useAttendancesLogs = (projectId, fromDate, toDate,organizationId) => {
|
||||
const dispatch = useDispatch();
|
||||
const enabled = !!projectId && !!fromDate && !!toDate;
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: ['attendanceLogs', projectId, fromDate, toDate,organizationId],
|
||||
@ -55,7 +54,6 @@ export const useAttendancesLogs = (projectId, fromDate, toDate,organizationId) =
|
||||
);
|
||||
return res.data;
|
||||
},
|
||||
enabled,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@ -123,7 +121,7 @@ export const useRegularizationRequests = (projectId, organizationId, IncludeInAc
|
||||
refetch: recall,
|
||||
isFetching,
|
||||
} = useQuery({
|
||||
queryKey: ["regularizedList", projectId, organizationId, IncludeInActive], // include filters in cache key
|
||||
queryKey: ["regularizedList", projectId, organizationId, IncludeInActive],
|
||||
queryFn: async () => {
|
||||
const response = await AttendanceRepository.getRegularizeList(
|
||||
projectId,
|
||||
@ -132,7 +130,6 @@ export const useRegularizationRequests = (projectId, organizationId, IncludeInAc
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
enabled: !!projectId, // only run if projectId exists
|
||||
onError: (error) => {
|
||||
showToast(error.message || "Error while fetching regularizes", "error");
|
||||
},
|
||||
|
@ -2,8 +2,8 @@ import { api } from "../utils/axiosClient";
|
||||
|
||||
const AttendanceRepository = {
|
||||
markAttendance: (data) => api.post("/api/attendance/record", data),
|
||||
|
||||
getAttendance: (projectId, organizationId, includeInactive,date) => {
|
||||
|
||||
getAttendance: (projectId, organizationId, includeInactive, date) => {
|
||||
let url = `/api/attendance/project/team`;
|
||||
|
||||
const params = [];
|
||||
@ -13,41 +13,47 @@ const AttendanceRepository = {
|
||||
if (date) params.push(`date=${date}`);
|
||||
|
||||
if (params.length > 0) {
|
||||
url += `&${params.join("&")}`; }
|
||||
url += `?${params.join("&")}`;
|
||||
}
|
||||
|
||||
return api.get(url);
|
||||
},
|
||||
|
||||
getAttendanceFilteredByDate: (projectId, fromDate, toDate,organizationId) => {
|
||||
let url = `api/Attendance/project/log?projectId=${projectId}`;
|
||||
if (fromDate) {
|
||||
url += `&dateFrom=${fromDate}`;
|
||||
getAttendanceFilteredByDate: (projectId, fromDate, toDate, organizationId) => {
|
||||
let url = `api/attendance/project/log`;
|
||||
|
||||
const params = [];
|
||||
if (projectId) params.push(`projectId=${projectId}`);
|
||||
if (fromDate) params.push(`dateFrom=${fromDate}`);
|
||||
if (toDate) params.push(`dateTo=${toDate}`);
|
||||
if (organizationId) params.push(`organizationId=${organizationId}`);
|
||||
|
||||
if (params.length > 0) {
|
||||
url += `?${params.join("&")}`;
|
||||
}
|
||||
|
||||
if (toDate) {
|
||||
url += `&dateTo=${toDate}`;
|
||||
}
|
||||
if (organizationId) {
|
||||
url += `&organizationId=${organizationId}`;
|
||||
}
|
||||
return api.get(url);
|
||||
},
|
||||
|
||||
|
||||
getAttendanceLogs: (id) => api.get(`api/attendance/log/attendance/${id}`),
|
||||
|
||||
getRegularizeList: (projectId, organizationId, IncludeInActive) => {
|
||||
let url = `/api/attendance/regularize?projectId=${projectId}`;
|
||||
getRegularizeList: (projectId, organizationId, IncludeInActive) => {
|
||||
let url = `/api/attendance/regularize`;
|
||||
|
||||
const params = [];
|
||||
if (projectId) params.push(`projectId=${projectId}`);
|
||||
if (organizationId) params.push(`organizationId=${organizationId}`);
|
||||
if (IncludeInActive) params.push(`IncludeInActive=${IncludeInActive}`);
|
||||
|
||||
if (params.length > 0) {
|
||||
url += `&${params.join("&")}`; }
|
||||
url += `?${params.join("&")}`;
|
||||
}
|
||||
|
||||
return api.get(url);
|
||||
},
|
||||
|
||||
|
||||
getAttendanceByEmployee: (employeeId, fromDate, toDate) => {
|
||||
let url = `api/Attendance/log/employee/${employeeId}?`;
|
||||
if (fromDate) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user