User.jsx 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. // import * as React from 'react';
  2. //
  3. // import {
  4. // Outlet,
  5. // } from "react-router-dom";
  6. //
  7. // import {
  8. // AppBar, Box, CssBaseline, Divider, Drawer,
  9. // IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText,
  10. // Toolbar, Typography, Container, Badge,
  11. // MenuItem, Avatar,Menu
  12. // } from '@mui/material'
  13. //
  14. // import {
  15. // Mail as MailIcon, Notifications as NotificationsIcon,
  16. // Menu as MenuIcon,
  17. // } from '@mui/icons-material'
  18. //
  19. //
  20. // import Footer from "../Components/Footer.js";
  21. // import ProfilePicture from '../Images/man.png';
  22. // import useAuth from '../Auth/useAuth';
  23. import React from 'react';
  24. import { ThemeProvider, styled, createTheme } from '@mui/material/styles';
  25. import '../Css/user.css'
  26. import {
  27. Container, IconButton, Divider,
  28. Typography, List, Toolbar,useMediaQuery as Size,
  29. Box, Badge, Menu, Avatar, MenuItem
  30. } from '@mui/material'
  31. import {
  32. Fullscreen as FullscreenIcon,
  33. Menu as MenuIcon,
  34. KeyboardDoubleArrowLeft as LeftKey,
  35. Mail as MailIcon, Notifications as NotificationsIcon,
  36. } from '@mui/icons-material'
  37. import Logo from '../Images/evaluacion.jpeg';
  38. import { Outlet, useNavigate } from "react-router-dom";
  39. import { MenuMovil } from '../Components/Navigation/MenuMovil';
  40. import Footer from "../Components/Footer";
  41. import { Drawer as MuiDrawer, AppBar as MuiAppBar } from "../Components/Navigation/AppBar"
  42. import { UserListItems, SecondaryListItems } from '../Components/Navigation/listItems';
  43. import useAuth from '../Auth/useAuth.js'
  44. import ProfilePicture from '../Images/man.png';
  45. const drawerWidth = 240;
  46. const mdTheme = createTheme();
  47. const AppBar = styled(MuiAppBar, {
  48. shouldForwardProp: (prop) => prop !== 'open',
  49. })(({ theme, open }) => ({
  50. zIndex: theme.zIndex.drawer + 1,
  51. transition: theme.transitions.create(['width', 'margin'], {
  52. easing: theme.transitions.easing.sharp,
  53. duration: theme.transitions.duration.leavingScreen,
  54. }),
  55. ...(open && {
  56. marginLeft: drawerWidth,
  57. width: `calc(100% - ${drawerWidth}px)`,
  58. transition: theme.transitions.create(['width', 'margin'], {
  59. easing: theme.transitions.easing.sharp,
  60. duration: theme.transitions.duration.enteringScreen,
  61. }),
  62. }),
  63. }));
  64. const Drawer = styled(MuiDrawer,
  65. { shouldForwardProp: (prop) => prop !== 'open' })(
  66. ({ theme, open }) => ({
  67. '& .MuiDrawer-paper': {
  68. position: 'relative',
  69. whiteSpace: 'nowrap',
  70. width: drawerWidth,
  71. transition: theme.transitions.create('width', {
  72. easing: theme.transitions.easing.sharp,
  73. duration: theme.transitions.duration.enteringScreen,
  74. }),
  75. boxSizing: 'border-box',
  76. ...(!open && {
  77. overflowX: 'hidden',
  78. transition: theme.transitions.create('width', {
  79. easing: theme.transitions.easing.sharp,
  80. duration: theme.transitions.duration.leavingScreen,
  81. }),
  82. width: theme.spacing(7),
  83. [theme.breakpoints.up('sm')]: {
  84. width: theme.spacing(9),
  85. },
  86. }),
  87. },
  88. }),
  89. );
  90. export function User() {
  91. const [open, setOpen] = React.useState(false);
  92. const isMovil = Size('(max-width:770px)');
  93. const auth = useAuth();
  94. const navigate = useNavigate()
  95. const CerrarSession = () => {
  96. auth.logout();
  97. navigate('/')
  98. }
  99. const [anchorEl, setAnchorEl] = React.useState(null);
  100. const open_profile = Boolean(anchorEl);
  101. const handleClick = (event) => setAnchorEl(event.currentTarget);
  102. const handleClose = () => setAnchorEl(null)
  103. const toggleDrawer = () => {
  104. if(isMovil){
  105. setAnchorElMov(!anchorElMovil)
  106. }else{
  107. setOpen(!open);
  108. }
  109. }
  110. const [anchorElMovil, setAnchorElMov] = React.useState(false);
  111. return (
  112. <ThemeProvider theme={mdTheme}>
  113. <MenuMovil anchor={anchorElMovil} control={setAnchorElMov} />
  114. <Box sx={{ display: 'flex' }}>
  115. <AppBar style={{ backgroundColor: '#fff', boxShadow: 'None' }} position="absolute" open={open}>
  116. <Toolbar sx={{ pr: '24px', borderBottom: "1px solid var(--second)" }} >
  117. <IconButton
  118. name="navigation_icon_button"
  119. edge="start"
  120. color="inherit"
  121. aria-label="open drawer"
  122. // onClick={isMovil ? MenuResponsive : toggleDrawer}
  123. onClick={toggleDrawer}
  124. sx={{ marginRight: '36px', ...( open && { display: 'none' }), }} >
  125. <MenuIcon style={{
  126. background: 'var(--second)',
  127. fontSize: "40",
  128. color: "#fff"
  129. }} />
  130. </IconButton>
  131. <Typography component="h1" variant="h6" color="inherit" noWrap sx={{ flexGrow: 1 }} >
  132. {
  133. open ? (
  134. <React.Fragment>
  135. <IconButton onClick={toggleDrawer}>
  136. <LeftKey/>
  137. </IconButton>
  138. <IconButton onClick={(event) => event.target.requestFullscreen()}>
  139. <FullscreenIcon style={{ paddinLeft: 15 }} />
  140. </IconButton>
  141. </React.Fragment>
  142. ) : undefined
  143. }
  144. </Typography>
  145. <Box sx={{ display: { xs: 'none', md: 'flex' } }}>
  146. <IconButton size="large" aria-label="show 4 new mails" color="inherit">
  147. <Badge badgeContent={4} color="error">
  148. <MailIcon style={{ color : '#212529' }} />
  149. </Badge>
  150. </IconButton>
  151. <IconButton
  152. size="large"
  153. aria-label="show 17 new notifications"
  154. color="inherit">
  155. <Badge badgeContent={17} color="error">
  156. <NotificationsIcon style={{ color : '#212529' }}/>
  157. </Badge>
  158. </IconButton>
  159. <IconButton
  160. size="small"
  161. edge="end"
  162. aria-label="account of current user"
  163. aria-haspopup="true"
  164. aria-expanded={open_profile ? 'true' : undefined}
  165. onClick={handleClick}
  166. color="inherit"
  167. >
  168. <Avatar alt="Cindy Baker" src={ProfilePicture} />
  169. </IconButton>
  170. <Menu
  171. id="basic-menu"
  172. anchorEl={anchorEl}
  173. open={open_profile}
  174. onClose={handleClose}
  175. MenuListProps={{ 'aria-labelledby': 'basic-button', }}>
  176. <MenuItem onClick={() => navigate('dashboard/perfil') }>Profile</MenuItem>
  177. <MenuItem onClick={() => console.log('opcion 2')}>My account</MenuItem>
  178. <MenuItem onClick={CerrarSession}>Logout</MenuItem>
  179. </Menu>
  180. </Box>
  181. </Toolbar>
  182. </AppBar>
  183. <Drawer variant="permanent" open={open} >
  184. <Toolbar
  185. sx={{
  186. display: 'flex',
  187. alignItems: 'center',
  188. justifyContent: 'flex-start',
  189. px: [1]
  190. }} >
  191. <div style={{ flat: 'righ' }} className="sidebar-header">
  192. <div className="width_img">
  193. <img src={Logo} alt="pruebas psicometricas" />
  194. </div>
  195. </div>
  196. </Toolbar>
  197. <Divider />
  198. <List>
  199. <UserListItems AppBarVisible={open} setAppBarVisible={setOpen} />
  200. </List>
  201. <Divider />
  202. <List>
  203. {SecondaryListItems}
  204. </List>
  205. </Drawer>
  206. <Container maxWidth="lg" sx={{ mt: 2, mb: 2 }}>
  207. <Outlet />
  208. <Footer />
  209. </Container>
  210. </Box>
  211. </ThemeProvider>
  212. );
  213. }