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