forked from Roflin/gamenight
65 lines
1.5 KiB
JavaScript
65 lines
1.5 KiB
JavaScript
import * as React from 'react';
|
|
import AppBar from '@mui/material/AppBar';
|
|
import Toolbar from '@mui/material/Toolbar';
|
|
import Typography from '@mui/material/Typography';
|
|
import Button from '@mui/material/Button';
|
|
import IconButton from '@mui/material/IconButton';
|
|
import MenuIcon from '@mui/icons-material/Menu';
|
|
|
|
function MenuBar(props) {
|
|
|
|
let adminPanelButton = null;
|
|
if (props.user?.role === 'Admin') {
|
|
adminPanelButton = (
|
|
<Button
|
|
color="inherit"
|
|
onClick={props.onAdmin}>
|
|
AdminPanel
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
let userButton = null;
|
|
if (props.user != null) {
|
|
userButton = (
|
|
<Button
|
|
color="inherit"
|
|
onClick={props.onUser}>
|
|
{props.user.username}
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<AppBar position="static">
|
|
<Toolbar>
|
|
<IconButton
|
|
size="large"
|
|
edge="start"
|
|
color="inherit"
|
|
aria-label="menu"
|
|
sx={{ mr: 2 }}>
|
|
<MenuIcon />
|
|
</IconButton>
|
|
<Typography
|
|
style={{cursor:'pointer'}}
|
|
variant="h6"
|
|
component="div"
|
|
sx={{ flexGrow: 1 }}
|
|
onClick={props.onReset}>
|
|
Gamenight!
|
|
</Typography>
|
|
{userButton !== null && userButton}
|
|
{adminPanelButton !== null && adminPanelButton}
|
|
<Button
|
|
color="inherit"
|
|
onClick={props.onLogout}>
|
|
Logout
|
|
</Button>
|
|
</Toolbar>
|
|
</AppBar>
|
|
);
|
|
}
|
|
|
|
export default MenuBar;
|