Skip to content

Commit

Permalink
set up auth for side nav to display conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
djnunez-aot committed Aug 13, 2024
1 parent 85031d7 commit 1448bc1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Box, Breadcrumbs, Typography } from "@mui/material";
import { Link, useRouter } from "@tanstack/react-router";
import { Link, useRouter, useRouterState } from "@tanstack/react-router";

Check failure on line 3 in submit-web/src/components/Shared/layout/SideNav/BreadcrumbNav.tsx

View workflow job for this annotation

GitHub Actions / linting (18.x)

'useRouter' is defined but never used
import { theme } from "@/styles/theme";

interface RouteSegment {
Expand All @@ -20,8 +20,8 @@ const filterUniqueRoutes = (breadcrumbs: RouteSegment[]) => {
};

const BreadcrumbNav: React.FC = () => {
const router = useRouter();
const breadcrumbs = router.state.matches.map((match) => {
const router = useRouterState();
const breadcrumbs = router.matches.map((match) => {
const { meta, pathname } = match;

Check warning on line 25 in submit-web/src/components/Shared/layout/SideNav/BreadcrumbNav.tsx

View check run for this annotation

Codecov / codecov/patch

submit-web/src/components/Shared/layout/SideNav/BreadcrumbNav.tsx#L23-L25

Added lines #L23 - L25 were not covered by tests
if (meta)
return {

Check warning on line 27 in submit-web/src/components/Shared/layout/SideNav/BreadcrumbNav.tsx

View check run for this annotation

Codecov / codecov/patch

submit-web/src/components/Shared/layout/SideNav/BreadcrumbNav.tsx#L27

Added line #L27 was not covered by tests
Expand Down
13 changes: 7 additions & 6 deletions submit-web/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ export const Route = createRootRouteWithContext<RouterContext>()({
meta: () => [{ title: "Home" }],
});
function Layout() {
const isMobile = useIsMobile();
const { isAuthenticated } = useAuth();

const isMobile = useIsMobile();
return (
<>
<EAOAppBar />
<BreadcrumbNav />
{isAuthenticated && <BreadcrumbNav />}
<Box
height={"calc(100vh - 88px)"}
width={isMobile ? "100%" : "calc(100vw)"}
flexDirection={"row"}
width={
isMobile ? "100%" : `calc(100vw - ${isAuthenticated ? 240 : 0}px)`
}
flexDirection={isAuthenticated ? "column" : "row"}
display={"flex"}
>
{<SideNavBar />}
{isAuthenticated && <SideNavBar />}
<Outlet />
</Box>
<Footer />
Expand Down

0 comments on commit 1448bc1

Please sign in to comment.