handled console error
This commit is contained in:
parent
e0994c6f43
commit
f3bedf5826
@ -62,7 +62,7 @@ const AttendancePage = () => {
|
|||||||
modalElement.classList.remove("show");
|
modalElement.classList.remove("show");
|
||||||
modalElement.style.display = "none";
|
modalElement.style.display = "none";
|
||||||
document.body.classList.remove("modal-open");
|
document.body.classList.remove("modal-open");
|
||||||
document.querySelector(".modal-backdrop").remove();
|
document.querySelector(".modal-backdrop")?.remove();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ const AttendancePage = () => {
|
|||||||
className="modal fade show"
|
className="modal fade show"
|
||||||
style={{ display: "block" }}
|
style={{ display: "block" }}
|
||||||
id="check-Out-modal"
|
id="check-Out-modal"
|
||||||
tabindex="-1"
|
tabIndex="-1"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
>
|
>
|
||||||
<AttendanceModel
|
<AttendanceModel
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import { useProfile } from "../../hooks/useProfile";
|
|||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { useProjectDetails, useProjects } from "../../hooks/useProjects";
|
import { useProjectDetails, useProjects } from "../../hooks/useProjects";
|
||||||
import { setProjectId } from "../../slices/localVariablesSlice";
|
import { setProjectId } from "../../slices/localVariablesSlice";
|
||||||
|
import showToast from "../../services/toastService";
|
||||||
|
|
||||||
const TaskPlannng = () => {
|
const TaskPlannng = () => {
|
||||||
const { profile } = useProfile();
|
const { profile } = useProfile();
|
||||||
@ -22,6 +23,7 @@ const TaskPlannng = () => {
|
|||||||
(store) => store.localVariables.projectId
|
(store) => store.localVariables.projectId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const [project, setProject] = useState(null);
|
const [project, setProject] = useState(null);
|
||||||
const [projectDetails, setProjectDetails] = useState(null);
|
const [projectDetails, setProjectDetails] = useState(null);
|
||||||
const [activities, setActivities] = useState(null);
|
const [activities, setActivities] = useState(null);
|
||||||
@ -66,14 +68,22 @@ const TaskPlannng = () => {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(error);
|
const message =
|
||||||
setError("Failed to fetch data.");
|
error.response?.data?.message ||
|
||||||
|
error.message ||
|
||||||
|
"An unexpected error occurred";
|
||||||
|
showToast( message, "error" );
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setProjectDetails(project_cache);
|
setProjectDetails(project_cache);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError("Failed to fetch data.");
|
setError( "Failed to fetch data." );
|
||||||
|
const message =
|
||||||
|
error.response?.data?.message ||
|
||||||
|
error.message ||
|
||||||
|
"An unexpected error occurred";
|
||||||
|
showToast( message, "error" );
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user