|
@@ -2,16 +2,16 @@ import React from 'react';
|
2
|
2
|
import { ThemeProvider, styled, createTheme } from '@mui/material/styles';
|
3
|
3
|
|
4
|
4
|
import {
|
5
|
|
- Container, IconButton, Divider,
|
6
|
|
- Typography, List, Toolbar,useMediaQuery as Size,
|
7
|
|
- Box, Badge, Menu, Avatar, MenuItem
|
|
5
|
+ Container, IconButton, Divider,
|
|
6
|
+ Typography, List, Toolbar, useMediaQuery as Size,
|
|
7
|
+ Box, Badge, Menu, Avatar, MenuItem
|
8
|
8
|
} from '@mui/material'
|
9
|
9
|
|
10
|
10
|
import {
|
11
|
|
- Fullscreen as FullscreenIcon,
|
12
|
|
- Menu as MenuIcon,
|
13
|
|
- KeyboardDoubleArrowLeft as LeftKey,
|
14
|
|
- Notifications as NotificationsIcon,
|
|
11
|
+ Fullscreen as FullscreenIcon,
|
|
12
|
+ Menu as MenuIcon,
|
|
13
|
+ KeyboardDoubleArrowLeft as LeftKey,
|
|
14
|
+ Notifications as NotificationsIcon,
|
15
|
15
|
} from '@mui/icons-material'
|
16
|
16
|
|
17
|
17
|
import Logo from '../Images/evaluacion.jpeg';
|
|
@@ -23,57 +23,86 @@ import Footer from "../Components/Footer";
|
23
|
23
|
import { Drawer as MuiDrawer, AppBar as MuiAppBar } from "../Components/Navigation/AppBar"
|
24
|
24
|
import { MainListItems, SecondaryListItems } from '../Components/Navigation/listItems';
|
25
|
25
|
import ProfilePicture from '../Images/man.png';
|
26
|
|
-import { useDispatch } from 'react-redux';
|
|
26
|
+import { useDispatch, useSelector } from 'react-redux';
|
27
|
27
|
import { removeToken } from '../Slices/tokenSlice';
|
28
|
28
|
|
29
|
29
|
const drawerWidth = 240;
|
30
|
30
|
const mdTheme = createTheme();
|
31
|
31
|
|
|
32
|
+function stringToColor(string) {
|
|
33
|
+ let hash = 0;
|
|
34
|
+ let i;
|
|
35
|
+ /* eslint-disable no-bitwise */
|
|
36
|
+ for (i = 0; i < string.length; i += 1) {
|
|
37
|
+ hash = string.charCodeAt(i) + ((hash << 5) - hash);
|
|
38
|
+ }
|
|
39
|
+
|
|
40
|
+ let color = '#';
|
|
41
|
+
|
|
42
|
+ for (i = 0; i < 3; i += 1) {
|
|
43
|
+ const value = (hash >> (i * 8)) & 0xff;
|
|
44
|
+ color += `00${value.toString(16)}`.slice(-2);
|
|
45
|
+ }
|
|
46
|
+ /* eslint-enable no-bitwise */
|
|
47
|
+ return color;
|
|
48
|
+}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+function stringAvatar(name) {
|
|
52
|
+ console.log("NAME: ", name)
|
|
53
|
+ return {
|
|
54
|
+ sx: {
|
|
55
|
+ bgcolor: stringToColor(name),
|
|
56
|
+ },
|
|
57
|
+ children: `${name.split(' ')[0][0]}${name.split(' ')[1][0]}`,
|
|
58
|
+ };
|
|
59
|
+}
|
|
60
|
+
|
32
|
61
|
const AppBar = styled(MuiAppBar, {
|
33
|
|
- shouldForwardProp: (prop) => prop !== 'open',
|
|
62
|
+ shouldForwardProp: (prop) => prop !== 'open',
|
34
|
63
|
})(({ theme, open }) => ({
|
35
|
|
- zIndex: theme.zIndex.drawer + 1,
|
|
64
|
+ zIndex: theme.zIndex.drawer + 1,
|
|
65
|
+ transition: theme.transitions.create(['width', 'margin'], {
|
|
66
|
+ easing: theme.transitions.easing.sharp,
|
|
67
|
+ duration: theme.transitions.duration.leavingScreen,
|
|
68
|
+ }),
|
|
69
|
+ ...(open && {
|
|
70
|
+ marginLeft: drawerWidth,
|
|
71
|
+ width: `calc(100% - ${drawerWidth}px)`,
|
36
|
72
|
transition: theme.transitions.create(['width', 'margin'], {
|
37
|
|
- easing: theme.transitions.easing.sharp,
|
38
|
|
- duration: theme.transitions.duration.leavingScreen,
|
39
|
|
- }),
|
40
|
|
- ...(open && {
|
41
|
|
- marginLeft: drawerWidth,
|
42
|
|
- width: `calc(100% - ${drawerWidth}px)`,
|
43
|
|
- transition: theme.transitions.create(['width', 'margin'], {
|
44
|
|
- easing: theme.transitions.easing.sharp,
|
45
|
|
- duration: theme.transitions.duration.enteringScreen,
|
46
|
|
- }),
|
|
73
|
+ easing: theme.transitions.easing.sharp,
|
|
74
|
+ duration: theme.transitions.duration.enteringScreen,
|
47
|
75
|
}),
|
|
76
|
+ }),
|
48
|
77
|
}));
|
49
|
78
|
|
50
|
79
|
|
51
|
|
-const Drawer = styled(MuiDrawer,
|
52
|
|
- { shouldForwardProp: (prop) => prop !== 'open' })(
|
|
80
|
+const Drawer = styled(MuiDrawer,
|
|
81
|
+ { shouldForwardProp: (prop) => prop !== 'open' })(
|
53
|
82
|
({ theme, open }) => ({
|
54
|
|
- '& .MuiDrawer-paper': {
|
55
|
|
- position: 'relative',
|
56
|
|
- whiteSpace: 'nowrap',
|
57
|
|
- width: drawerWidth,
|
58
|
|
- transition: theme.transitions.create('width', {
|
59
|
|
- easing: theme.transitions.easing.sharp,
|
60
|
|
- duration: theme.transitions.duration.enteringScreen,
|
61
|
|
- }),
|
62
|
|
- boxSizing: 'border-box',
|
63
|
|
- ...(!open && {
|
64
|
|
- overflowX: 'hidden',
|
65
|
|
- transition: theme.transitions.create('width', {
|
66
|
|
- easing: theme.transitions.easing.sharp,
|
67
|
|
- duration: theme.transitions.duration.leavingScreen,
|
68
|
|
- }),
|
69
|
|
- width: theme.spacing(7),
|
70
|
|
- [theme.breakpoints.up('sm')]: {
|
71
|
|
- width: theme.spacing(9),
|
72
|
|
- },
|
73
|
|
- }),
|
74
|
|
- },
|
|
83
|
+ '& .MuiDrawer-paper': {
|
|
84
|
+ position: 'relative',
|
|
85
|
+ whiteSpace: 'nowrap',
|
|
86
|
+ width: drawerWidth,
|
|
87
|
+ transition: theme.transitions.create('width', {
|
|
88
|
+ easing: theme.transitions.easing.sharp,
|
|
89
|
+ duration: theme.transitions.duration.enteringScreen,
|
|
90
|
+ }),
|
|
91
|
+ boxSizing: 'border-box',
|
|
92
|
+ ...(!open && {
|
|
93
|
+ overflowX: 'hidden',
|
|
94
|
+ transition: theme.transitions.create('width', {
|
|
95
|
+ easing: theme.transitions.easing.sharp,
|
|
96
|
+ duration: theme.transitions.duration.leavingScreen,
|
|
97
|
+ }),
|
|
98
|
+ width: theme.spacing(7),
|
|
99
|
+ [theme.breakpoints.up('sm')]: {
|
|
100
|
+ width: theme.spacing(9),
|
|
101
|
+ },
|
|
102
|
+ }),
|
|
103
|
+ },
|
75
|
104
|
}),
|
76
|
|
-);
|
|
105
|
+ );
|
77
|
106
|
|
78
|
107
|
|
79
|
108
|
function DashboardContent() {
|
|
@@ -83,25 +112,29 @@ function DashboardContent() {
|
83
|
112
|
const isMovil = Size('(max-width:1000px)');
|
84
|
113
|
const dispatch = useDispatch();
|
85
|
114
|
const navigate = useNavigate()
|
|
115
|
+ const profile = useSelector((state) => state.recluter.info)
|
|
116
|
+ console.log('PROFILE: ', profile)
|
86
|
117
|
|
87
|
118
|
const CerrarSession = () => {
|
|
119
|
+ //TODO:
|
|
120
|
+ //remove all status
|
88
|
121
|
dispatch(removeToken())
|
89
|
122
|
navigate('/')
|
90
|
123
|
}
|
91
|
124
|
|
92
|
125
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
93
|
126
|
const open_profile = Boolean(anchorEl);
|
94
|
|
- const handleClick = (event) => setAnchorEl(event.currentTarget);
|
|
127
|
+ const handleClick = (event) => setAnchorEl(event.currentTarget);
|
95
|
128
|
const handleClose = () => setAnchorEl(null)
|
96
|
129
|
const toggleDrawer = () => {
|
97
|
|
- if(isMovil){
|
|
130
|
+ if (isMovil) {
|
98
|
131
|
setAnchorElMov(!anchorElMovil)
|
99
|
|
- }else{
|
|
132
|
+ } else {
|
100
|
133
|
setOpen(!open);
|
101
|
134
|
}
|
102
|
135
|
}
|
103
|
136
|
const [anchorElMovil, setAnchorElMov] = React.useState(false);
|
104
|
|
- React.useEffect(() => isMovil ? setOpen(false) : null , [isMovil])
|
|
137
|
+ React.useEffect(() => isMovil ? setOpen(false) : null, [isMovil])
|
105
|
138
|
|
106
|
139
|
return (
|
107
|
140
|
<ThemeProvider theme={mdTheme}>
|
|
@@ -114,9 +147,8 @@ function DashboardContent() {
|
114
|
147
|
edge="start"
|
115
|
148
|
color="inherit"
|
116
|
149
|
aria-label="open drawer"
|
117
|
|
- // onClick={isMovil ? MenuResponsive : toggleDrawer}
|
118
|
150
|
onClick={toggleDrawer}
|
119
|
|
- sx={{ marginRight: '36px', ...( open && { display: 'none' }), }} >
|
|
151
|
+ sx={{ marginRight: '36px', ...(open && { display: 'none' }), }} >
|
120
|
152
|
<MenuIcon style={{
|
121
|
153
|
background: '#ec5e69',
|
122
|
154
|
fontSize: "40",
|
|
@@ -125,19 +157,19 @@ function DashboardContent() {
|
125
|
157
|
</IconButton>
|
126
|
158
|
<Typography component="h1" variant="h6" color="inherit" noWrap sx={{ flexGrow: 1 }} >
|
127
|
159
|
{
|
128
|
|
- open ? (
|
129
|
|
- <React.Fragment>
|
130
|
|
-
|
131
|
|
- <IconButton onClick={toggleDrawer}>
|
132
|
|
- <LeftKey/>
|
133
|
|
- </IconButton>
|
134
|
|
-
|
135
|
|
- <IconButton onClick={(event) => event.target.requestFullscreen()}>
|
136
|
|
- <FullscreenIcon style={{ paddinLeft: 15 }} />
|
137
|
|
- </IconButton>
|
138
|
|
- </React.Fragment>
|
139
|
|
- ) : undefined
|
140
|
|
- }
|
|
160
|
+ open ? (
|
|
161
|
+ <React.Fragment>
|
|
162
|
+
|
|
163
|
+ <IconButton onClick={toggleDrawer}>
|
|
164
|
+ <LeftKey />
|
|
165
|
+ </IconButton>
|
|
166
|
+
|
|
167
|
+ <IconButton onClick={(event) => event.target.requestFullscreen()}>
|
|
168
|
+ <FullscreenIcon style={{ paddinLeft: 15 }} />
|
|
169
|
+ </IconButton>
|
|
170
|
+ </React.Fragment>
|
|
171
|
+ ) : undefined
|
|
172
|
+ }
|
141
|
173
|
</Typography>
|
142
|
174
|
|
143
|
175
|
<Box sx={{ display: { xs: 'none', md: 'flex' } }}>
|
|
@@ -146,8 +178,8 @@ function DashboardContent() {
|
146
|
178
|
size="large"
|
147
|
179
|
aria-label="show 17 new notifications"
|
148
|
180
|
color="inherit">
|
149
|
|
- <Badge badgeContent={17} color="error">
|
150
|
|
- <NotificationsIcon style={{ color : '#212529' }}/>
|
|
181
|
+ <Badge badgeContent={1} color="error">
|
|
182
|
+ <NotificationsIcon style={{ color: '#212529' }} />
|
151
|
183
|
</Badge>
|
152
|
184
|
</IconButton>
|
153
|
185
|
|
|
@@ -161,7 +193,8 @@ function DashboardContent() {
|
161
|
193
|
onClick={handleClick}
|
162
|
194
|
color="inherit"
|
163
|
195
|
>
|
164
|
|
- <Avatar alt="Cindy Baker" src={ProfilePicture} />
|
|
196
|
+ {/* <Avatar alt="Cindy Baker" src={ProfilePicture} /> */ }
|
|
197
|
+ <Avatar {...stringAvatar(`${profile.nombre} ${profile.apelidos}`)} />
|
165
|
198
|
|
166
|
199
|
</IconButton>
|
167
|
200
|
<Menu
|
|
@@ -170,7 +203,7 @@ function DashboardContent() {
|
170
|
203
|
open={open_profile}
|
171
|
204
|
onClose={handleClose}
|
172
|
205
|
MenuListProps={{ 'aria-labelledby': 'basic-button', }}>
|
173
|
|
- <MenuItem onClick={() => navigate('/dashboard/configuraciones') }>Perfil</MenuItem>
|
|
206
|
+ <MenuItem onClick={() => navigate('/dashboard/configuraciones')}>Perfil</MenuItem>
|
174
|
207
|
<MenuItem onClick={CerrarSession}>Cerrar Sesion</MenuItem>
|
175
|
208
|
</Menu>
|
176
|
209
|
</Box>
|
|
@@ -211,6 +244,6 @@ function DashboardContent() {
|
211
|
244
|
}
|
212
|
245
|
|
213
|
246
|
export function Dashboard() {
|
214
|
|
- return <DashboardContent />;
|
|
247
|
+ return <DashboardContent />;
|
215
|
248
|
}
|
216
|
249
|
|