Reac front end for psicometric app

Dashboard.js 8.5KB

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