Browse Source

test from produccion

amenpunk 3 years ago
parent
commit
6dbe9de39b

+ 19 - 31
src/Components/Dashboard.js

1
 import React, { useEffect, useState, useRef } from 'react';
1
 import React, { useEffect, useState, useRef } from 'react';
2
 import { styled, createTheme, ThemeProvider } from '@mui/material/styles';
2
 import { styled, createTheme, ThemeProvider } from '@mui/material/styles';
3
-import CssBaseline from '@mui/material/CssBaseline';
4
-import MuiDrawer from '@mui/material/Drawer';
5
-import Box from '@mui/material/Box';
6
-import MuiAppBar from '@mui/material/AppBar';
7
-import Toolbar from '@mui/material/Toolbar';
8
-import List from '@mui/material/List';
9
-import Typography from '@mui/material/Typography';
10
-import Divider from '@mui/material/Divider';
11
-import IconButton from '@mui/material/IconButton';
12
-import Badge from '@mui/material/Badge';
13
-import Container from '@mui/material/Container';
14
-import Avatar from '@mui/material/Avatar';
15
-
16
-import MenuIcon from '@mui/icons-material/Menu';
17
-import FullscreenIcon from '@mui/icons-material/Fullscreen';
18
-
19
-import NotificationsIcon from '@mui/icons-material/Notifications';
20
-import { MainListItems, secondaryListItems } from './listItems';
21
-
22
-import Menu from '@mui/material/Menu';
23
-import MenuItem from '@mui/material/MenuItem';
24
 
3
 
4
+import { MainListItems, secondaryListItems } from './listItems';
5
+import { 
6
+    Menu,MenuItem,Container,Avatar, Badge,IconButton,Divider,
7
+    Typography, List, Toolbar, AppBar as MuiAppBar, Box, Drawer as MuiDrawer,
8
+    CssBaseline
9
+} from '@mui/material'
25
 
10
 
26
-import MailIcon from '@mui/icons-material/Mail';
11
+import {
12
+    Mail as MailIcon, Notifications as NotificationsIcon, Fullscreen as FullscreenIcon,
13
+    Menu as MenuIcon,
14
+} from '@mui/icons-material'
27
 
15
 
28
 import Logo from '../Images/logo.png';
16
 import Logo from '../Images/logo.png';
29
 import ProfilePicture from '../Images/man.png';
17
 import ProfilePicture from '../Images/man.png';
30
 
18
 
31
 import useAuth from '../Auth/useAuth';
19
 import useAuth from '../Auth/useAuth';
32
 import { Outlet, useNavigate} from "react-router-dom";
20
 import { Outlet, useNavigate} from "react-router-dom";
21
+import { MenuMovil } from '../Components/MenuMovil';
33
 import Footer from "../Components/Footer";
22
 import Footer from "../Components/Footer";
34
 
23
 
35
 
24
 
140
                     <Toolbar sx={{ pr: '24px' ,  borderBottom : "1px solid #ec5e69"}} >
129
                     <Toolbar sx={{ pr: '24px' ,  borderBottom : "1px solid #ec5e69"}} >
141
 
130
 
142
                         <div ref={elRef}>
131
                         <div ref={elRef}>
132
+
143
                             <IconButton 
133
                             <IconButton 
144
                                 edge="start" 
134
                                 edge="start" 
145
                                 color="inherit" 
135
                                 color="inherit" 
153
                                 }}/>
143
                                 }}/>
154
                             </IconButton>
144
                             </IconButton>
155
 
145
 
156
-                            <Menu
146
+
147
+
148
+                            <MenuMovil
157
                                 id="basic-menu"
149
                                 id="basic-menu"
158
                                 anchorEl={anchorElMovil}
150
                                 anchorEl={anchorElMovil}
159
                                 open={openMov}
151
                                 open={openMov}
160
                                 onClose={handleCloseMov}
152
                                 onClose={handleCloseMov}
161
-                                MenuListProps={{
162
-                                    'aria-labelledby': 'basic-button',
163
-                                }}>
164
-                                <MenuItem onClick={ () => navigate('/perfil') }>Perfil</MenuItem>
165
-                                <MenuItem onClick={handleCloseMov}>My account</MenuItem>
166
-                                <MenuItem onClick={handleCloseMov}>Logout</MenuItem>
167
-                            </Menu>
153
+                                out={CerrarSession}
154
+                                MenuListProps={{ 'aria-labelledby': 'basic-button', }}
155
+                            />
168
 
