2024-05-23 16:57:58 -07:00
|
|
|
import { useState } from 'react';
|
2024-05-24 18:02:58 -07:00
|
|
|
import AppBar from '@mui/material/AppBar';
|
|
|
|
|
import Box from '@mui/material/Box';
|
|
|
|
|
import Toolbar from '@mui/material/Toolbar';
|
|
|
|
|
import IconButton from '@mui/material/IconButton';
|
|
|
|
|
import Typography from '@mui/material/Typography';
|
2024-05-23 16:57:58 -07:00
|
|
|
import Menu from '@mui/material/Menu';
|
2024-05-24 18:02:58 -07:00
|
|
|
import MenuIcon from '@mui/icons-material/Menu';
|
|
|
|
|
import Container from '@mui/material/Container';
|
|
|
|
|
import Avatar from '@mui/material/Avatar';
|
|
|
|
|
import Tooltip from '@mui/material/Tooltip';
|
2024-05-23 16:57:58 -07:00
|
|
|
import MenuItem from '@mui/material/MenuItem';
|
2024-05-24 18:02:58 -07:00
|
|
|
import { useTheme } from '@mui/material/styles';
|
2024-05-06 12:29:36 -04:00
|
|
|
|
2024-05-24 18:02:58 -07:00
|
|
|
const settings = ['Profile', 'Team', 'Invite Colleagues', 'Logout'];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NavBar component
|
|
|
|
|
*
|
|
|
|
|
* A responsive navigation bar component with a user menu.
|
|
|
|
|
*
|
|
|
|
|
* @component
|
|
|
|
|
* @example
|
|
|
|
|
* return (
|
|
|
|
|
* <NavBar />
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
function NavBar() {
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const [anchorElUser, setAnchorElUser] = useState(null);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handles opening the user menu.
|
|
|
|
|
*
|
|
|
|
|
* @param {React.MouseEvent<HTMLElement>} event - The event triggered by clicking the user menu button.
|
|
|
|
|
*/
|
|
|
|
|
const handleOpenUserMenu = (event) => {
|
|
|
|
|
setAnchorElUser(event.currentTarget);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handles closing the user menu.
|
|
|
|
|
*/
|
|
|
|
|
const handleCloseUserMenu = () => {
|
|
|
|
|
setAnchorElUser(null);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<AppBar position="static">
|
|
|
|
|
<Container maxWidth="xl">
|
|
|
|
|
<Toolbar disableGutters>
|
|
|
|
|
<Typography
|
|
|
|
|
variant="h6"
|
|
|
|
|
noWrap
|
|
|
|
|
component="a"
|
|
|
|
|
href="#"
|
|
|
|
|
sx={{
|
|
|
|
|
mr: 2,
|
|
|
|
|
display: { xs: 'none', md: 'flex' },
|
|
|
|
|
fontFamily: 'monospace',
|
|
|
|
|
fontWeight: theme.typography.fontWeightBold,
|
|
|
|
|
letterSpacing: theme.spacing(0.3),
|
|
|
|
|
color: 'inherit',
|
|
|
|
|
textDecoration: 'none',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
UPTIME GENIE
|
|
|
|
|
</Typography>
|
|
|
|
|
|
|
|
|
|
<Box sx={{ flexGrow: 1, display: { xs: 'flex', md: 'none' } }}>
|
|
|
|
|
<IconButton
|
|
|
|
|
size="large"
|
|
|
|
|
aria-label="account of current user"
|
|
|
|
|
aria-controls="menu-appbar"
|
|
|
|
|
aria-haspopup="true"
|
|
|
|
|
color="inherit"
|
2024-05-23 16:57:58 -07:00
|
|
|
>
|
2024-05-24 18:02:58 -07:00
|
|
|
<MenuIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
|
|
<Typography
|
|
|
|
|
variant="h5"
|
|
|
|
|
noWrap
|
|
|
|
|
component="a"
|
|
|
|
|
href="#"
|
|
|
|
|
sx={{
|
|
|
|
|
mr: 2,
|
|
|
|
|
display: { xs: 'flex', md: 'none' },
|
|
|
|
|
flexGrow: 1,
|
|
|
|
|
fontFamily: 'monospace',
|
|
|
|
|
fontWeight: theme.typography.fontWeightBold,
|
|
|
|
|
letterSpacing: theme.spacing(0.3),
|
|
|
|
|
color: 'inherit',
|
|
|
|
|
textDecoration: 'none',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
UPTIME GENIE
|
|
|
|
|
</Typography>
|
|
|
|
|
|
|
|
|
|
<Box sx={{ flexGrow: 1 }} />
|
|
|
|
|
|
|
|
|
|
<Box sx={{ flexGrow: 0 }}>
|
|
|
|
|
<Tooltip title="Open settings">
|
|
|
|
|
<IconButton onClick={handleOpenUserMenu} sx={{ p: 0 }}>
|
|
|
|
|
<Avatar alt="Remy Sharp" src="/static/images/avatar/2.jpg" />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Tooltip>
|
2024-05-23 16:57:58 -07:00
|
|
|
<Menu
|
2024-05-24 18:02:58 -07:00
|
|
|
sx={{ mt: theme.spacing(5.5) }}
|
|
|
|
|
id="menu-appbar"
|
|
|
|
|
anchorEl={anchorElUser}
|
|
|
|
|
anchorOrigin={{
|
|
|
|
|
vertical: 'top',
|
|
|
|
|
horizontal: 'right',
|
|
|
|
|
}}
|
|
|
|
|
keepMounted
|
|
|
|
|
transformOrigin={{
|
|
|
|
|
vertical: 'top',
|
|
|
|
|
horizontal: 'right',
|
|
|
|
|
}}
|
|
|
|
|
open={Boolean(anchorElUser)}
|
|
|
|
|
onClose={handleCloseUserMenu}
|
2024-05-23 16:57:58 -07:00
|
|
|
>
|
2024-05-24 18:02:58 -07:00
|
|
|
{settings.map((setting) => (
|
|
|
|
|
<MenuItem key={setting} onClick={handleCloseUserMenu}>
|
|
|
|
|
<Typography textAlign="center">{setting}</Typography>
|
|
|
|
|
</MenuItem>
|
|
|
|
|
))}
|
2024-05-23 16:57:58 -07:00
|
|
|
</Menu>
|
2024-05-24 18:02:58 -07:00
|
|
|
</Box>
|
|
|
|
|
</Toolbar>
|
|
|
|
|
</Container>
|
|
|
|
|
</AppBar>
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-05-06 12:29:36 -04:00
|
|
|
|
2024-05-23 16:57:58 -07:00
|
|
|
export default NavBar;
|