Browse Source

fixes esteticos

amenpunk 2 years ago
parent
commit
1f0e3655b9
4 changed files with 210 additions and 210 deletions
  1. 2 31
      src/Components/Dashboard.js
  2. 3 0
      src/Components/Routes.js
  3. 178 179
      src/Components/User.jsx
  4. 27 0
      src/Utils/avatar.jsx

+ 2 - 31
src/Components/Dashboard.js

15
 } from '@mui/icons-material'
15
 } from '@mui/icons-material'
16
 
16
 
17
 import Logo from '../Images/evaluacion.jpeg';
17
 import Logo from '../Images/evaluacion.jpeg';
18
+import { stringAvatar } from '../Utils/avatar'
18
 
19
 
19
 import { Outlet, useNavigate } from "react-router-dom";
20
 import { Outlet, useNavigate } from "react-router-dom";
20
 import { MenuMovil } from '../Components/Navigation/MenuMovil';
21
 import { MenuMovil } from '../Components/Navigation/MenuMovil';
29
 const drawerWidth = 240;
30
 const drawerWidth = 240;
30
 const mdTheme = createTheme();
31
 const mdTheme = createTheme();
31
 
32
 
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
 
33
 
61
 const AppBar = styled(MuiAppBar, {
34
 const AppBar = styled(MuiAppBar, {
62
   shouldForwardProp: (prop) => prop !== 'open',
35
   shouldForwardProp: (prop) => prop !== 'open',
76
   }),
49
   }),
77
 }));
50
 }));
78
 
51
 
79
-
80
 const Drawer = styled(MuiDrawer,
52
 const Drawer = styled(MuiDrawer,
81
   { shouldForwardProp: (prop) => prop !== 'open' })(
53
   { shouldForwardProp: (prop) => prop !== 'open' })(
82
     ({ theme, open }) => ({
54
     ({ theme, open }) => ({
104
     }),
76
     }),
105
   );
77
   );
106
 
78
 
107
-
108
 function DashboardContent() {
79
 function DashboardContent() {
109
 
80
 
110
   const [open, setOpen] = React.useState(false);
81
   const [open, setOpen] = React.useState(false);
193
                 onClick={handleClick}
164
                 onClick={handleClick}
194
                 color="inherit"
165
                 color="inherit"
195
               >
166
               >
196
-                {/* <Avatar alt="Cindy Baker" src={ProfilePicture} /> */ }
167
+                {/* <Avatar alt="Cindy Baker" src={ProfilePicture} /> */}
197
                 <Avatar {...stringAvatar(`${profile.nombre} ${profile.apelidos}`)} />
168
                 <Avatar {...stringAvatar(`${profile.nombre} ${profile.apelidos}`)} />
198
 
169
 
199
               </IconButton>
170
               </IconButton>

+ 3 - 0
src/Components/Routes.js

43
             <User />
43
             <User />
44
           </RequireUserToken>
44
           </RequireUserToken>
45
         } >
45
         } >
46
+        <Route path="default" element={<Default />} />
47
+        <Route path="default2" element={<Default />} />
46
         <Route path="home" element={<HomeUser />} />
48
         <Route path="home" element={<HomeUser />} />
49
+        <Route path="pruebas" element={<HomeUser />} />
47
         <Route path="prueba">
50
         <Route path="prueba">
48
           <Route path=":id" element={<Prueba />} />
51
           <Route path=":id" element={<Prueba />} />
49
           <Route path="" element={<Prueba />} />
52
           <Route path="" element={<Prueba />} />

+ 178 - 179
src/Components/User.jsx

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

+ 27 - 0
src/Utils/avatar.jsx

1
+function stringToColor(string) {
2
+  let hash = 0;
3
+  let i;
4
+  /* eslint-disable no-bitwise */
5
+  for (i = 0; i < string.length; i += 1) {
6
+    hash = string.charCodeAt(i) + ((hash << 5) - hash);
7
+  }
8
+
9
+  let color = '#';
10
+
11
+  for (i = 0; i < 3; i += 1) {
12
+    const value = (hash >> (i * 8)) & 0xff;
13
+    color += `00${value.toString(16)}`.slice(-2);
14
+  }
15
+  /* eslint-enable no-bitwise */
16
+  return color;
17
+}
18
+
19
+
20
+export function stringAvatar(name) {
21
+  return {
22
+    sx: {
23
+      bgcolor: stringToColor(name),
24
+    },
25
+    children: `${name.split(' ')[0][0]}${name.split(' ')[1][0]}`,
26
+  };
27
+}