Compare commits

...

3 Commits

Author SHA1 Message Date
Pramod Mahajan
f48d05ecee changed hook name , replaced properly related logic name 2025-06-14 10:46:33 +05:30
Pramod Mahajan
dee44c63aa handled loading properly 2025-06-14 10:45:43 +05:30
Pramod Mahajan
b76ca68059 changed class to className 2025-06-14 10:21:24 +05:30
3 changed files with 26 additions and 22 deletions

View File

@ -147,7 +147,7 @@ const Header = () => {
> >
{project?.name}{" "} {project?.name}{" "}
{project?.shortName ? ( {project?.shortName ? (
<span class="text-primary fw-semibold"> <span className="text-primary fw-semibold">
{" "} {" "}
({project?.shortName}) ({project?.shortName})
</span> </span>
@ -169,7 +169,7 @@ const Header = () => {
<li className="nav-item dropdown-shortcuts navbar-dropdown dropdown me-2 me-xl-0"> <li className="nav-item dropdown-shortcuts navbar-dropdown dropdown me-2 me-xl-0">
<a <a
className="nav-link dropdown-toggle hide-arrow" className="nav-link dropdown-toggle hide-arrow"
href="#;"
data-bs-toggle="dropdown" data-bs-toggle="dropdown"
data-bs-auto-close="true" data-bs-auto-close="true"
aria-expanded="false" aria-expanded="false"

View File

@ -5,7 +5,7 @@ import AttendanceRepository from "../repositories/AttendanceRepository";
export const useAttendace =(projectId)=>{ export const useAttendace =(projectId)=>{
const [attendance, setAttendance] = useState([]); const [attendance, setAttendance] = useState([]);
const[loading,setLoading] = useState(false) const[loading,setLoading] = useState(true)
const [error, setError] = useState(null); const [error, setError] = useState(null);
const fetchData = () => { const fetchData = () => {
@ -16,7 +16,8 @@ export const useAttendace =(projectId)=>{
AttendanceRepository.getAttendance(projectId) AttendanceRepository.getAttendance(projectId)
.then((response) => { .then((response) => {
setAttendance(response.data); setAttendance(response.data);
cacheData("Attendance", { data: response.data, projectId }) cacheData( "Attendance", {data: response.data, projectId} )
setLoading(false)
}) })
.catch((error) => { .catch((error) => {
setLoading(false) setLoading(false)

View File

@ -9,7 +9,7 @@ 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 { 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";
@ -21,10 +21,10 @@ import { REGULARIZE_ATTENDANCE } from "../../utils/constants";
const AttendancePage = () => { const AttendancePage = () => {
const [activeTab, setActiveTab] = useState("all"); const [activeTab, setActiveTab] = useState("all");
const [showOnlyCheckout, setShowOnlyCheckout] = useState(); const [ShowPending, setShowPending] = useState(false);
const loginUser = getCachedProfileData(); const loginUser = getCachedProfileData();
var selectedProject = useSelector((store) => store.localVariables.projectId); var selectedProject = useSelector((store) => store.localVariables.projectId);
const { projects, loading: projectLoading } = useProjects(); // const { projects, loading: projectLoading } = useProjects();
const { attendance, loading: attLoading } = useAttendace(selectedProject); const { attendance, loading: attLoading } = useAttendace(selectedProject);
const [attendances, setAttendances] = useState(); const [attendances, setAttendances] = useState();
const [empRoles, setEmpRoles] = useState(null); const [empRoles, setEmpRoles] = useState(null);
@ -99,11 +99,11 @@ const AttendancePage = () => {
setAttendances(attendance); setAttendances(attendance);
}, [attendance]); }, [attendance]);
useEffect(() => { // useEffect(() => {
if (selectedProject === 1 || selectedProject === undefined) { // if (selectedProject === 1 || selectedProject === undefined) {
dispatch(setProjectId(loginUser?.projects[0])); // dispatch(setProjectId(loginUser?.projects[0]));
} // }
}, [selectedProject, loginUser?.projects]); // }, [selectedProject, loginUser?.projects]);
// Filter attendance data based on the toggle // Filter attendance data based on the toggle
// const filteredAttendance = showOnlyCheckout // const filteredAttendance = showOnlyCheckout
@ -111,7 +111,7 @@ const AttendancePage = () => {
// (att) => att?.checkOutTime !== null && att?.checkInTime !== null // (att) => att?.checkOutTime !== null && att?.checkInTime !== null
// ) // )
// : attendances; // : attendances;
const filteredAttendance = showOnlyCheckout const filteredAttendance = ShowPending
? attendances?.filter((att) => att?.checkInTime !== null && att?.checkOutTime === null) ? attendances?.filter((att) => att?.checkInTime !== null && att?.checkOutTime === null)
: attendances; : attendances;
@ -217,23 +217,23 @@ const AttendancePage = () => {
</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">
{projectLoading && <span>Loading..</span>}
{!projectLoading && !attendances && <span>Not Found</span>}
{activeTab === "all" && ( {activeTab === "all" && (
<> <>
{!projectLoading && filteredAttendance?.length === 0 && (
<p>No Employee assigned yet.</p>
)}
<div className="tab-pane fade show active py-0"> <div className="tab-pane fade show active py-0">
<Attendance <Attendance
attendance={filteredAttendance} attendance={filteredAttendance}
handleModalData={handleModalData} handleModalData={handleModalData}
getRole={getRole} getRole={getRole}
setshowOnlyCheckout={setShowOnlyCheckout} setshowOnlyCheckout={setShowPending}
showOnlyCheckout={showOnlyCheckout} showOnlyCheckout={ShowPending}
/> />
</div> </div>
{!attLoading && filteredAttendance?.length === 0 && (
<p> {ShowPending ? "No Pending Available" : "No Employee assigned yet."} </p>
)}
</> </>
)} )}
@ -242,8 +242,8 @@ const AttendancePage = () => {
<AttendanceLog <AttendanceLog
handleModalData={handleModalData} handleModalData={handleModalData}
projectId={selectedProject} projectId={selectedProject}
setshowOnlyCheckout={setShowOnlyCheckout} setshowOnlyCheckout={setShowPending}
showOnlyCheckout={showOnlyCheckout} showOnlyCheckout={ShowPending}
/> />
</div> </div>
)} )}
@ -253,6 +253,9 @@ const AttendancePage = () => {
<Regularization handleRequest={handleSubmit} /> <Regularization handleRequest={handleSubmit} />
</div> </div>
)} )}
{attLoading && <span>Loading..</span>}
{!attLoading && !attendances && <span>Not Found</span>}
</div> </div>
</div> </div>
</div> </div>