diff --git a/src/components/Layout/Header.jsx b/src/components/Layout/Header.jsx index 9769e26b..9023d007 100644 --- a/src/components/Layout/Header.jsx +++ b/src/components/Layout/Header.jsx @@ -1,3 +1,4 @@ + import getGreetingMessage from "../../utils/greetingHandler"; import { cacheData, @@ -26,6 +27,8 @@ const Header = () => { const { data, loading } = useMaster(); const navigate = useNavigate(); const HasManageProjectPermission = useHasUserPermission(MANAGE_PROJECT); + const isDashboard = location.pathname === "/dashboard"; + // const isDirectoryPath = location.pathname === "/directory"; const getRole = (roles, joRoleId) => { if (!Array.isArray(roles)) return "User"; @@ -99,7 +102,7 @@ const Header = () => { if ( projectNames && projectNames.length > 0 && - selectedProject === undefined && + selectedProject === undefined && !getCachedData("hasReceived") ) { dispatch(setProjectId(null)); // Set to null for "All Projects" @@ -108,7 +111,7 @@ const Header = () => { /** Check if current page is project details page or directory page */ - const isProjectPath = /^\/projects\/[a-f0-9-]{36}$/.test(location.pathname); + // const isProjectPath = /^\/projects\/[a-f0-9-]{36}$/.test(location.pathname); const isDirectoryPath = /^\/directory$/.test(location.pathname); const handler = useCallback( @@ -172,69 +175,61 @@ const Header = () => { id="navbar-collapse" > {/* Project Selection Dropdown */} - {projectNames && ( // Ensure projectNames is not null before rendering dropdown + {projectNames && !isDirectoryPath && (
- {(!isProjectPath && !isDirectoryPath) && ( - <> - -
- + +
+ - {/* Render dropdown menu only if there are projects or the "All Projects" option is relevant */} - {projectNames.length > 0 && ( -
    - {/* "All Projects" option */} -
  • + {projectNames.length > 0 && ( +
      + {/* Show "All Projects" only on dashboard */} + {isDashboard && ( +
    • + +
    • + )} + {[...projectNames] + .sort((a, b) => a?.name?.localeCompare(b.name)) + .map((project) => ( +
    • - {[...projectNames] - .sort((a, b) => a?.name?.localeCompare(b.name)) - .map((project) => ( -
    • - -
    • - ))} -
    - )} -
- - )} + ))} + + )} +
)} {/* Display project name on project details or directory pages */} - {isProjectPath && ({displayText})} + {/* { ({displayText})} */} {/* User Profile and Shortcuts */}