diff --git a/vinvoor/src/WelcomePage.tsx b/vinvoor/src/WelcomePage.tsx index c8cd2f7..e4a7e28 100644 --- a/vinvoor/src/WelcomePage.tsx +++ b/vinvoor/src/WelcomePage.tsx @@ -2,7 +2,7 @@ import { GitHub } from "@mui/icons-material"; import { Box, Button, Typography } from "@mui/material"; import { ShakerOutline } from "mdi-material-ui"; import { TypographyG } from "./components/TypographyG"; -import { UnstyledLink } from "./components/UnstyledLink"; +import { Login } from "./user/Login"; declare module "@mui/material/Button" { interface ButtonPropsColorOverrides { @@ -29,12 +29,10 @@ export const WelcomePage = () => { > Welcome to Vinvoor! Log in to start scanning - - - + + Log in with Zauth + + +// diff --git a/vinvoor/src/components/UnstyledLink.tsx b/vinvoor/src/components/UnstyledLink.tsx index 5de2736..d1c160c 100644 --- a/vinvoor/src/components/UnstyledLink.tsx +++ b/vinvoor/src/components/UnstyledLink.tsx @@ -2,5 +2,7 @@ import { FC } from "react"; import { Link, LinkProps } from "react-router-dom"; export const UnstyledLink: FC = (props) => { - return ; + return ( + + ); }; diff --git a/vinvoor/src/main.tsx b/vinvoor/src/main.tsx index 18069a6..6cded09 100644 --- a/vinvoor/src/main.tsx +++ b/vinvoor/src/main.tsx @@ -24,6 +24,10 @@ const router = createBrowserRouter([ element: , errorElement: , children: [ + { + path: "login", + element: , + }, { path: "logout", element: , @@ -38,11 +42,6 @@ const router = createBrowserRouter([ }, ], }, - { - path: "/login", - element: , - errorElement: , - }, ]); ReactDOM.createRoot(document.getElementById("root")!).render( diff --git a/vinvoor/src/navbar/NavBar.tsx b/vinvoor/src/navbar/NavBar.tsx index be65857..a660fff 100644 --- a/vinvoor/src/navbar/NavBar.tsx +++ b/vinvoor/src/navbar/NavBar.tsx @@ -1,4 +1,6 @@ +import LeaderboardIcon from "@mui/icons-material/Leaderboard"; import { AppBar, Box, Container, Toolbar } from "@mui/material"; +import { CreditCardMultipleOutline } from "mdi-material-ui"; import { useContext } from "react"; import { DarkModeToggle } from "../components/DarkModeToggle"; import { UserContext } from "../user/UserProvider"; @@ -7,8 +9,17 @@ import { NavBarPages } from "./NavBarPages"; import { NavBarSandwich } from "./NavBarSandwich"; import { NavBarUserMenu } from "./NavBarUserMenu"; -const pages = ["Cards", "Leaderboard"]; -const settings = ["Logout"]; +export interface PageIcon { + page: string; + icon: JSX.Element; +} + +const navBarPages: PageIcon[] = [ + { page: "Cards", icon: }, + { page: "Leaderboard", icon: }, +]; + +const userMenuPages: PageIcon[] = []; export const NavBar = () => { const { @@ -21,7 +32,13 @@ export const NavBar = () => { }; return ( - + {/* Display either the ZeSS logo or a sandwich menu */} @@ -31,7 +48,7 @@ export const NavBar = () => { {user && ( )} @@ -42,7 +59,7 @@ export const NavBar = () => { {user && ( )} @@ -54,7 +71,7 @@ export const NavBar = () => { - + diff --git a/vinvoor/src/navbar/NavBarLogo.tsx b/vinvoor/src/navbar/NavBarLogo.tsx index f2986a0..015a46d 100644 --- a/vinvoor/src/navbar/NavBarLogo.tsx +++ b/vinvoor/src/navbar/NavBarLogo.tsx @@ -1,4 +1,5 @@ import { Box, Button, SxProps, Theme, Typography } from "@mui/material"; +import { HexagonSlice6 } from "mdi-material-ui"; import { FC } from "react"; import { UnstyledLink } from "../components/UnstyledLink"; @@ -18,6 +19,7 @@ export const NavBarLogo: FC = ({ sx }) => { color: "white", }} > + ; } -export const NavBarPages: FC = ({ pages, sx }) => { +export const NavBarPages: FC = ({ pageIcons, sx }) => { return ( - {pages.map((page) => ( + {pageIcons.map(({ page, icon }) => ( diff --git a/vinvoor/src/navbar/NavBarSandwich.tsx b/vinvoor/src/navbar/NavBarSandwich.tsx index 9c46319..71c63e2 100644 --- a/vinvoor/src/navbar/NavBarSandwich.tsx +++ b/vinvoor/src/navbar/NavBarSandwich.tsx @@ -10,13 +10,14 @@ import { } from "@mui/material"; import { FC, MouseEvent, useState } from "react"; import { UnstyledLink } from "../components/UnstyledLink"; +import { PageIcon } from "./NavBar"; interface NavBarSandwichProps { - pages: readonly string[]; + pageIcons: readonly PageIcon[]; sx?: SxProps; } -export const NavBarSandwich: FC = ({ pages, sx }) => { +export const NavBarSandwich: FC = ({ pageIcons, sx }) => { const [anchorElNav, setAnchorElNav] = useState( undefined ); @@ -48,9 +49,10 @@ export const NavBarSandwich: FC = ({ pages, sx }) => { open={Boolean(anchorElNav)} onClose={handleCloseNavMenu} > - {pages.map((page) => ( + {pageIcons.map(({ page, icon }) => ( + {icon} {page} diff --git a/vinvoor/src/navbar/NavBarUserMenu.tsx b/vinvoor/src/navbar/NavBarUserMenu.tsx index 8d64df7..0ceb9c8 100644 --- a/vinvoor/src/navbar/NavBarUserMenu.tsx +++ b/vinvoor/src/navbar/NavBarUserMenu.tsx @@ -1,14 +1,18 @@ import { AccountCircle } from "@mui/icons-material"; import { Button, Menu, MenuItem, Typography } from "@mui/material"; +import ExitRun from "mdi-material-ui/ExitRun"; import { FC, MouseEvent, useContext, useState } from "react"; import { UnstyledLink } from "../components/UnstyledLink"; +import { Login } from "../user/Login"; +import { Logout } from "../user/Logout"; import { UserContext } from "../user/UserProvider"; +import { PageIcon } from "./NavBar"; interface NavBarUserMenuProps { - settings: readonly string[]; + pageIcons: readonly PageIcon[]; } -export const NavBarUserMenu: FC = ({ settings }) => { +export const NavBarUserMenu: FC = ({ pageIcons }) => { const { userState: { user }, } = useContext(UserContext); @@ -29,7 +33,6 @@ export const NavBarUserMenu: FC = ({ settings }) => { {user ? ( <> = ({ settings }) => { open={Boolean(anchorElUser)} onClose={handleCloseUserMenu} > - {settings.map((setting) => ( - + {pageIcons.map(({ page, icon }) => ( + - {setting} + {icon} + {page} ))} + + + + Logout + + ) : ( - - - + + Login + )} ); diff --git a/vinvoor/src/user/Login.tsx b/vinvoor/src/user/Login.tsx index 97276ee..6a0ac81 100644 --- a/vinvoor/src/user/Login.tsx +++ b/vinvoor/src/user/Login.tsx @@ -1,11 +1,16 @@ -import { useEffect } from "react"; +import { Button, ButtonProps } from "@mui/material"; +import { FC } from "react"; -export const Login = () => { +export const Login: FC = (props) => { const baseUrl = import.meta.env.VITE_BASE_URL; - useEffect(() => { - window.location.replace(`${baseUrl}/login`); - }, []); + const handleClick = () => { + const form = document.createElement("form"); + form.method = "POST"; + form.action = `${baseUrl}/login`; + document.body.appendChild(form); + form.submit(); + }; - return <>; + return