Browse Source

pre is movil validation

amenpunk 2 years ago
parent
commit
164c4a8a0a
2 changed files with 70 additions and 14 deletions
  1. 66 10
      src/Components/Dashboard.js
  2. 4 4
      src/Components/Navigation/UserOptions.jsx

+ 66 - 10
src/Components/Dashboard.js

3
 
3
 
4
 import {
4
 import {
5
     Container, IconButton, Divider,
5
     Container, IconButton, Divider,
6
-    Typography, List, Toolbar, Box, CssBaseline, useMediaQuery as Size,
6
+    Typography, List, Toolbar,useMediaQuery as Size,
7
+    Box, Badge, Menu, Avatar, MenuItem
7
 } from '@mui/material'
8
 } from '@mui/material'
8
 
9
 
9
 import {
10
 import {
10
     Fullscreen as FullscreenIcon,
11
     Fullscreen as FullscreenIcon,
11
     Menu as MenuIcon,
12
     Menu as MenuIcon,
13
+    KeyboardDoubleArrowLeft as LeftKey,
14
+    Mail as MailIcon, Notifications as NotificationsIcon,
12
 } from '@mui/icons-material'
15
 } from '@mui/icons-material'
13
 
16
 
14
-// import Logo from '../Images/logo.png';
15
 import Logo from '../Images/evaluacion.jpeg';
17
 import Logo from '../Images/evaluacion.jpeg';
16
 
18
 
17
-import { Outlet } from "react-router-dom";
19
+import { Outlet, useNavigate } from "react-router-dom";
18
 import { MenuMovil } from '../Components/Navigation/MenuMovil';
20
 import { MenuMovil } from '../Components/Navigation/MenuMovil';
19
 import Footer from "../Components/Footer";
21
 import Footer from "../Components/Footer";
20
 
22
 
21
-// import { psicotheme } from '../Utils/theme'
22
 import { Drawer as MuiDrawer, AppBar as MuiAppBar } from "../Components/Navigation/AppBar"
23
 import { Drawer as MuiDrawer, AppBar as MuiAppBar } from "../Components/Navigation/AppBar"
23
 import { MainListItems, SecondaryListItems } from '../Components/Navigation/listItems';
24
 import { MainListItems, SecondaryListItems } from '../Components/Navigation/listItems';
24
-import { UserOptions } from '../Components/Navigation/UserOptions'
25
+import useAuth from '../Auth/useAuth.js'
26
+import ProfilePicture from '../Images/man.png';
25
 
27
 
26
 const drawerWidth = 240;
28
 const drawerWidth = 240;
27
 const mdTheme = createTheme();
29
 const mdTheme = createTheme();
78
     const [open, setOpen] = React.useState(false);
80
     const [open, setOpen] = React.useState(false);
79
 
81
 
80
     const isMovil = Size('(min-width:770px)');
82
     const isMovil = Size('(min-width:770px)');
81
-    const navbar = React.useRef(null);
83
+    const auth = useAuth();
84
+    const navigate = useNavigate()
85
+
86
+    const CerrarSession = () => {
87
+        auth.logout();
88
+        navigate('/')
89
+    }
90
+
91
+    const [anchorEl, setAnchorEl] = React.useState(null);
92
+    const open_profile = Boolean(anchorEl);
93
+    const handleClick = (event) => {
94
+        console.log('handle click')
95
+        console.log(event)
96
+        setAnchorEl(event.currentTarget);
97
+    }
98
+    const handleClose = () => setAnchorEl(null)
82
 
99
 
83
     const toggleDrawer = () => {
100
     const toggleDrawer = () => {
84
         setOpen(!open);
101
         setOpen(!open);
99
             <Box sx={{ display: 'flex' }}>
116
             <Box sx={{ display: 'flex' }}>
100
                 <AppBar style={{ backgroundColor: '#fff', boxShadow: 'None' }} position="absolute" open={open}>
117
                 <AppBar style={{ backgroundColor: '#fff', boxShadow: 'None' }} position="absolute" open={open}>
101
                     <Toolbar sx={{ pr: '24px', borderBottom: "1px solid #ec5e69" }} >
118
                     <Toolbar sx={{ pr: '24px', borderBottom: "1px solid #ec5e69" }} >
102
-
103
                         <IconButton
119
                         <IconButton
104
                             edge="start"
120
                             edge="start"
105
                             color="inherit"
121
                             color="inherit"
112
                                 color: "#fff"
128
                                 color: "#fff"
113
                             }} />
