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 === "/" &&