diff --git a/src/components/Activities/AttendcesLogs.jsx b/src/components/Activities/AttendcesLogs.jsx
index 505c7c61..5642c65a 100644
--- a/src/components/Activities/AttendcesLogs.jsx
+++ b/src/components/Activities/AttendcesLogs.jsx
@@ -9,6 +9,7 @@ import DateRangePicker from "../common/DateRangePicker";
import { clearCacheKey, getCachedData } from "../../slices/apiDataManager";
import eventBus from "../../services/eventBus";
import AttendanceRepository from "../../repositories/AttendanceRepository";
+import { useAttendancesLogs } from "../../hooks/useAttendance";
const usePagination = (data, itemsPerPage) => {
const [currentPage, setCurrentPage] = useState(1);
@@ -37,9 +38,12 @@ const AttendanceLog = ({
setshowOnlyCheckout,
showOnlyCheckout,
}) => {
+ const selectedProject = useSelector((store)=>store.localVariables.projectId)
const [dateRange, setDateRange] = useState({ startDate: "", endDate: "" });
const dispatch = useDispatch();
- const { data, loading, error } = useSelector((store) => store.attendanceLogs);
+ const [loading,setLoading] = useState(false)
+ // const { data, loading, error } = useSelector((store) => store.attendanceLogs);
+
const [isRefreshing, setIsRefreshing] = useState(false);
const [processedData, setProcessedData] = useState([]);
@@ -69,18 +73,18 @@ const AttendanceLog = ({
return nameA?.localeCompare(nameB);
};
- useEffect(() => {
- const { startDate, endDate } = dateRange;
- dispatch(
- fetchAttendanceData({
- projectId,
- fromDate: startDate,
- toDate: endDate,
- })
- );
- setIsRefreshing(false);
- }, [dateRange, projectId, dispatch, isRefreshing]);
-
+ // useEffect(() => {
+ // const { startDate, endDate } = dateRange;
+ // dispatch(
+ // fetchAttendanceData({
+ // projectId,
+ // fromDate: startDate,
+ // toDate: endDate,
+ // })
+ // );
+ // setIsRefreshing(false);
+ // }, [dateRange, projectId, dispatch, isRefreshing]);
+ const {data= [],isLoading, error, refetch,isFetching} = useAttendancesLogs(selectedProject,dateRange.startDate, dateRange.endDate)
const filtering = (data) => {
const filteredData = showOnlyCheckout
? data.filter((item) => item.checkOutTime === null)
@@ -146,7 +150,6 @@ const AttendanceLog = ({
resetPage,
} = usePagination(processedData, 20);
- // Reset to the first page whenever processedData changes (due to switch on/off)
useEffect(() => {
resetPage();
}, [processedData, resetPage]);
@@ -225,10 +228,10 @@ const AttendanceLog = ({
setIsRefreshing(true)}
+ onClick={()=>refetch()}
/>
@@ -331,14 +334,9 @@ const AttendanceLog = ({
)}
- {!loading && !isRefreshing && data.length === 0 && (
+ {!loading && !isRefreshing && data?.length === 0 && (
No employee logs
)}
- {/* {error && !loading && !isRefreshing && (
-
- | {error} |
-
- )} */}
{!loading && !isRefreshing && processedData.length > 10 && (