瀏覽代碼

first new api changes

amenpunk 3 年之前
父節點
當前提交
ff1c844922

+ 5 - 2
src/Auth/AuthProvider.js

5
 
5
 
6
 export function AuthProvider ({ children }){
6
 export function AuthProvider ({ children }){
7
 
7
 
8
-    let [user, setUser] = React.useState( Cookies.get('token') )
8
+    let [user, setUser] = React.useState( Cookies.get('token') );
9
+    let [profile, setProfile] = React.useState({});
9
 
10
 
10
     const context = {
11
     const context = {
11
         user,
12
         user,
40
                 console.log("Error checking user ", e)
41
                 console.log("Error checking user ", e)
41
                 return false
42
                 return false
42
             }
43
             }
43
-        }
44
+        },
45
+        setProfile :(obj) => setProfile(obj),
46
+        getProfile: () => profile
44
     }
47
     }
45
 
48
 
46
     return (
49
     return (

+ 40 - 39
src/Components/Dashboard.js

1
 import React from 'react';
1
 import React from 'react';
2
 import { ThemeProvider } from '@mui/material/styles';
2
 import { ThemeProvider } from '@mui/material/styles';
3
 
3
 
4
-import { 
5
-    Menu,MenuItem,Container,Avatar, Badge,IconButton,Divider,
6
-    Typography, List, Toolbar, Box, CssBaseline,useMediaQuery as Size,
4
+import {
5
+    Menu, MenuItem, Container, Avatar, Badge, IconButton, Divider,
6
+    Typography, List, Toolbar, Box, CssBaseline, useMediaQuery as Size,
7
 } from '@mui/material'
7
 } from '@mui/material'
8
 
8
 
9
 import {
9
 import {
15
 import Logo from '../Images/logo.png';
15
 import Logo from '../Images/logo.png';
16
 import ProfilePicture from '../Images/man.png';
16
 import ProfilePicture from '../Images/man.png';
17
 
17
 
18
-import { Outlet, useNavigate} from "react-router-dom";
18
+import { Outlet, useNavigate } from "react-router-dom";
19
 import { MenuMovil } from '../Components/Navigation/MenuMovil';
19
 import { MenuMovil } from '../Components/Navigation/MenuMovil';
20
 import Footer from "../Components/Footer";
20
 import Footer from "../Components/Footer";
21
 
21
 
26
 function DashboardContent() {
26
 function DashboardContent() {
27
 
27
 
28
     const [open, setOpen] = React.useState(false);
28
     const [open, setOpen] = React.useState(false);
29
+
29
     const isMovil = Size('(min-width:770px)');
30
     const isMovil = Size('(min-width:770px)');
30
     const auth = useAuth();
31
     const auth = useAuth();
31
     const navigate = useNavigate()
32
     const navigate = useNavigate()
46
         console.log('cerrando session')
47
         console.log('cerrando session')
47
         auth.logout();
48
         auth.logout();
48
         navigate('/')
49
         navigate('/')
49
-    } 
50
+    }
50
 
51
 
51
     return (
52
     return (
52
         <ThemeProvider theme={mdTheme}>
53
         <ThemeProvider theme={mdTheme}>
53
 
54
 
54
-            <MenuMovil 
55
+            <MenuMovil
55
                 anchor={anchorElMovil}
56
                 anchor={anchorElMovil}
56
                 control={setAnchorElMov} />
57
                 control={setAnchorElMov} />
57
 
58
 
58
             <Box sx={{ display: 'flex' }}>
59
             <Box sx={{ display: 'flex' }}>
59
-                <CssBaseline/>
60
-                <AppBar style={{ backgroundColor : '#fff', boxShadow : 'None' }} position="absolute" open={ !isMovil ? open : false}>
61
-                    <Toolbar sx={{ pr: '24px' ,  borderBottom : "1px solid #ec5e69"}} >
60
+                <CssBaseline />
61
+                <AppBar style={{ backgroundColor: '#fff', boxShadow: 'None' }} position="absolute" open={!isMovil ? open : false}>
62
+                    <Toolbar sx={{ pr: '24px', borderBottom: "1px solid #ec5e69" }} >
62
 
63
 
63
                         {/* boton para activar navegacion */}
64
                         {/* boton para activar navegacion */}
64
-                        <IconButton 
65
-                            edge="start" 
66
-                            color="inherit" 
67
-                            aria-label="open drawer" 
68
-                            onClick={ !isMovil ? MenuResponsive : toggleDrawer } 
69
-                            sx={{ marginRight: '36px', ...( !isMovil && open && { display: 'none' }), }} >
70
-                            <MenuIcon  style={{
65
+                        <IconButton
66
+                            edge="start"
67
+                            color="inherit"
68
+                            aria-label="open drawer"
69
+                            onClick={!isMovil ? MenuResponsive : toggleDrawer}
70
+                            sx={{ marginRight: '36px', ...(!isMovil && open && { display: 'none' }), }} >
71
+                            <MenuIcon style={{
71
                                 background: '#ec5e69',
72
                                 background: '#ec5e69',
72
                                 fontSize: "40",
73
                                 fontSize: "40",
73
                                 color: "#fff"
74
                                 color: "#fff"
74
-                            }}/>
75
+                            }} />
75
                         </IconButton>
76
                         </IconButton>
76
 
77
 
77
                         <Typography component="h1" variant="h6" color="inherit" noWrap sx={{ flexGrow: 1 }} >
78
                         <Typography component="h1" variant="h6" color="inherit" noWrap sx={{ flexGrow: 1 }} >
78
                             {
79
                             {
79
-                            !isMovil && open ? (
80
-                                <React.Fragment>
81
-
82
-                                    <IconButton onClick={toggleDrawer}>
83
-                                        <MenuIcon />
84
-                                    </IconButton>
85
-
86
-                                    <IconButton onClick={ (event) =>  event.target.requestFullscreen() }>
87
-                                        <FullscreenIcon style={{ paddinLeft : 15 }}/>
88
-                                    </IconButton>
89
-                                </React.Fragment>
90
-                            ) : undefined
91
-                        }
80
+                                !isMovil && open ? (
81
+                                    <React.Fragment>
82
+
83
+                                        <IconButton onClick={toggleDrawer}>
84
+                                            <MenuIcon />
85
+                                        </IconButton>
86
+
87
+                                        <IconButton onClick={(event) => event.target.requestFullscreen()}>
88
+                                            <FullscreenIcon style={{ paddinLeft: 15 }} />
89
+                                        </IconButton>
90
+                                    </React.Fragment>
91
+                                ) : undefined
92
+                            }
92
                         </Typography>
93
                         </Typography>
93
 
94
 
94
 
95
 
95
                         <Box sx={{ display: { xs: 'none', md: 'flex' } }}>
96
                         <Box sx={{ display: { xs: 'none', md: 'flex' } }}>
96
                             <IconButton size="large" aria-label="show 4 new mails" color="inherit">
97
                             <IconButton size="large" aria-label="show 4 new mails" color="inherit">
97
                                 <Badge badgeContent={4} color="error">
98
                                 <Badge badgeContent={4} color="error">
98
-                                    <MailIcon style={{ color : '#212529' }} />
99
+                                    <MailIcon style={{ color: '#212529' }} />
99
                                 </Badge>
100
                                 </Badge>
100
                             </IconButton>
101
                             </IconButton>
101
                             <IconButton
102
                             <IconButton
103
                                 aria-label="show 17 new notifications"
104
                                 aria-label="show 17 new notifications"
104
                                 color="inherit">
105
                                 color="inherit">
105
                                 <Badge badgeContent={17} color="error">
106
                                 <Badge badgeContent={17} color="error">
106
-                                    <NotificationsIcon style={{ color : '#212529' }}/>
107
+                                    <NotificationsIcon style={{ color: '#212529' }} />
107
                                 </Badge>
108
                                 </Badge>
108
                             </IconButton>
109
                             </IconButton>
109
 
110
 
116
                                 aria-expanded={open_profile ? 'true' : undefined}
117
                                 aria-expanded={open_profile ? 'true' : undefined}
117
                                 onClick={handleClick}
118
                                 onClick={handleClick}
118
                                 color="inherit" >
119
                                 color="inherit" >
119
-                            <Avatar alt="profile picture" src={ProfilePicture} />
120
+                                <Avatar alt="profile picture" src={ProfilePicture} />
120
                             </IconButton>
121
                             </IconButton>
121
                             <Menu
122
                             <Menu
122
                                 id="basic-menu"
123
                                 id="basic-menu"
124
                                 open={open_profile}
125
                                 open={open_profile}
125
                                 onClose={handleClose}
126
                                 onClose={handleClose}
126
                                 MenuListProps={{ 'aria-labelledby': 'basic-button', }}>
127
                                 MenuListProps={{ 'aria-labelledby': 'basic-button', }}>
127
-                                <MenuItem onClick={() => navigate('dashboard/perfil') }>Mi Cuenta</MenuItem>
128
+                                <MenuItem onClick={() => navigate('dashboard/perfil')}>Mi Cuenta</MenuItem>
128
                                 <MenuItem onClick={() => console.log('dashboard/perfil')}>Configuraciones</MenuItem>
129
                                 <MenuItem onClick={() => console.log('dashboard/perfil')}>Configuraciones</MenuItem>
129
-                                <MenuItem onClick={CerrarSession}>Logout</MenuItem>
130
+                                <MenuItem onClick={CerrarSession}>Cerrar Sesión</MenuItem>
130
                             </Menu>
131
                             </Menu>
131
                         </Box>
132
                         </Box>
132
                     </Toolbar>
133
                     </Toolbar>
139
                             justifyContent: 'flex-start',
140
                             justifyContent: 'flex-start',
140
                             px: [1]
141
                             px: [1]
141
                         }} >
142
                         }} >
142
-                        <div style={{ flat : 'righ' }} className="sidebar-header">
143
+                        <div style={{ flat: 'righ' }} className="sidebar-header">
143
                             <div className="width_img">
144
                             <div className="width_img">
144
-                                <img src={Logo} alt="pruebas psicometricas"/>
145
+                                <img src={Logo} alt="pruebas psicometricas" />
145
                             </div>
146
                             </div>
146
                         </div>
147
                         </div>
147
                     </Toolbar>
148
                     </Toolbar>
154
                         {SecondaryListItems}
155
                         {SecondaryListItems}
155
                     </List>
156
                     </List>
156
                 </Drawer>
157
                 </Drawer>
157
-                <Container maxWidth="lg" sx={{ mt: 2 , mb: 2 }}>
158
-                    <Outlet  />
158
+                <Container maxWidth="lg" sx={{ mt: 2, mb: 2 }}>
159
+                    <Outlet />
159
                     <Footer />
160
                     <Footer />
160
                 </Container>
161
                 </Container>
161
             </Box>
162
             </Box>

+ 0 - 1
src/Components/Modal/AgregarManual.js

158
                                     id="filled-multiline-static"
158
                                     id="filled-multiline-static"
159
                                     multiline
159
                                     multiline
160
                                     rows={4}
160
                                     rows={4}
161
-                                    defaultValue="Default Value"
162
                                     variant="filled"
161
                                     variant="filled"
163
                                     label="Notas"
162
                                     label="Notas"
164
                                     fullWidth
163
                                     fullWidth

+ 2 - 1
src/Components/Modal/MostrarPlaza.js

1
 import React from 'react';
1
 import React from 'react';
2
 import { Modal, Col, Row } from 'react-bootstrap'
2
 import { Modal, Col, Row } from 'react-bootstrap'
3
+import QA from '../../Images/puesto.jpg'
3
 
4
 
4
 export default function Mostrar(props) {
5
 export default function Mostrar(props) {
5
 
6
 
21
                     <Row >
22
                     <Row >
22
                         <Col md="4">
23
                         <Col md="4">
23
                             <div className="img-container">
24
                             <div className="img-container">
24
-                                <img alt='not found cooo' src={"https://yt3.ggpht.com/ytc/AKedOLRgmxVvijEuMGpaELK2ukM5QGGZYdnLLt065bh4=s900-c-k-c0x00ffffff-no-rj"}/>
25
+                                <img alt='not found cooo' src={QA}/>
25
                             </div>
26
                             </div>
26
                         </Col>
27
                         </Col>
27
                         <Col md="8">
28
                         <Col md="8">

+ 3 - 1
src/Components/Puestos/Card.jsx

6
 import Button from '@mui/material/Button';
6
 import Button from '@mui/material/Button';
7
 import Typography from '@mui/material/Typography';
7
 import Typography from '@mui/material/Typography';
8
 
8
 
9
+import QA from '../../Images/puesto.jpg'
10
+
9
 export function PuestoCard(props) {
11
 export function PuestoCard(props) {
10
 
12
 
11
     let {nombre, description} = props.plaza
13
     let {nombre, description} = props.plaza
17
                 component="img"
19
                 component="img"
18
                 alt="green iguana"
20
                 alt="green iguana"
19
                 height="140"
21
                 height="140"
20
-                image="https://yt3.ggpht.com/ytc/AKedOLRgmxVvijEuMGpaELK2ukM5QGGZYdnLLt065bh4=s900-c-k-c0x00ffffff-no-rj"
22
+                image={QA}
21
                 />
23
                 />
22
             <CardContent>
24
             <CardContent>
23
                 <Typography gutterBottom variant="h5" component="div">
25
                 <Typography gutterBottom variant="h5" component="div">

+ 3 - 3
src/Components/Puestos/ListMode.jsx

37
                                             <TableCell
37
                                             <TableCell
38
                                                 sx={{
38
                                                 sx={{
39
                                                     "display":'flex',
39
                                                     "display":'flex',
40
-                                                    "flex-direction":'row',
41
-                                                    "justify-content": "space-between",
42
-                                                    "flex-wrap": !isMovil ? "wrap": "nowrap",
40
+                                                    "flexDirection":'row',
41
+                                                    "justifyContent": "space-between",
42
+                                                    "flexWrap": !isMovil ? "wrap": "nowrap",
43
                                                 }} 
43
                                                 }} 
44
                                                 className="actions_butons_plaza"> 
44
                                                 className="actions_butons_plaza"> 
45
                                                 <Button 
45
                                                 <Button 

二進制
src/Images/puesto.jpg


+ 10 - 16
src/Pages/Home.jsx

1
 import { Col, Row } from 'react-bootstrap'
1
 import { Col, Row } from 'react-bootstrap'
2
-import React, { } from 'react'
2
+import React, { useEffect, useState } from 'react'
3
 
3
 
4
 import { PersonOutline, VerifiedUser, ListAlt  } from '@mui/icons-material/'
4
 import { PersonOutline, VerifiedUser, ListAlt  } from '@mui/icons-material/'
5
 
5
 
7
 import Candidatos from '../Components/Home/Candidatos'
7
 import Candidatos from '../Components/Home/Candidatos'
8
 import { Card } from '../Components/Card';
8
 import { Card } from '../Components/Card';
9
 
9
 
10
-// import useAuth from '../Auth/useAuth';
11
-// import { Service } from '../Utils/HTTP.js';
10
+import useAuth from '../Auth/useAuth';
12
 
11
 
13
 export function Home() {
12
 export function Home() {
14
 
13
 
15
-    /*
16
-    let auth = useAuth();
14
+    const auth = useAuth();
15
+    const [nombre, setNombre] = useState(null);
16
+
17
     useEffect(() => {
17
     useEffect(() => {
18
-        let token = auth.getToken();
19
-        let myService = new Service("/persona/view");
20
-        myService.get(token)
21
-        .then( ({data}) => {
22
-            console.log('Home Response :: ', data)
23
-        }).catch(e => {
24
-            console.log('Error Response :: ', e)
25
-        })
26
-    } ,[])
27
-*/
18
+        let { nombre: empresa } = auth.getProfile();
19
+        setNombre(empresa)
20
+    }, [auth])
21
+
28
 
22
 
29
     return (
23
     return (
30
         <section >
24
         <section >
31
             <div className="content-section">
25
             <div className="content-section">
32
                 <div className="main">
26
                 <div className="main">
33
-                    <h1>Bienvenido de nuevo Grupo DIT</h1>
27
+                    <h1>Bienvenido de nuevo {nombre}</h1>
34
                     <div className="panel_options">
28
                     <div className="panel_options">
35
                         <Row>
29
                         <Row>
36
                             <Col md="4">
30
                             <Col md="4">

+ 2 - 8
src/Pages/Login.jsx

59
             .then( response => {
59
             .then( response => {
60
 
60
 
61
                 console.log("Service Response :: ", response)
61
                 console.log("Service Response :: ", response)
62
-                let { token, nombre, apelidos } = response;
62
+                let { token, nombre, apelidos, empresa } = response;
63
                 toast.success(`Bienvenido ${nombre} ${apelidos}!!`)
63
                 toast.success(`Bienvenido ${nombre} ${apelidos}!!`)
64
                 token = token.replace("Bearer ", "")
64
                 token = token.replace("Bearer ", "")
65
                     console.log(token);
65
                     console.log(token);
69
                 let restante = timestamp - Date.now();
69
                 let restante = timestamp - Date.now();
70
 
70
 
71
                 setTimeout(() => alert("Token Expirado") , restante )
71
                 setTimeout(() => alert("Token Expirado") , restante )
72
-
73
-                // console.log(exp * 1000)
74
-                // console.log(Date.now())
75
-                // let token_expire_in = new Date(new Date(1656562738 * 1000))
76
-                // let token_expire_in = new Date( exp * 1000)
77
-                // console.log("TOKEN EXP :: ",token_expire_in)
78
-                // console.log("Bearer ", token)
72
+                auth.setProfile(empresa)
79
 
73
 
80
                 setTimeout( () => {
74
                 setTimeout( () => {
81
                     setOpen(false)
75
                     setOpen(false)