diff --git a/src/pages/authentication/LoginPage.jsx b/src/pages/authentication/LoginPage.jsx
index ab898b4c..9240e33d 100644
--- a/src/pages/authentication/LoginPage.jsx
+++ b/src/pages/authentication/LoginPage.jsx
@@ -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");
diff --git a/src/pages/authentication/LoginWithOtp.jsx b/src/pages/authentication/LoginWithOtp.jsx
index 73882b4f..8b07f8fb 100644
--- a/src/pages/authentication/LoginWithOtp.jsx
+++ b/src/pages/authentication/LoginWithOtp.jsx
@@ -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");
diff --git a/src/pages/employee/EmployeeList.jsx b/src/pages/employee/EmployeeList.jsx
index 387d6232..eaa2f950 100644
--- a/src/pages/employee/EmployeeList.jsx
+++ b/src/pages/employee/EmployeeList.jsx
@@ -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) => {
diff --git a/src/router/AppRoutes.jsx b/src/router/AppRoutes.jsx
index feb9e05f..66293637 100644
--- a/src/router/AppRoutes.jsx
+++ b/src/router/AppRoutes.jsx
@@ -66,7 +66,7 @@ const router = createBrowserRouter(
{
element: ,
children: [
- { path: "/", element: },
+ { path: "/dashboard", element: },
{ path: "/projects", element: },
{ path: "/projects/details", element: },
{ path: "/project/manage/:projectId", element: },
diff --git a/src/slices/apiDataManager.jsx b/src/slices/apiDataManager.jsx
index 9c3fcc1e..ad4d38a1 100644
--- a/src/slices/apiDataManager.jsx
+++ b/src/slices/apiDataManager.jsx
@@ -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;
+}
\ No newline at end of file
diff --git a/src/slices/localVariablesSlice.jsx b/src/slices/localVariablesSlice.jsx
index 7c996608..0b0a8405 100644
--- a/src/slices/localVariablesSlice.jsx
+++ b/src/slices/localVariablesSlice.jsx
@@ -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 ) =>
{