Browse Source

first new api changes

amenpunk 2 years ago
parent
commit
ff1c844922

+ 5 - 2
src/Auth/AuthProvider.js

@@ -5,7 +5,8 @@ export const AuthContext = React.createContext(null);
5 5
 
6 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 11
     const context = {
11 12
         user,
@@ -40,7 +41,9 @@ export function AuthProvider ({ children }){
40 41
                 console.log("Error checking user ", e)
41 42
                 return false
42 43
             }
43
-        }
44
+        },
45
+        setProfile :(obj) => setProfile(obj),
46
+        getProfile: () => profile
44 47
     }
45 48
 
46 49
     return (

+ 40 - 39
src/Components/Dashboard.js

@@ -1,9 +1,9 @@
1 1
 import React from 'react';
2 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 7
 } from '@mui/material'
8 8
 
9 9
 import {
@@ -15,7 +15,7 @@ import useAuth from '../Auth/useAuth';
15 15
 import Logo from '../Images/logo.png';
16 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 19
 import { MenuMovil } from '../Components/Navigation/MenuMovil';
20 20
 import Footer from "../Components/Footer";
21 21
 
@@ -26,6 +26,7 @@ import { MainListItems, SecondaryListItems } from '../Components/Navigation/list
26 26
 function DashboardContent() {
27 27
 
28 28
     const [open, setOpen] = React.useState(false);
29
+
29 30
     const isMovil = Size('(min-width:770px)');
30 31
     const auth = useAuth();
31 32
     const navigate = useNavigate()
@@ -46,56 +47,56 @@ function DashboardContent() {
46 47
         console.log('cerrando session')
47 48
         auth.logout();
48 49
         navigate('/')
49
-    } 
50
+    }
50 51
 
51 52
     return (
52 53
         <ThemeProvider theme={mdTheme}>
53 54
 
54
-            <MenuMovil 
55
+            <MenuMovil
55 56
                 anchor={anchorElMovil}
56 57
                 control={setAnchorElMov} />
57 58
 
58 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 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 72
                                 background: '#ec5e69',
72 73
                                 fontSize: "40",
73 74
                                 color: "#fff"
74
-                            }}/>
75
+                            }} />
75 76
                         </IconButton>
76 77
 
77 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 93
                         </Typography>
93 94
 
94 95
 
95 96
                         <Box sx={{ display: { xs: 'none', md: 'flex' } }}>
96 97
                             <IconButton size="large" aria-label="show 4 new mails" color="inherit">
97 98
                                 <Badge badgeContent={4} color="error">
98
-                                    <MailIcon style={{ color : '#212529' }} />
99
+                                    <MailIcon style={{ color: '#212529' }} />
99 100
                                 </Badge>
100 101
                             </IconButton>
101 102
                             <IconButton
