Project dropdown should only include active ,On Hold and In Progress Projects only show in Projects page.

This commit is contained in:
Kartik Sharma 2025-07-23 10:52:30 +05:30 committed by pramod mahajan
parent 3925926084
commit 7535028b44

View File

@ -33,25 +33,10 @@ const Header = () => {
/^\/dashboard$/.test(location.pathname) || /^\/$/.test(location.pathname); /^\/dashboard$/.test(location.pathname) || /^\/$/.test(location.pathname);
// Define the specific project status IDs you want to filter by // Define the specific project status IDs you want to filter by
// Changed to explicitly include only 'Active', 'On Hold', 'In Progress'
const allowedProjectStatusIds = [ const allowedProjectStatusIds = [
"603e994b-a27f-4e5d-a251-f3d69b0498ba", // On Hold "603e994b-a27f-4e5d-a251-f3d69b0498ba", // On Hold
"cdad86aa-8a56-4ff4-b633-9c629057dfef", // In Progress "cdad86aa-8a56-4ff4-b633-9c629057dfef", // In Progress
"ef1c356e-0fe0-42df-a5d3-8daee355492d", // Inactive - Removed as per requirement "ef1c356e-0fe0-42df-a5d3-8daee355492d", // Inactive
"b74da4c2-d07e-46f2-9919-e75e49b12731", // Active
];
const isDirectoryPath = /^\/directory$/.test(location.pathname);
const isProjectPath = /^\/projects$/.test(location.pathname);
const isDashboard =
/^\/dashboard$/.test(location.pathname) || /^\/$/.test(location.pathname);
// Define the specific project status IDs you want to filter by
// Changed to explicitly include only 'Active', 'On Hold', 'In Progress'
const allowedProjectStatusIds = [
"603e994b-a27f-4e5d-a251-f3d69b0498ba", // On Hold
"cdad86aa-8a56-4ff4-b633-9c629057dfef", // In Progress
"ef1c356e-0fe0-42df-a5d3-8daee355492d", // Inactive - Removed as per requirement
"b74da4c2-d07e-46f2-9919-e75e49b12731", // Active "b74da4c2-d07e-46f2-9919-e75e49b12731", // Active
]; ];
@ -112,8 +97,8 @@ const Header = () => {
const projectsForDropdown = isDashboard const projectsForDropdown = isDashboard
? projectNames // On dashboard, show all projects ? projectNames // On dashboard, show all projects
: projectNames?.filter(project => : projectNames?.filter(project =>
allowedProjectStatusIds.includes(project.projectStatusId) allowedProjectStatusIds.includes(project.projectStatusId)
); );
// Determine the display text for the project dropdown // Determine the display text for the project dropdown
let displayText = "All Projects"; let displayText = "All Projects";
@ -134,7 +119,7 @@ const Header = () => {
useEffect(() => { useEffect(() => {
if ( if (
projectNames && projectNames && // Use the original projectNames for initial setting to ensure all are considered for initial state if needed
projectNames.length > 0 && projectNames.length > 0 &&
selectedProject === undefined && selectedProject === undefined &&
!getCachedData("hasReceived") !getCachedData("hasReceived")
@ -200,10 +185,7 @@ const Header = () => {
// No navigation if on dashboard or if "All Projects" is selected // No navigation if on dashboard or if "All Projects" is selected
}; };
// Determine if the dropdown should be shown console.log("Kartik sharma", projectNames);
const shouldShowDropdown =
isDashboard || (projectsForDropdown && projectsForDropdown.length > 1);
return ( return (
<nav <nav
className="layout-navbar container-fluid mb-3 navbar navbar-expand-xl navbar-detached align-items-center bg-navbar-theme" className="layout-navbar container-fluid mb-3 navbar navbar-expand-xl navbar-detached align-items-center bg-navbar-theme"
@ -225,28 +207,17 @@ const Header = () => {
<div className="align-items-center"> <div className="align-items-center">
<i className="rounded-circle bx bx-building-house bx-sm-lg bx-md me-2"></i> <i className="rounded-circle bx bx-building-house bx-sm-lg bx-md me-2"></i>
<div className="btn-group"> <div className="btn-group">
{/* Conditionally render the button based on shouldShowDropdown */} <button
{shouldShowDropdown ? ( className={`btn btn-sm-sm btn-xl ${projectsForDropdown && projectsForDropdown.length > 0 ? "dropdown-toggle" : ""
<button } px-1`}
className={`btn btn-sm-sm btn-xl ${projectsForDropdown && projectsForDropdown.length > 0 ? "dropdown-toggle" : "" type="button"
} px-1`} data-bs-toggle="dropdown"
type="button" aria-expanded="false"
data-bs-toggle="dropdown" >
aria-expanded="false" {displayText}
> </button>
{displayText}
</button>
) : (
// If only one project, just display its name without a dropdown
<span className="btn btn-sm-sm btn-xl px-1">
{projectsForDropdown && projectsForDropdown.length === 1
? projectsForDropdown[0].name
: displayText}
</span>
)}
{/* Only render the dropdown menu if shouldShowDropdown is true */} {projectsForDropdown && projectsForDropdown.length > 0 && (
{shouldShowDropdown && projectsForDropdown && projectsForDropdown.length > 0 && (
<ul <ul
className="dropdown-menu" className="dropdown-menu"
style={{ overflow: "auto", maxHeight: "300px" }} style={{ overflow: "auto", maxHeight: "300px" }}