Merge branch 'Document_Manag' of https://git.marcoaiot.com/admin/marco.pms.web into Document_Manag
This commit is contained in:
commit
2a833196f8
@ -44,7 +44,7 @@ const LoginPage = () => {
|
||||
localStorage.setItem("jwtToken", response.data.token);
|
||||
localStorage.setItem("refreshToken", response.data.refreshToken);
|
||||
setLoading(false);
|
||||
navigate("/");
|
||||
navigate("/dashboard");
|
||||
} else {
|
||||
await AuthRepository.sendOTP({ email: data.username });
|
||||
showToast("OTP has been sent to your email.", "success");
|
||||
|
@ -52,7 +52,7 @@ const LoginWithOtp = () => {
|
||||
setLoading(false);
|
||||
localStorage.removeItem("otpUsername");
|
||||
localStorage.removeItem("otpSentTime");
|
||||
navigate("/");
|
||||
navigate("/dashboard");
|
||||
|
||||
} catch (err) {
|
||||
showToast("Invalid or expired OTP.", "error");
|
||||
|
@ -79,11 +79,11 @@ const EmployeeList = () => {
|
||||
}
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedProjectId === null) {
|
||||
dispatch(setProjectId(projectNames[0]?.id));
|
||||
}
|
||||
}, [selectedProjectId]);
|
||||
useEffect(() => {
|
||||
if (!selectedProjectId && projectNames?.length > 0) {
|
||||
dispatch(setProjectId(projectNames[0].id));
|
||||
}
|
||||
}, [selectedProjectId, projectNames, dispatch]);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const applySearchFilter = (data, text) => {
|
||||
|
@ -66,7 +66,7 @@ const router = createBrowserRouter(
|
||||
{
|
||||
element: <HomeLayout />,
|
||||
children: [
|
||||
{ path: "/", element: <Dashboard /> },
|
||||
{ path: "/dashboard", element: <Dashboard /> },
|
||||
{ path: "/projects", element: <ProjectList /> },
|
||||
{ path: "/projects/details", element: <ProjectDetails /> },
|
||||
{ path: "/project/manage/:projectId", element: <ManageProject /> },
|
||||
|
@ -39,10 +39,17 @@ export const useSelectedProject = () => {
|
||||
const selectedProject = useSelector(
|
||||
(store) => store.localVariables.projectId
|
||||
);
|
||||
var project = localStorage.getItem("project");
|
||||
|
||||
const project = localStorage.getItem("project");
|
||||
|
||||
if (project) {
|
||||
return project;
|
||||
} else {
|
||||
return selectedProject;
|
||||
try {
|
||||
const parsed = JSON.parse(project);
|
||||
return parsed ?? selectedProject;
|
||||
} catch (e) {
|
||||
return selectedProject;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return selectedProject;
|
||||
}
|
@ -23,7 +23,7 @@ const localVariablesSlice = createSlice({
|
||||
setProjectId: (state, action) => {
|
||||
localStorage.setItem("project",null)
|
||||
state.projectId = action.payload;
|
||||
localStorage.setItem("project",state.projectId)
|
||||
localStorage.setItem("project",state.projectId || null)
|
||||
},
|
||||
refreshData: ( state, action ) =>
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user