@@ -103,7 +104,7 @@ function DashboardContent() {
103 104
                                 aria-label="show 17 new notifications"
104 105
                                 color="inherit">
105 106
                                 <Badge badgeContent={17} color="error">
106
-                                    <NotificationsIcon style={{ color : '#212529' }}/>
107
+                                    <NotificationsIcon style={{ color: '#212529' }} />
107 108
                                 </Badge>
108 109
                             </IconButton>
109 110
 
@@ -116,7 +117,7 @@ function DashboardContent() {
116 117
                                 aria-expanded={open_profile ? 'true' : undefined}
117 118
                                 onClick={handleClick}
118 119
                                 color="inherit" >
119
-                            <Avatar alt="profile picture" src={ProfilePicture} />
120
+                                <Avatar alt="profile picture" src={ProfilePicture} />
120 121
                             </IconButton>
121 122
                             <Menu
122 123
                                 id="basic-menu"
@@ -124,9 +125,9 @@ function DashboardContent() {
124 125
                                 open={open_profile}
125 126
                                 onClose={handleClose}
126 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 129
                                 <MenuItem onClick={() => console.log('dashboard/perfil')}>Configuraciones</MenuItem>
129
-                                <MenuItem onClick={CerrarSession}>Logout</MenuItem>
130
+                                <MenuItem onClick={CerrarSession}>Cerrar Sesión</MenuItem>
130 131
                             </Menu>
131 132
                         </Box>
132 133
                     </Toolbar>
@@ -139,9 +140,9 @@ function DashboardContent() {
139 140
                             justifyContent: 'flex-start',
140 141
                             px: [1]
141 142
                         }} >
142
-                        <div style={{ flat : 'righ' }} className="sidebar-header">
143
+                        <div style={{ flat: 'righ' }} className="sidebar-header">
143 144
                             <div className="width_img">
144
-                                <img src={Logo} alt="pruebas psicometricas"/>
145
+                                <img src={Logo} alt="pruebas psicometricas" />
145 146
                             </div>
146 147
                         </div>
147 148
                     </Toolbar>
@@ -154,8 +155,8 @@ function DashboardContent() {
154 155
                         {SecondaryListItems}
155 156
                     </List>
156 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 160
                     <Footer />
160 161
                 </Container>
161 162
             </Box>

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

@@ -158,7 +158,6 @@ export default function Manual ( props ) {
158 158
                                     id="filled-multiline-static"
159 159
                                     multiline
160 160
                                     rows={4}
161
-                                    defaultValue="Default Value"
162 161
                                     variant="filled"
163 162
                                     label="Notas"
164 163
                                     fullWidth

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

@@ -1,5 +1,6 @@
1 1
 import React from 'react';
2 2
 import { Modal, Col, Row } from 'react-bootstrap'
3
+import QA from '../../Images/puesto.jpg'
3 4
 
4 5
 export default function Mostrar(props) {
5 6
 
@@ -21,7 +22,7 @@ export default function Mostrar(props) {
21 22
                     <Row >
22 23
                         <Col md="4">
23 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 26
                             </div>
26 27
                         </Col>
27 28
                         <Col md="8">

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

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

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

@@ -37,9 +37,9 @@ export function ListMode(props) {
37 37
                                             <TableCell
38 38
                                                 sx={{
39 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 44
                                                 className="actions_butons_plaza"> 
45 45
                                                 <Button 

BIN
src/Images/puesto.jpg


+ 10 - 16
src/Pages/Home.jsx

@@ -1,5 +1,5 @@
1 1
 import { Col, Row } from 'react-bootstrap'
2
-import React, { } from 'react'
2
+import React, { useEffect, useState } from 'react'
3 3
 
4 4
 import { PersonOutline, VerifiedUser, ListAlt  } from '@mui/icons-material/'
5 5
 
@@ -7,30 +7,24 @@ import Actividades from '../Components/Home/Actividades'
7 7
 import Candidatos from '../Components/Home/Candidatos'
8 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 12
 export function Home() {
14 13
 
15
-    /*
16
-    let auth = useAuth();
14
+    const auth = useAuth();
15
+    const [nombre, setNombre] = useState(null);
16
+
17 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 23
     return (
30 24
         <section >
31 25
             <div className="content-section">
32 26
                 <div className="main">
33
-                    <h1>Bienvenido de nuevo Grupo DIT</h1>
27
+                    <h1>Bienvenido de nuevo {nombre}</h1>
34 28
                     <div className="panel_options">
35 29
                         <Row>
36 30
                             <Col md="4">

+ 2 - 8
src/Pages/Login.jsx

@@ -59,7 +59,7 @@ export function Login() {
59 59
             .then( response => {
60 60
 
61 61
                 console.log("Service Response :: ", response)
62
-                let { token, nombre, apelidos } = response;
62
+                let { token, nombre, apelidos, empresa } = response;
63 63
                 toast.success(`Bienvenido ${nombre} ${apelidos}!!`)
64 64
                 token = token.replace("Bearer ", "")
65 65
                     console.log(token);
@@ -69,13 +69,7 @@ export function Login() {
69 69
                 let restante = timestamp - Date.now();
70 70
 
71 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 74
                 setTimeout( () => {
81 75
                     setOpen(false)