2022-06-15 17:31:09 +00:00
|
|
|
import { NotificationsOutlined } from '@mui/icons-material';
|
|
|
|
import {
|
|
|
|
Avatar,
|
|
|
|
Badge,
|
|
|
|
Box,
|
|
|
|
IconButton,
|
|
|
|
Menu,
|
|
|
|
MenuItem,
|
|
|
|
Tooltip,
|
|
|
|
Typography,
|
|
|
|
} from '@mui/material';
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
2022-07-05 16:22:22 +00:00
|
|
|
import styles from './styles';
|
|
|
|
|
2022-06-15 18:03:12 +00:00
|
|
|
function Toolbar({ title, layoutType, avatarMenuOptions }) {
|
2022-07-05 16:22:22 +00:00
|
|
|
const {
|
|
|
|
box,
|
|
|
|
menuBoxContainer,
|
|
|
|
menuBox,
|
|
|
|
notificationIconButton,
|
|
|
|
menuNotifications,
|
|
|
|
menuUser,
|
|
|
|
} = styles[layoutType];
|
2022-06-15 17:31:09 +00:00
|
|
|
const [anchorElUser, setAnchorElUser] = useState(null);
|
|
|
|
const [anchorElNotifications, setAnchorElNotifications] = useState(null);
|
|
|
|
|
2022-06-29 13:39:36 +00:00
|
|
|
if (layoutType === 'desktop') {
|
|
|
|
return (
|
|
|
|
<Box sx={box}>
|
|
|
|
{title}
|
2022-07-05 16:22:22 +00:00
|
|
|
<Box sx={menuBoxContainer}>
|
|
|
|
<Box sx={menuBox}>
|
2022-06-29 13:39:36 +00:00
|
|
|
<Tooltip title="Ver notificações">
|
|
|
|
<IconButton
|
|
|
|
size="large"
|
|
|
|
aria-label="show 17 new notifications"
|
|
|
|
color="inherit"
|
|
|
|
onClick={e => setAnchorElNotifications(e.currentTarget)}
|
2022-07-05 16:22:22 +00:00
|
|
|
sx={notificationIconButton}
|
2022-06-29 13:39:36 +00:00
|
|
|
>
|
|
|
|
<Badge badgeContent={17} color="success">
|
|
|
|
<NotificationsOutlined />
|
|
|
|
</Badge>
|
|
|
|
</IconButton>
|
|
|
|
</Tooltip>
|
|
|
|
<Menu
|
2022-07-05 16:22:22 +00:00
|
|
|
sx={menuNotifications.sx}
|
2022-06-29 13:39:36 +00:00
|
|
|
id="menu-appbar"
|
|
|
|
anchorEl={anchorElNotifications}
|
2022-07-05 16:22:22 +00:00
|
|
|
anchorOrigin={menuNotifications.anchorOrigin}
|
2022-06-29 13:39:36 +00:00
|
|
|
keepMounted
|
2022-07-05 16:22:22 +00:00
|
|
|
transformOrigin={menuNotifications.transformOrigin}
|
2022-06-29 13:39:36 +00:00
|
|
|
open={Boolean(anchorElNotifications)}
|
|
|
|
onClose={() => setAnchorElNotifications(null)}
|
2022-06-15 17:31:09 +00:00
|
|
|
>
|
2022-06-29 13:39:36 +00:00
|
|
|
<MenuItem onClick={() => setAnchorElNotifications(null)}>
|
|
|
|
<Typography textAlign="center">Notificacoes</Typography>
|
|
|
|
</MenuItem>
|
|
|
|
</Menu>
|
|
|
|
<Tooltip title="Ver opções">
|
|
|
|
<IconButton
|
|
|
|
onClick={e => setAnchorElUser(e.currentTarget)}
|
|
|
|
sx={{ p: 0 }}
|
2022-06-15 17:31:09 +00:00
|
|
|
>
|
2022-06-29 13:39:36 +00:00
|
|
|
<Avatar alt="Remy Sharp" src="/static/images/avatar/2.jpg" />
|
|
|
|
</IconButton>
|
|
|
|
</Tooltip>
|
2022-06-15 17:31:09 +00:00
|
|
|
|
2022-06-29 13:39:36 +00:00
|
|
|
<Menu
|
2022-07-05 16:22:22 +00:00
|
|
|
sx={menuUser.sx}
|
2022-06-29 13:39:36 +00:00
|
|
|
id="menu-appbar"
|
|
|
|
anchorEl={anchorElUser}
|
2022-07-05 16:22:22 +00:00
|
|
|
anchorOrigin={menuUser.anchorOrigin}
|
2022-06-29 13:39:36 +00:00
|
|
|
keepMounted
|
2022-07-05 16:22:22 +00:00
|
|
|
transformOrigin={menuUser.transformOrigin}
|
2022-06-29 13:39:36 +00:00
|
|
|
open={Boolean(anchorElUser)}
|
|
|
|
onClose={() => setAnchorElUser(null)}
|
|
|
|
>
|
|
|
|
{avatarMenuOptions.map(option => (
|
|
|
|
<MenuItem key={option.text} onClick={option.action}>
|
|
|
|
<Typography textAlign="center">{option.text}</Typography>
|
|
|
|
</MenuItem>
|
|
|
|
))}
|
|
|
|
</Menu>
|
2022-06-15 17:31:09 +00:00
|
|
|
</Box>
|
|
|
|
</Box>
|
2022-06-29 13:39:36 +00:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
} else if (layoutType === 'mobile') {
|
|
|
|
return (
|
2022-07-05 16:22:22 +00:00
|
|
|
<Box sx={box}>
|
2022-06-29 13:39:36 +00:00
|
|
|
{title}
|
2022-07-05 16:22:22 +00:00
|
|
|
<Box sx={menuBoxContainer}>
|
|
|
|
<Box sx={menuBox}>
|
2022-06-29 13:39:36 +00:00
|
|
|
<Tooltip title="Ver notificações">
|
|
|
|
<IconButton
|
|
|
|
size="large"
|
|
|
|
aria-label="show 17 new notifications"
|
|
|
|
color="inherit"
|
|
|
|
onClick={e => setAnchorElNotifications(e.currentTarget)}
|
2022-07-05 16:22:22 +00:00
|
|
|
sx={notificationIconButton}
|
2022-06-29 13:39:36 +00:00
|
|
|
>
|
|
|
|
<Badge badgeContent={17} color="success">
|
|
|
|
<NotificationsOutlined />
|
|
|
|
</Badge>
|
|
|
|
</IconButton>
|
|
|
|
</Tooltip>
|
|
|
|
<Menu
|
2022-07-05 16:22:22 +00:00
|
|
|
sx={menuNotifications.sx}
|
2022-06-29 13:39:36 +00:00
|
|
|
id="menu-appbar"
|
|
|
|
anchorEl={anchorElNotifications}
|
2022-07-05 16:22:22 +00:00
|
|
|
anchorOrigin={menuNotifications.anchorOrigin}
|
2022-06-29 13:39:36 +00:00
|
|
|
keepMounted
|
2022-07-05 16:22:22 +00:00
|
|
|
transformOrigin={menuNotifications.transformOrigin}
|
2022-06-29 13:39:36 +00:00
|
|
|
open={Boolean(anchorElNotifications)}
|
|
|
|
onClose={() => setAnchorElNotifications(null)}
|
2022-06-15 17:31:09 +00:00
|
|
|
>
|
2022-06-29 13:39:36 +00:00
|
|
|
<MenuItem onClick={() => setAnchorElNotifications(null)}>
|
|
|
|
<Typography textAlign="center">Notificacoes</Typography>
|
|
|
|
</MenuItem>
|
|
|
|
</Menu>
|
|
|
|
<Tooltip title="Ver opções">
|
|
|
|
<IconButton
|
|
|
|
onClick={e => setAnchorElUser(e.currentTarget)}
|
|
|
|
sx={{ p: 0 }}
|
2022-06-15 17:31:09 +00:00
|
|
|
>
|
2022-06-29 13:39:36 +00:00
|
|
|
<Avatar alt="Remy Sharp" src="/static/images/avatar/2.jpg" />
|
|
|
|
</IconButton>
|
|
|
|
</Tooltip>
|
2022-06-15 17:31:09 +00:00
|
|
|
|
2022-06-29 13:39:36 +00:00
|
|
|
<Menu
|
2022-07-05 16:22:22 +00:00
|
|
|
sx={menuUser.sx}
|
2022-06-29 13:39:36 +00:00
|
|
|
id="menu-appbar"
|
|
|
|
anchorEl={anchorElUser}
|
2022-07-05 16:22:22 +00:00
|
|
|
anchorOrigin={menuUser.anchorOrigin}
|
2022-06-29 13:39:36 +00:00
|
|
|
keepMounted
|
2022-07-05 16:22:22 +00:00
|
|
|
transformOrigin={menuUser.transformOrigin}
|
2022-06-29 13:39:36 +00:00
|
|
|
open={Boolean(anchorElUser)}
|
|
|
|
onClose={() => setAnchorElUser(null)}
|
|
|
|
>
|
|
|
|
{avatarMenuOptions.map(option => (
|
|
|
|
<MenuItem key={option.text} onClick={option.action}>
|
|
|
|
<Typography textAlign="center">{option.text}</Typography>
|
|
|
|
</MenuItem>
|
|
|
|
))}
|
|
|
|
</Menu>
|
2022-06-15 17:31:09 +00:00
|
|
|
</Box>
|
|
|
|
</Box>
|
2022-06-29 13:39:36 +00:00
|
|
|
</Box>
|
|
|
|
);
|
2022-06-15 17:31:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Toolbar;
|