From 7a166fe9208340e34bc717fbb00dbd171389a848 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Wed, 11 Jun 2025 10:36:35 -0700 Subject: [PATCH] Menu re-work almost done --- .../src/components/layout/BackstoryLayout.tsx | 20 ++++++------ .../src/components/layout/BackstoryRoutes.tsx | 2 +- frontend/src/components/layout/Header.tsx | 11 +++---- frontend/src/config/navigationConfig.tsx | 31 ++++++++++++------- frontend/src/types/navigation.ts | 2 +- 5 files changed, 35 insertions(+), 31 deletions(-) diff --git a/frontend/src/components/layout/BackstoryLayout.tsx b/frontend/src/components/layout/BackstoryLayout.tsx index 8a31a69..db05c8f 100644 --- a/frontend/src/components/layout/BackstoryLayout.tsx +++ b/frontend/src/components/layout/BackstoryLayout.tsx @@ -12,7 +12,7 @@ import { Snack, SetSnackType } from 'components/Snack'; import { User } from 'types/types'; import { LoadingComponent } from "components/LoadingComponent"; import { AuthProvider, useAuth, ProtectedRoute } from 'hooks/AuthContext'; -import { useSelectedCandidate } from 'hooks/GlobalContext'; +import { useAppState, useSelectedCandidate } from 'hooks/GlobalContext'; import { getMainNavigationItems, getAllRoutes, @@ -76,29 +76,28 @@ const BackstoryPageContainer = (props: BackstoryPageContainerProps) => { interface BackstoryLayoutProps { page: string; chatRef: React.Ref; - snackRef: React.Ref; - submitQuery: any; } const BackstoryLayout: React.FC = (props: BackstoryLayoutProps) => { - const { page, chatRef, snackRef, submitQuery } = props; + const { page, chatRef, } = props; + const { setSnack } = useAppState(); const navigate = useNavigate(); const location = useLocation(); const { guest, user } = useAuth(); - const { selectedCandidate } = useSelectedCandidate(); const [navigationItems, setNavigationItems] = useState([]); useEffect(() => { const userType = user?.userType || null; - setNavigationItems(getMainNavigationItems(userType)); + setNavigationItems(getMainNavigationItems(userType, user?.isAdmin ? true : false)); }, [user]); // Generate dynamic routes from navigation config const generateRoutes = () => { - if (!guest) return null; + if (!guest && !user) return null; const userType = user?.userType || null; - const routes = getAllRoutes(userType); + const isAdmin = user?.isAdmin ? true : false; + const routes = getAllRoutes(userType, isAdmin); return routes.map((route, index) => { if (!route.path || !route.component) return null; @@ -158,7 +157,7 @@ const BackstoryLayout: React.FC = (props: BackstoryLayoutP }} > - {!guest && ( + {!guest && !user && ( = (props: BackstoryLayoutP /> )} - {guest && ( + {(guest || user) && ( <> @@ -179,7 +178,6 @@ const BackstoryLayout: React.FC = (props: BackstoryLayoutP {location.pathname === "/" &&