diff --git a/src/hooks/useAttendance.js b/src/hooks/useAttendance.js index 33666784..e971147a 100644 --- a/src/hooks/useAttendance.js +++ b/src/hooks/useAttendance.js @@ -5,7 +5,7 @@ import AttendanceRepository from "../repositories/AttendanceRepository"; export const useAttendace =(projectId)=>{ const [attendance, setAttendance] = useState([]); - const[loading,setLoading] = useState(false) + const[loading,setLoading] = useState(true) const [error, setError] = useState(null); const fetchData = () => { @@ -16,7 +16,8 @@ export const useAttendace =(projectId)=>{ AttendanceRepository.getAttendance(projectId) .then((response) => { setAttendance(response.data); - cacheData("Attendance", { data: response.data, projectId }) + cacheData( "Attendance", {data: response.data, projectId} ) + setLoading(false) }) .catch((error) => { setLoading(false) diff --git a/src/pages/Activities/AttendancePage.jsx b/src/pages/Activities/AttendancePage.jsx index eeee1c1a..8c1330d8 100644 --- a/src/pages/Activities/AttendancePage.jsx +++ b/src/pages/Activities/AttendancePage.jsx @@ -9,7 +9,7 @@ import AttendanceLog from "../../components/Activities/AttendcesLogs"; import Attendance from "../../components/Activities/Attendance"; import AttendanceModel from "../../components/Activities/AttendanceModel"; import showToast from "../../services/toastService"; -import { useProjects } from "../../hooks/useProjects"; +// import { useProjects } from "../../hooks/useProjects"; import Regularization from "../../components/Activities/Regularization"; import { useAttendace } from "../../hooks/useAttendance"; import { useDispatch, useSelector } from "react-redux"; @@ -24,7 +24,7 @@ const AttendancePage = () => { const [showOnlyCheckout, setShowOnlyCheckout] = useState(); const loginUser = getCachedProfileData(); var selectedProject = useSelector((store) => store.localVariables.projectId); - const { projects, loading: projectLoading } = useProjects(); + // const { projects, loading: projectLoading } = useProjects(); const { attendance, loading: attLoading } = useAttendace(selectedProject); const [attendances, setAttendances] = useState(); const [empRoles, setEmpRoles] = useState(null); @@ -99,11 +99,11 @@ const AttendancePage = () => { setAttendances(attendance); }, [attendance]); - useEffect(() => { - if (selectedProject === 1 || selectedProject === undefined) { - dispatch(setProjectId(loginUser?.projects[0])); - } - }, [selectedProject, loginUser?.projects]); + // useEffect(() => { + // if (selectedProject === 1 || selectedProject === undefined) { + // dispatch(setProjectId(loginUser?.projects[0])); + // } + // }, [selectedProject, loginUser?.projects]); // Filter attendance data based on the toggle // const filteredAttendance = showOnlyCheckout @@ -217,14 +217,11 @@ const AttendancePage = () => {
- {projectLoading && Loading..} - {!projectLoading && !attendances && Not Found} + {activeTab === "all" && ( <> - {!projectLoading && filteredAttendance?.length === 0 && ( -

No Employee assigned yet.

- )} +
{ showOnlyCheckout={showOnlyCheckout} />
+ {!attLoading && filteredAttendance?.length === 0 && ( +

No Employee assigned yet.

+ )} )} @@ -253,6 +253,9 @@ const AttendancePage = () => {
)} + + {attLoading && Loading..} + {!attLoading && !attendances && Not Found}