smooth log out
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
|||||||
ListItem,
|
ListItem,
|
||||||
ListItemAvatar,
|
ListItemAvatar,
|
||||||
ListItemButton,
|
ListItemButton,
|
||||||
|
ListItemIcon,
|
||||||
ListItemText,
|
ListItemText,
|
||||||
ListSubheader,
|
ListSubheader,
|
||||||
Menu,
|
Menu,
|
||||||
@@ -28,6 +29,7 @@ import {
|
|||||||
FiActivity,
|
FiActivity,
|
||||||
FiHeadphones,
|
FiHeadphones,
|
||||||
FiInbox,
|
FiInbox,
|
||||||
|
FiLogOut,
|
||||||
FiMonitor,
|
FiMonitor,
|
||||||
FiMoreVertical,
|
FiMoreVertical,
|
||||||
FiPlay,
|
FiPlay,
|
||||||
@@ -41,6 +43,7 @@ import { useKey } from 'react-use';
|
|||||||
import NirvanaAvatar from './NirvanaAvatar';
|
import NirvanaAvatar from './NirvanaAvatar';
|
||||||
|
|
||||||
import MenuItem from '@mui/material/MenuItem';
|
import MenuItem from '@mui/material/MenuItem';
|
||||||
|
import useAuth from '../providers/AuthProvider';
|
||||||
|
|
||||||
export default function Terminal() {
|
export default function Terminal() {
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
@@ -230,6 +233,8 @@ const Navbar = () => {
|
|||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { logout } = useAuth();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -273,7 +278,7 @@ const Navbar = () => {
|
|||||||
<IconButton
|
<IconButton
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
size="small"
|
size="small"
|
||||||
sx={{ ml: 2 }}
|
sx={{ ml: 2, borderRadius: 1 }}
|
||||||
aria-controls={open ? 'account-menu' : undefined}
|
aria-controls={open ? 'account-menu' : undefined}
|
||||||
aria-haspopup="true"
|
aria-haspopup="true"
|
||||||
aria-expanded={open ? 'true' : undefined}
|
aria-expanded={open ? 'true' : undefined}
|
||||||
@@ -286,22 +291,55 @@ const Navbar = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Menu
|
<Menu
|
||||||
id="account-menu"
|
|
||||||
anchorEl={anchorEl}
|
anchorEl={anchorEl}
|
||||||
|
id="account-menu"
|
||||||
open={open}
|
open={open}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
anchorOrigin={{
|
onClick={handleClose}
|
||||||
vertical: 'top',
|
PaperProps={{
|
||||||
horizontal: 'left',
|
elevation: 0,
|
||||||
}}
|
sx: {
|
||||||
transformOrigin={{
|
overflow: 'visible',
|
||||||
vertical: 'top',
|
filter: 'drop-shadow(0px 2px 8px rgba(0,0,0,0.32))',
|
||||||
horizontal: 'left',
|
mt: 1.5,
|
||||||
|
'& .MuiAvatar-root': {
|
||||||
|
width: 32,
|
||||||
|
height: 32,
|
||||||
|
ml: -0.5,
|
||||||
|
mr: 1,
|
||||||
|
},
|
||||||
|
'&:before': {
|
||||||
|
content: '""',
|
||||||
|
display: 'block',
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
right: 14,
|
||||||
|
width: 10,
|
||||||
|
height: 10,
|
||||||
|
bgcolor: 'background.paper',
|
||||||
|
transform: 'translateY(-50%) rotate(45deg)',
|
||||||
|
zIndex: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
|
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
|
||||||
|
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
|
||||||
>
|
>
|
||||||
<MenuItem onClick={handleClose}>Profile</MenuItem>
|
<MenuItem>
|
||||||
<MenuItem onClick={handleClose}>My account</MenuItem>
|
<Avatar /> Profile
|
||||||
<MenuItem onClick={handleClose}>Logout</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem>
|
||||||
|
<Avatar /> My account
|
||||||
|
</MenuItem>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
<MenuItem onClick={logout}>
|
||||||
|
<ListItemIcon>
|
||||||
|
<FiLogOut />
|
||||||
|
</ListItemIcon>
|
||||||
|
<Typography color="warning">Logout</Typography>
|
||||||
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
<CircularProgress />
|
<CircularProgress />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthContext.Provider value={{ user: currentUser, logout }}>
|
<AuthContext.Provider value={{ user: currentUser, logout }}>
|
||||||
{currentUser ? <>{children}</> : <Login />}
|
{currentUser ? <>{children}</> : <Login />}
|
||||||
|
|||||||
Reference in New Issue
Block a user