UserOptions.jsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import React from 'react';
  2. import {
  3. Box, Badge, IconButton, Menu, Avatar, MenuItem
  4. } from '@mui/material'
  5. import {
  6. Mail as MailIcon, Notifications as NotificationsIcon,
  7. } from '@mui/icons-material'
  8. import useAuth from '../../Auth/useAuth.js';
  9. import { useNavigate } from "react-router-dom";
  10. import ProfilePicture from '../../Images/man.png';
  11. export function UserOptions(){
  12. const auth = useAuth();
  13. const navigate = useNavigate()
  14. const CerrarSession = () => {
  15. auth.logout();
  16. navigate('/')
  17. }
  18. const [anchorEl, setAnchorEl] = React.useState(null);
  19. const open_profile = Boolean(anchorEl);
  20. const handleClick = (event) => setAnchorEl(event.currentTarget);
  21. const handleClose = () => setAnchorEl(null)
  22. return(
  23. <Box sx={{ display: { xs: 'none', md: 'flex' } }}>
  24. <IconButton size="large" aria-label="show 4 new mails" color="inherit">
  25. <Badge badgeContent={4} color="error">
  26. <MailIcon style={{ color: '#212529' }} />
  27. </Badge>
  28. </IconButton>
  29. <IconButton
  30. size="large"
  31. aria-label="show 17 new notifications"
  32. color="inherit">
  33. <Badge badgeContent={17} color="error">
  34. <NotificationsIcon style={{ color: '#212529' }} />
  35. </Badge>
  36. </IconButton>
  37. <IconButton
  38. size="small"
  39. edge="end"
  40. aria-label="account of current user"
  41. aria-haspopup="true"
  42. aria-expanded={open_profile ? 'true' : undefined}
  43. onClick={handleClick}
  44. color="inherit" >
  45. <Avatar alt="profile picture" src={ProfilePicture} />
  46. </IconButton>
  47. <Menu
  48. id="basic-menu"
  49. anchorEl={anchorEl}
  50. pen={open_profile}
  51. onClose={handleClose}
  52. MenuListProps={{ 'aria-labelledby': 'basic-button', }}>
  53. <MenuItem onClick={() => navigate('dashboard/perfil')}>Mi Cuenta</MenuItem>
  54. <MenuItem onClick={() => console.log('dashboard/perfil')}>Configuraciones</MenuItem>
  55. <MenuItem onClick={CerrarSession}>Cerrar Sesión</MenuItem>
  56. </Menu>
  57. </Box>
  58. )
  59. }