-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add main page navbar with logout button
- Loading branch information
1 parent
40b0fab
commit da9421c
Showing
5 changed files
with
81 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
import TicketScoutLogo from "../assets/TicketScoutLogo.svg"; | ||
import { styled } from "@mui/system"; | ||
|
||
const StyledImage = styled("img")({ | ||
height: "26px", | ||
}); | ||
|
||
export default function Logo() { | ||
return <img src={TicketScoutLogo} alt="Telescope" />; | ||
return <StyledImage src={TicketScoutLogo} alt="Telescope" />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import MenuIcon from "@mui/icons-material/Menu"; | ||
import { IconButton } from "@mui/material"; | ||
|
||
export default function MainMenuButton() { | ||
return ( | ||
<> | ||
<IconButton | ||
size="large" | ||
edge="start" | ||
color="inherit" | ||
aria-label="menu" | ||
sx={{ mr: 2 }} | ||
> | ||
<MenuIcon /> | ||
</IconButton> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ export default function MainPage() { | |
return ( | ||
<> | ||
<NavBar navbarContext={"main"} /> | ||
Hello World | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { IconButton, Menu, MenuItem } from "@mui/material"; | ||
import { AccountCircle } from "@mui/icons-material"; | ||
import { MouseEvent, useState } from "react"; | ||
|
||
export default function UserMenuButton() { | ||
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null); | ||
const handleMenu = (event: MouseEvent<HTMLElement>) => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
|
||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
|
||
const logout = () => { | ||
const host = | ||
window.location.host === "localhost:5173" | ||
? "http://localhost:8080" | ||
: window.location.origin; | ||
|
||
window.open(host + "/logout", "_self"); | ||
}; | ||
|
||
return ( | ||
<> | ||
<IconButton | ||
size="large" | ||
aria-label="account of current user" | ||
aria-controls="menu-appbar" | ||
aria-haspopup="true" | ||
onClick={handleMenu} | ||
color="inherit" | ||
> | ||
<AccountCircle /> | ||
</IconButton> | ||
<Menu | ||
id="menu-appbar" | ||
anchorEl={anchorEl} | ||
anchorOrigin={{ vertical: "bottom", horizontal: "center" }} | ||
transformOrigin={{ vertical: "top", horizontal: "center" }} | ||
keepMounted | ||
open={Boolean(anchorEl)} | ||
onClose={handleClose} | ||
> | ||
<MenuItem onClick={logout}>Logout</MenuItem> | ||
</Menu> | ||
</> | ||
); | ||
} |