Compare commits

..

No commits in common. "f48d05ecee922f8ef998e0d745b781bb058aab94" and "7c9607cb780a196f19573d55d13c4c95f547fc37" have entirely different histories.

3 changed files with 22 additions and 26 deletions

View File

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

View File

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

View File

@ -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";
@ -21,10 +21,10 @@ import { REGULARIZE_ATTENDANCE } from "../../utils/constants";
const AttendancePage = () => {
const [activeTab, setActiveTab] = useState("all");
const [ShowPending, setShowPending] = useState(false);
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
@ -111,7 +111,7 @@ const AttendancePage = () => {
// (att) => att?.checkOutTime !== null && att?.checkInTime !== null
// )
// : attendances;
const filteredAttendance = ShowPending
const filteredAttendance = showOnlyCheckout
? attendances?.filter((att) => att?.checkInTime !== null && att?.checkOutTime === null)
: attendances;
@ -217,23 +217,23 @@ const AttendancePage = () => {
</ul>
<div className="tab-content attedanceTabs py-0 px-1 px-sm-3">
{projectLoading && <span>Loading..</span>}
{!projectLoading && !attendances && <span>Not Found</span>}
{activeTab === "all" && (
<>
{!projectLoading && filteredAttendance?.length === 0 && (
<p>No Employee assigned yet.</p>
)}
<div className="tab-pane fade show active py-0">
<Attendance
attendance={filteredAttendance}
handleModalData={handleModalData}
getRole={getRole}
setshowOnlyCheckout={setShowPending}
showOnlyCheckout={ShowPending}
setshowOnlyCheckout={setShowOnlyCheckout}
showOnlyCheckout={showOnlyCheckout}
/>
</div>
{!attLoading && filteredAttendance?.length === 0 && (
<p> {ShowPending ? "No Pending Available" : "No Employee assigned yet."} </p>
)}
</>
)}
@ -242,8 +242,8 @@ const AttendancePage = () => {
<AttendanceLog
handleModalData={handleModalData}
projectId={selectedProject}
setshowOnlyCheckout={setShowPending}
showOnlyCheckout={ShowPending}
setshowOnlyCheckout={setShowOnlyCheckout}
showOnlyCheckout={showOnlyCheckout}
/>
</div>
)}
@ -253,9 +253,6 @@ const AttendancePage = () => {
<Regularization handleRequest={handleSubmit} />
</div>
)}
{attLoading && <span>Loading..</span>}
{!attLoading && !attendances && <span>Not Found</span>}
</div>
</div>
</div>