156
 
169
                         </div>
157
                         </div>
170
 
158
 
222
                                 open={open_profile}
210
                                 open={open_profile}
223
                                 onClose={handleClose}
211
                                 onClose={handleClose}
224
                                 MenuListProps={{ 'aria-labelledby': 'basic-button', }}>
212
                                 MenuListProps={{ 'aria-labelledby': 'basic-button', }}>
225
-                                <MenuItem onClick={() => navigate('perfil') }>Profile</MenuItem>
213
+                                <MenuItem onClick={() => navigate('dashboard/perfil') }>Profile</MenuItem>
226
                                 <MenuItem onClick={() => console.log('opcion 2')}>My account</MenuItem>
214
                                 <MenuItem onClick={() => console.log('opcion 2')}>My account</MenuItem>
227
                                 <MenuItem onClick={CerrarSession}>Logout</MenuItem>
215
                                 <MenuItem onClick={CerrarSession}>Logout</MenuItem>
228
                             </Menu>
216
                             </Menu>

+ 44 - 32
src/Components/Home/Candidatos.js

1
 import React, { useState, useEffect } from 'react';
1
 import React, { useState, useEffect } from 'react';
2
 
2
 
3
 import UpdateIcon from '@mui/icons-material/Update';
3
 import UpdateIcon from '@mui/icons-material/Update';
4
-import Typography from '@mui/material/Typography';
5
-import Pagination from '@mui/material/Pagination';
6
-import Stack from '@mui/material/Stack';
4
+
5
+import {
6
+    Typography, Pagination, Stack, CircularProgress, Box
7
+} from '@mui/material'
8
+
7
 import { Row, Col } from 'react-bootstrap';
9
 import { Row, Col } from 'react-bootstrap';
8
 
10
 
9
 import { Candidato } from './Candidato'
11
 import { Candidato } from './Candidato'
10
-const USER_LENGTH = 14
12
+// const USER_LENGTH = 14
13
+const USER_LENGTH = 99
11
 
14
 
12
 
15
 
13
 function Divide(arregloOriginal){
16
 function Divide(arregloOriginal){
14
-    const LONGITUD_PEDAZOS = 5;
15
-	let arregloDeArreglos = [];
17
+    const LONGITUD_PEDAZOS = 10;
18
+    let arregloDeArreglos = [];
16
     for (let i = 0; i < arregloOriginal.length; i += LONGITUD_PEDAZOS) {
19
     for (let i = 0; i < arregloOriginal.length; i += LONGITUD_PEDAZOS) {
17
         let pedazo = arregloOriginal.slice(i, i + LONGITUD_PEDAZOS);
20
         let pedazo = arregloOriginal.slice(i, i + LONGITUD_PEDAZOS);
18
         arregloDeArreglos.push(pedazo);
21
         arregloDeArreglos.push(pedazo);
19
     }
22
     }
20
-    console.log(arregloDeArreglos)
21
     return arregloDeArreglos
23
     return arregloDeArreglos
22
 }
24
 }
23
 
25
 
36
 
38
 
37
     useEffect(() => {
39
     useEffect(() => {
38
 
40
 
39
-        let list =  [{
40
-            password :'repartidor',
41
-            puesto : "Piloto Repartidor",
42
-            DPI : 0,
43
-            // aplicacion : "27/12/2018 12:02 PM",
44
-            aplicacion : new Date().toUTCString(),
45
-            pendientes : "No"
46
-        }]
47
-
48
-        let a = 1;
49
-        for( let _ of new Array(USER_LENGTH)  ){
50
-            if(_) break
51
-
52
-            let temp = {
53
-                ...list[0],
54
-                DPI : a * 1000
41
+        setTimeout(() => {
42
+
43
+
44
+            let list =  [{
45
+                password : 'tester',
46
+                puesto : "Piloto Repartidor",
47
+                DPI : 0,
48
+                // aplicacion : "27/12/2018 12:02 PM",
49
+                aplicacion : new Date().toUTCString(),
50
+                pendientes : "No"
51
+            }]
52
+
53
+            let a = 1;
54
+            for( let _ of new Array(USER_LENGTH)  ){
55
+                if(_) break
56
+
57
+                let temp = {
58
+                    ...list[0],
59
+                    DPI : a * 1000,
60
+                    password : Math.random().toString(36).slice(5), 
61
+                    aplicacion : new Date(10,12,a).toUTCString(),
62
+                }
63
+
64
+                a=a+1;
65
+                list.push(temp)
55
             }
66
             }
56
 
67
 
57
-            a=a+1;
58
-            list.push(temp)
59
-        }
68
+            let divided = Divide(list);
60
 
69
 
61
-        let divided = Divide(list);
62
-        console.log('DIVDED 0 >> ',JSON.stringify( divided[0] ))
70
+            setUser(divided)
63
 
71
 
64
-        setUser(divided)
72
+        },3000)
65
 
73
 
66
     }, [])
74
     }, [])
