Merge pull request 'Removing the dropdown from the Masters page.' (#453) from Kartik_Bug#1417 into OnField_Issues_Oct_2W
Reviewed-on: #453 Merged
This commit is contained in:
commit
a3a5d9fdad
@ -1,4 +1,4 @@
|
|||||||
import { useCallback, useEffect, useState,useMemo } from "react";
|
import { useCallback, useEffect, useState, useMemo } from "react";
|
||||||
import getGreetingMessage from "../../utils/greetingHandler";
|
import getGreetingMessage from "../../utils/greetingHandler";
|
||||||
import {
|
import {
|
||||||
cacheData,
|
cacheData,
|
||||||
@ -14,7 +14,7 @@ import { useProfile } from "../../hooks/useProfile";
|
|||||||
import { useLocation, useNavigate, useParams } from "react-router-dom";
|
import { useLocation, useNavigate, useParams } from "react-router-dom";
|
||||||
import Avatar from "../../components/common/Avatar";
|
import Avatar from "../../components/common/Avatar";
|
||||||
import { useChangePassword } from "../Context/ChangePasswordContext";
|
import { useChangePassword } from "../Context/ChangePasswordContext";
|
||||||
import { useProjects } from "../../hooks/useProjects";
|
import { useProjects } from "../../hooks/useProjects";
|
||||||
import { useProjectName } from "../../hooks/useProjects";
|
import { useProjectName } from "../../hooks/useProjects";
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
@ -22,7 +22,7 @@ import { ALLOW_PROJECTSTATUS_ID, MANAGE_PROJECT, UUID_REGEX } from "../../utils/
|
|||||||
import { useAuthModal, useLogout } from "../../hooks/useAuth";
|
import { useAuthModal, useLogout } from "../../hooks/useAuth";
|
||||||
|
|
||||||
const Header = () => {
|
const Header = () => {
|
||||||
const { profile } = useProfile();
|
const { profile } = useProfile();
|
||||||
const { data: masterData } = useMaster();
|
const { data: masterData } = useMaster();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@ -40,11 +40,12 @@ const Header = () => {
|
|||||||
const isProjectPath = pathname === "/projects";
|
const isProjectPath = pathname === "/projects";
|
||||||
const isDirectory = pathname === "/directory";
|
const isDirectory = pathname === "/directory";
|
||||||
const isEmployeeList = pathname === "/employees";
|
const isEmployeeList = pathname === "/employees";
|
||||||
|
const isMasters = pathname === "/masters";
|
||||||
// const isExpense = pathname === "/expenses";
|
// const isExpense = pathname === "/expenses";
|
||||||
const isEmployeeProfile = UUID_REGEX.test(pathname);
|
const isEmployeeProfile = UUID_REGEX.test(pathname);
|
||||||
|
|
||||||
const hideDropPaths =
|
const hideDropPaths =
|
||||||
isDirectory || isEmployeeList || isEmployeeProfile;
|
isDirectory || isEmployeeList || isMasters || isEmployeeProfile;
|
||||||
|
|
||||||
const showProjectDropdown = !hideDropPaths;
|
const showProjectDropdown = !hideDropPaths;
|
||||||
|
|
||||||
@ -57,8 +58,8 @@ const Header = () => {
|
|||||||
isDashboardPath
|
isDashboardPath
|
||||||
? projectNames
|
? projectNames
|
||||||
: projectNames?.filter((project) =>
|
: projectNames?.filter((project) =>
|
||||||
ALLOW_PROJECTSTATUS_ID.includes(project.projectStatusId)
|
ALLOW_PROJECTSTATUS_ID.includes(project.projectStatusId)
|
||||||
),
|
),
|
||||||
[projectNames, isDashboardPath]
|
[projectNames, isDashboardPath]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -66,11 +67,11 @@ const Header = () => {
|
|||||||
if (projectLoading) return "Loading...";
|
if (projectLoading) return "Loading...";
|
||||||
if (!projectNames?.length) return "No Projects Assigned";
|
if (!projectNames?.length) return "No Projects Assigned";
|
||||||
if (projectNames.length === 1) return projectNames[0].name;
|
if (projectNames.length === 1) return projectNames[0].name;
|
||||||
if (selectedProject === null) return "All Projects";
|
if (selectedProject === null) return "All Projects";
|
||||||
const selectedObj = projectNames.find((p) => p.id === selectedProject);
|
const selectedObj = projectNames.find((p) => p.id === selectedProject);
|
||||||
return selectedObj
|
return selectedObj
|
||||||
? selectedObj.name
|
? selectedObj.name
|
||||||
: projectNames[0]?.name || "No Projects Assigned";
|
: projectNames[0]?.name || "No Projects Assigned";
|
||||||
}, [projectLoading, projectNames, selectedProject]);
|
}, [projectLoading, projectNames, selectedProject]);
|
||||||
|
|
||||||
// ===== Role Helper =====
|
// ===== Role Helper =====
|
||||||
@ -199,13 +200,13 @@ const Header = () => {
|
|||||||
style={{ overflow: "auto", maxHeight: "300px" }}
|
style={{ overflow: "auto", maxHeight: "300px" }}
|
||||||
>
|
>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
className="dropdown-item"
|
className="dropdown-item"
|
||||||
onClick={() => handleProjectChange(null)}
|
onClick={() => handleProjectChange(null)}
|
||||||
>All Project</button>
|
>All Project</button>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{[...projectsForDropdown]
|
{[...projectsForDropdown]
|
||||||
.sort((a, b) => a?.name?.localeCompare(b.name))
|
.sort((a, b) => a?.name?.localeCompare(b.name))
|
||||||
.map((project) => (
|
.map((project) => (
|
||||||
@ -231,7 +232,7 @@ const Header = () => {
|
|||||||
|
|
||||||
<ul className="navbar-nav flex-row align-items-center ms-md-auto">
|
<ul className="navbar-nav flex-row align-items-center ms-md-auto">
|
||||||
{/* {HasManageProjectPermission && ( */}
|
{/* {HasManageProjectPermission && ( */}
|
||||||
|
|
||||||
{/* )} */}
|
{/* )} */}
|
||||||
<li className="nav-item navbar-dropdown dropdown-user dropdown">
|
<li className="nav-item navbar-dropdown dropdown-user dropdown">
|
||||||
<a
|
<a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user