From d5d5ad3eceb786bd048e9c8ca6df2ac0975e19e1 Mon Sep 17 00:00:00 2001 From: Jacob Filik Date: Fri, 7 Jun 2024 14:12:02 +0100 Subject: [PATCH] improve header component (#8) --- .../src/components/DiamondIcon.tsx | 39 +++++++++++++++++++ .../src/components/Header.tsx | 29 ++++++++++---- .../src/components/UserIcon.tsx | 10 +++++ xas-standards-client/src/mocks/handlers.ts | 8 ++++ 4 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 xas-standards-client/src/components/DiamondIcon.tsx create mode 100644 xas-standards-client/src/components/UserIcon.tsx diff --git a/xas-standards-client/src/components/DiamondIcon.tsx b/xas-standards-client/src/components/DiamondIcon.tsx new file mode 100644 index 0000000..1fe63c6 --- /dev/null +++ b/xas-standards-client/src/components/DiamondIcon.tsx @@ -0,0 +1,39 @@ +import { SvgIcon } from "@mui/material" + +export default function DiamondIcon() { + return ( + + + + ) +} \ No newline at end of file diff --git a/xas-standards-client/src/components/Header.tsx b/xas-standards-client/src/components/Header.tsx index b5c3e05..929400d 100644 --- a/xas-standards-client/src/components/Header.tsx +++ b/xas-standards-client/src/components/Header.tsx @@ -10,11 +10,14 @@ import ListItem from "@mui/material/ListItem"; import List from "@mui/material/List"; import ListItemText from "@mui/material/ListItemText"; import Stack from "@mui/material/Stack"; -import { Switch } from "@mui/material"; +import {Switch } from "@mui/material"; import { NavLink } from "react-router-dom"; +import DiamondIcon from "./DiamondIcon"; + import ColorModeContext from "../contexts/ColorModeContext"; +import UserIcon from "./UserIcon"; function NavListItem(props: { to: string; label: string }) { const to = props.to; @@ -54,11 +57,12 @@ export default function Header() { return ( - + + + XAS Standards - {Object.entries(navitems).map(([key, value]) => ( @@ -75,12 +79,23 @@ export default function Header() { ))} - {loggedIn ? ( + {loggedIn && ( - ) : ( - - )} + ) } + + + + {!loggedIn ? ( + + ) : ( + + + {user.identifier} + + + )} + ); diff --git a/xas-standards-client/src/components/UserIcon.tsx b/xas-standards-client/src/components/UserIcon.tsx new file mode 100644 index 0000000..859450f --- /dev/null +++ b/xas-standards-client/src/components/UserIcon.tsx @@ -0,0 +1,10 @@ +import { SvgIcon } from "@mui/material" + +export default function UserIcon() { + return ( + + + + + ) +} \ No newline at end of file diff --git a/xas-standards-client/src/mocks/handlers.ts b/xas-standards-client/src/mocks/handlers.ts index 3154309..85a3ddf 100644 --- a/xas-standards-client/src/mocks/handlers.ts +++ b/xas-standards-client/src/mocks/handlers.ts @@ -140,6 +140,14 @@ export const handlers = [ return HttpResponse.json(response); }), + http.get('/login', () => { + return new HttpResponse('
Hello
', { + headers: { + 'Content-Type': 'application/html' + } + }) + }) + // http.get("/login", () => { // // ...and respond to them using this JSON response. // return new HttpResponse(null, { status: 302, Location: "/" });