67
 
75
 
86
                 </div>
94
                 </div>
87
                 {
95
                 {
88
                     users.length ?
96
                     users.length ?
89
-                    users[page - 1]
90
-                    .map( user => (<Candidato key={user.DPI} user={user}/>)) 
91
-                    : undefined
97
+                    users[page - 1] .map( user => (<Candidato key={user.DPI} user={user}/>)) 
98
+                    : 
99
+                        <center>
100
+                            <Box sx={{ display: 'flex', padding : '5%',  maginTop : 100,  }}> 
101
+                                <CircularProgress /> 
102
+                            </Box>
103
+                        </center>
92
                 }
104
                 }
93
                 <Row style={{ padding : 5 }}>
105
                 <Row style={{ padding : 5 }}>
94
                     <Col>
106
                     <Col>

+ 25 - 29
src/Components/MenuMovil.js

1
-import * as React from 'react';
2
-import Menu from '@mui/material/Menu';
3
-import MenuItem from '@mui/material/MenuItem';
1
+import { Menu,MenuItem } from '@mui/material';
2
+import {  useNavigate} from "react-router-dom";
4
 
3
 
5
-export default function MenuMovil(props) {
4
+export function MenuMovil(props) {
6
 
5
 
7
-    const [anchorEl, setAnchorEl] = React.useState(props.open);
8
-    const open = Boolean(anchorEl);
6
+    const navigate = useNavigate()
9
 
7
 
10
-    const handleClick = (event) => {
11
-        setAnchorEl(event.currentTarget);
12
-    };
13
-    const handleClose = () => {
14
-        console.log('cerrando el componente')
15
-        // setAnchorEl(null);
16
-    };
17
-
18
-    return (
19
-        <div>
20
-            <Menu
21
-                id="basic-menu"
22
-                anchorEl={anchorEl}
23
-                open={open}
24
-                onClose={handleClose}
25
-                MenuListProps={{ 'aria-labelledby': 'basic-button', }}
26
-            >
27
-                <MenuItem onClick={handleClose}>Profile</MenuItem>
28
-                <MenuItem onClick={handleClose}>My account</MenuItem>
29
-                <MenuItem onClick={handleClose}>Logout</MenuItem>
30
-            </Menu>
31
-        </div>
32
-    );
8
+    let {onClose : handleCloseMov, anchorEl, open, out } =  props;
33
 
9
 
10
+    return(
11
+        <Menu
12
+            id="basic-menu"
13
+            anchorEl={anchorEl}
14
+            open={open}
15
+            onClose={handleCloseMov}
16
+            MenuListProps={{ 'aria-labelledby': 'basic-button' }}>
17
+            <MenuItem onClick={() => navigate('/')}>Home</MenuItem>
18
+            <MenuItem onClick={ () => navigate('perfil') }>Perfil</MenuItem>
19
+            <MenuItem onClick={handleCloseMov}>Shit</MenuItem>
20
+            <MenuItem onClick={handleCloseMov}>Shit</MenuItem>
21
+            <MenuItem onClick={handleCloseMov}>Shit</MenuItem>
22
+            <MenuItem onClick={handleCloseMov}>Shit</MenuItem>
23
+            <MenuItem onClick={handleCloseMov}>Shit</MenuItem>
24
+            <MenuItem onClick={handleCloseMov}>Shit</MenuItem>
25
+            <MenuItem onClick={handleCloseMov}>Shit</MenuItem>
26
+            <MenuItem onClick={out}>Logout</MenuItem>
27
+        </Menu>
28
+    )
34
 }
29
 }