129
                             }} />
114
                         </IconButton>
130
                         </IconButton>
115
-
116
                         <Typography component="h1" variant="h6" color="inherit" noWrap sx={{ flexGrow: 1 }} >
131
                         <Typography component="h1" variant="h6" color="inherit" noWrap sx={{ flexGrow: 1 }} >
117
                             {
132
                             {
118
                                 open ? (
133
                                 open ? (
119
                                     <React.Fragment>
134
                                     <React.Fragment>
120
 
135
 
121
                                         <IconButton onClick={toggleDrawer}>
136
                                         <IconButton onClick={toggleDrawer}>
122
-                                            <MenuIcon />
137
+                                            <LeftKey/>
123
                                         </IconButton>
138
                                         </IconButton>
124
 
139
 
125
                                         <IconButton onClick={(event) => event.target.requestFullscreen()}>
140
                                         <IconButton onClick={(event) => event.target.requestFullscreen()}>
129
                                 ) : undefined
144
                                 ) : undefined
130
                             }
145
                             }
131
                         </Typography>
146
                         </Typography>
132
-                        <UserOptions/>
147
+
148
+                        <Box sx={{ display: { xs: 'none', md: 'flex' } }}>
149
+                            <IconButton size="large" aria-label="show 4 new mails" color="inherit">
150
+                                <Badge badgeContent={4} color="error">
151
+                                    <MailIcon style={{ color : '#212529' }} />
152
+                                </Badge>
153
+                            </IconButton>
154
+                            <IconButton
155
+                                size="large"
156
+                                aria-label="show 17 new notifications"
157
+                                color="inherit">
158
+                                <Badge badgeContent={17} color="error">
159
+                                    <NotificationsIcon style={{ color : '#212529' }}/>
160
+                                </Badge>
161
+                            </IconButton>
162
+
163
+
164
+                            <IconButton
165
+                                size="small"
166
+                                edge="end"
167
+                                aria-label="account of current user"
168
+                                aria-haspopup="true"
169
+                                aria-expanded={open_profile ? 'true' : undefined}
170
+                                onClick={handleClick}
171
+                                color="inherit"
172
+                            >
173
+                                <Avatar alt="Cindy Baker" src={ProfilePicture} />
174
+
175
+                            </IconButton>
176
+                            <Menu
177
+                                id="basic-menu"
178
+                                anchorEl={anchorEl}
179
+                                open={open_profile}
180
+                                onClose={handleClose}
181
+                                MenuListProps={{ 'aria-labelledby': 'basic-button', }}>
182
+                                <MenuItem onClick={() => navigate('dashboard/perfil') }>Profile</MenuItem>
183
+                                <MenuItem onClick={() => console.log('opcion 2')}>My account</MenuItem>
184
+                                <MenuItem onClick={CerrarSession}>Logout</MenuItem>
185
+                            </Menu>
186
+                        </Box>
187
+
188
+
133
                     </Toolbar>
189
                     </Toolbar>
134
                 </AppBar>
190
                 </AppBar>
135
                 <Drawer variant="permanent" open={open} >
191
                 <Drawer variant="permanent" open={open} >

+ 4 - 4
src/Components/Navigation/UserOptions.jsx

21
         navigate('/')
21
         navigate('/')
22
     }
22
     }
23
 
23
 
24
-
25
     const [anchorEl, setAnchorEl] = React.useState(null);
24
     const [anchorEl, setAnchorEl] = React.useState(null);
26
     const open_profile = Boolean(anchorEl);
25
     const open_profile = Boolean(anchorEl);
27
-    const handleClick = (event) => setAnchorEl(event.currentTarget);
26
+    const handleClick = (event) => {
27
+        console.log('handle click')
28
+        setAnchorEl(event.currentTarget);
29
+    }
28
     const handleClose = () => setAnchorEl(null)
30
     const handleClose = () => setAnchorEl(null)
29
 
31
 
30
     return(
32
     return(
42
                     <NotificationsIcon style={{ color: '#212529' }} />
44
                     <NotificationsIcon style={{ color: '#212529' }} />
43
                 </Badge>
45
                 </Badge>
44
             </IconButton>
46
             </IconButton>
45
-
46
-
47
             <IconButton
47
             <IconButton
48
                 size="small"
48
                 size="small"
49
                 edge="end"
49
                 edge="end"