after refresh attednace page, now it able get employee default selectedproject. #63

Merged
vikas.nale merged 2 commits from pramod_Bug#178 into Issue_May_2W 2025-05-06 12:45:20 +00:00
Collaborator

Issue:
On page refresh, selectedProject was coming as undefined, which caused setProjectId to not dispatch. As a result, employee data and other project-related data were not loading.

Fix:
Added one more condition in a useEffect that checks if selectedProject is undefined or has the default fallback value (1). If so, it automatically sets the first available project from the logged-in user's project list.


useEffect(() => {
  if (selectedProject === 1 || selectedProject === undefined) {
    dispatch(setProjectId(loginUser?.projects[0]));
  }
}, [selectedProject, loginUser?.projects]);

Now, on page refresh, selectedProject is correctly initialized and all dependent data loads as expected.

**Issue:** On page refresh, selectedProject was coming as undefined, which caused setProjectId to not dispatch. As a result, employee data and other project-related data were not loading. **Fix:** Added one more condition in a useEffect that checks if selectedProject is undefined or has the default fallback value (1). If so, it automatically sets the first available project from the logged-in user's project list. ``` useEffect(() => { if (selectedProject === 1 || selectedProject === undefined) { dispatch(setProjectId(loginUser?.projects[0])); } }, [selectedProject, loginUser?.projects]); ``` Now, on page refresh, selectedProject is correctly initialized and all dependent data loads as expected.
pramod.mahajan added 1 commit 2025-05-06 05:13:06 +00:00
pramod.mahajan added 1 commit 2025-05-06 05:14:32 +00:00
vikas.nale merged commit ff9818fb3c into Issue_May_2W 2025-05-06 12:45:20 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/marco.pms.web#63
No description provided.