30
+

+ 16 - 12
src/Components/listItems.js

19
     let resolved = useResolvedPath(props.route);
19
     let resolved = useResolvedPath(props.route);
20
     let match = useMatch({ path: resolved.pathname, end: true });
20
     let match = useMatch({ path: resolved.pathname, end: true });
21
 
21
 
22
+    let { title, route, icon, open, AppBarVisible, setOpen } = props
23
+
24
+    if(route.startsWith('prueba') && match && open && !AppBarVisible ){
25
+        setOpen(false);
26
+        // setAppBarVisible(true)
27
+    }
28
+
29
+
22
     return(
30
     return(
23
         <ListItem
31
         <ListItem
24
             sx={{ color : '#25344f'}}
32
             sx={{ color : '#25344f'}}
25
             selected={ match && typeof(match) === "object" }
33
             selected={ match && typeof(match) === "object" }
26
-            onClick={() => navigate(props.route) } 
34
+            onClick={() => navigate(route) } 
27
             button
35
             button
28
         >
36
         >
29
             <ListItemIcon>
37
             <ListItemIcon>
30
-                {props.icon && props.icon}
38
+                {icon && icon}
31
             </ListItemIcon>
39
             </ListItemIcon>
32
             <ListItemText 
40
             <ListItemText 
33
                 sx={{
41
                 sx={{
36
                         fontSize : '.875rem'
44
                         fontSize : '.875rem'
37
                     },
45
                     },
38
                 }}
46
                 }}
39
-                primary={props.title} 
47
+                primary={title} 
40
             />
48
             />
41
         </ListItem>
49
         </ListItem>
42
     )
50
     )
45
 
53
 
46
 export const MainListItems = (props) =>  {
54
 export const MainListItems = (props) =>  {
47
 
55
 
48
-    /* TODO
49
-     *   only show submenu when is complete 
50
-     */
51
-
52
     const [open, setOpen] = React.useState(false);
56
     const [open, setOpen] = React.useState(false);
53
 
57
 
54
     const showPruebas = () => {
58
     const showPruebas = () => {
91
             <Collapse in={open} timeout="auto" unmountOnExit>
95
             <Collapse in={open} timeout="auto" unmountOnExit>
92
                 <List component="div" disablePadding>
96
                 <List component="div" disablePadding>
93
 
97
 
94
-                    <NavItem route="pruebas/crear" title="Crear Prueba" />
95
-                    <NavItem route="pruebas/listar"  title="Listado de pruebas" />
96
-                    <NavItem route="pruebas/aplicar"  title="Aplicar" />
97
-                    <NavItem route="pruebas/respuestas" title="Respuestas" />
98
-                    <NavItem route="pruebas/calificaciones" title="Calificaciones" />
98
+                    <NavItem setOpen={setOpen} { ...props} open={open} route="pruebas/crear" title="Crear Prueba" />
99
+                    <NavItem setOpen={setOpen} { ...props} open={open} route="pruebas/listar"  title="Listado de pruebas" />
100
+                    <NavItem setOpen={setOpen} { ...props} open={open} route="pruebas/aplicar"  title="Aplicar" />
101
+                    <NavItem setOpen={setOpen} { ...props} open={open} route="pruebas/respuestas" title="Respuestas" />
102
+                    <NavItem setOpen={setOpen} { ...props} open={open} route="pruebas/calificaciones" title="Calificaciones" />
99
 
103
 
100
                 </List>
104
                 </List>
101
             </Collapse>
105
             </Collapse>

+ 2 - 1
src/Pages/Login.jsx

35
 const theme = createTheme();
35
 const theme = createTheme();
36
 
36
 
37
 export function Login() {
37
 export function Login() {
38
+
38
     let auth = useAuth();
39
     let auth = useAuth();
39
     let navigate = useNavigate()
40
     let navigate = useNavigate()
40
 
41
 
53
             // toast.success('Bienvenido!!')
54
             // toast.success('Bienvenido!!')
54
             // toast.error("This didn't work.")
55
             // toast.error("This didn't work.")
55
             // return navigate('/dashboard/home')
56
             // return navigate('/dashboard/home')
56
-            // auth.login(values)
57
+            auth.login(values)
57
         },
58
         },
58
     });
59
     });
59
 
60