Explorar el Código

first new api changes

amenpunk hace 3 años
padre
commit
ff1c844922

+ 5 - 2
src/Auth/AuthProvider.js

@@ -5,7 +5,8 @@ export const AuthContext = React.createContext(null);
 
 export function AuthProvider ({ children }){
 
-    let [user, setUser] = React.useState( Cookies.get('token') )
+    let [user, setUser] = React.useState( Cookies.get('token') );
+    let [profile, setProfile] = React.useState({});
 
     const context = {
         user,
@@ -40,7 +41,9 @@ export function AuthProvider ({ children }){
                 console.log("Error checking user ", e)
                 return false
             }
-        }
+        },
+        setProfile :(obj) => setProfile(obj),
+        getProfile: () => profile
     }
 
     return (

+ 40 - 39
src/Components/Dashboard.js

@@ -1,9 +1,9 @@
 import React from 'react';
 import { ThemeProvider } from '@mui/material/styles';
 
-import { 
-    Menu,MenuItem,Container,Avatar, Badge,IconButton,Divider,
-    Typography, List, Toolbar, Box, CssBaseline,useMediaQuery as Size,
+import {
+    Menu, MenuItem, Container, Avatar, Badge, IconButton, Divider,
+    Typography, List, Toolbar, Box, CssBaseline, useMediaQuery as Size,
 } from '@mui/material'
 
 import {
@@ -15,7 +15,7 @@ import useAuth from '../Auth/useAuth';
 import Logo from '../Images/logo.png';
 import ProfilePicture from '../Images/man.png';
 
-import { Outlet, useNavigate} from "react-router-dom";
+import { Outlet, useNavigate } from "react-router-dom";
 import { MenuMovil } from '../Components/Navigation/MenuMovil';
 import Footer from "../Components/Footer";
 
@@ -26,6 +26,7 @@ import { MainListItems, SecondaryListItems } from '../Components/Navigation/list
 function DashboardContent() {
 
     const [open, setOpen] = React.useState(false);
+
     const isMovil = Size('(min-width:770px)');
     const auth = useAuth();
     const navigate = useNavigate()
@@ -46,56 +47,56 @@ function DashboardContent() {
         console.log('cerrando session')
         auth.logout();
         navigate('/')
-    } 
+    }
 
     return (
         <ThemeProvider theme={mdTheme}>
 
-            <MenuMovil 
+            <MenuMovil
                 anchor={anchorElMovil}
                 control={setAnchorElMov} />
 
             <Box sx={{ display: 'flex' }}>
-                <CssBaseline/>
-                <AppBar style={{ backgroundColor : '#fff', boxShadow : 'None' }} position="absolute" open={ !isMovil ? open : false}>
-                    <Toolbar sx={{ pr: '24px' ,  borderBottom : "1px solid #ec5e69"}} >
+                <CssBaseline />
+                <AppBar style={{ backgroundColor: '#fff', boxShadow: 'None' }} position="absolute" open={!isMovil ? open : false}>
+                    <Toolbar sx={{ pr: '24px', borderBottom: "1px solid #ec5e69" }} >
 
                         {/* boton para activar navegacion */}
-                        <IconButton 
-                            edge="start" 
-                            color="inherit" 
-                            aria-label="open drawer" 
-                            onClick={ !isMovil ? MenuResponsive : toggleDrawer } 
-                            sx={{ marginRight: '36px', ...( !isMovil && open && { display: 'none' }), }} >
-                            <MenuIcon  style={{
+                        <IconButton
+                            edge="start"
+                            color="inherit"
+                            aria-label="open drawer"
+                            onClick={!isMovil ? MenuResponsive : toggleDrawer}
+                            sx={{ marginRight: '36px', ...(!isMovil && open && { display: 'none' }), }} >
+                            <MenuIcon style={{
                                 background: '#ec5e69',
                                 fontSize: "40",
                                 color: "#fff"
-                            }}/>
+                            }} />
                         </IconButton>
 
                         <Typography component="h1" variant="h6" color="inherit" noWrap sx={{ flexGrow: 1 }} >
                             {
-                            !isMovil && open ? (
-                                <React.Fragment>
-
-                                    <IconButton onClick={toggleDrawer}>
-                                        <MenuIcon />
-                                    </IconButton>
-
-                                    <IconButton onClick={ (event) =>  event.target.requestFullscreen() }>
-                                        <FullscreenIcon style={{ paddinLeft : 15 }}/>
-                                    </IconButton>
-                                </React.Fragment>
-                            ) : undefined
-                        }
+                                !isMovil && open ? (
+                                    <React.Fragment>
+
+                                        <IconButton onClick={toggleDrawer}>
+                                            <MenuIcon />
+                                        </IconButton>
+
+                                        <IconButton onClick={(event) => event.target.requestFullscreen()}>
+                                            <FullscreenIcon style={{ paddinLeft: 15 }} />
+                                        </IconButton>
+                                    </React.Fragment>
+                                ) : undefined
+                            }
                         </Typography>
 
 
                         <Box sx={{ display: { xs: 'none', md: 'flex' } }}>
                             <IconButton size="large" aria-label="show 4 new mails" color="inherit">
                                 <Badge badgeContent={4} color="error">
-                                    <MailIcon style={{ color : '#212529' }} />
+                                    <MailIcon style={{ color: '#212529' }} />
                                 </Badge>
                             </IconButton>
                             <IconButton
@@ -103,7 +104,7 @@ function DashboardContent() {
                                 aria-label="show 17 new notifications"
                                 color="inherit">
                                 <Badge badgeContent={17} color="error">
-                                    <NotificationsIcon style={{ color : '#212529' }}/>
+                                    <NotificationsIcon style={{ color: '#212529' }} />
                                 </Badge>
                             </IconButton>
 
@@ -116,7 +117,7 @@ function DashboardContent() {
                                 aria-expanded={open_profile ? 'true' : undefined}
                                 onClick={handleClick}
                                 color="inherit" >
-                            <Avatar alt="profile picture" src={ProfilePicture} />
+                                <Avatar alt="profile picture" src={ProfilePicture} />
                             </IconButton>
                             <Menu
                                 id="basic-menu"
@@ -124,9 +125,9 @@ function DashboardContent() {
                                 open={open_profile}
                                 onClose={handleClose}
                                 MenuListProps={{ 'aria-labelledby': 'basic-button', }}>
-                                <MenuItem onClick={() => navigate('dashboard/perfil') }>Mi Cuenta</MenuItem>
+                                <MenuItem onClick={() => navigate('dashboard/perfil')}>Mi Cuenta</MenuItem>
                                 <MenuItem onClick={() => console.log('dashboard/perfil')}>Configuraciones</MenuItem>
-                                <MenuItem onClick={CerrarSession}>Logout</MenuItem>
+                                <MenuItem onClick={CerrarSession}>Cerrar Sesión</MenuItem>
                             </Menu>
                         </Box>
                     </Toolbar>
@@ -139,9 +140,9 @@ function DashboardContent() {
                             justifyContent: 'flex-start',
                             px: [1]
                         }} >
-                        <div style={{ flat : 'righ' }} className="sidebar-header">
+                        <div style={{ flat: 'righ' }} className="sidebar-header">
                             <div className="width_img">
-                                <img src={Logo} alt="pruebas psicometricas"/>
+                                <img src={Logo} alt="pruebas psicometricas" />
                             </div>
                         </div>
                     </Toolbar>
@@ -154,8 +155,8 @@ function DashboardContent() {
                         {SecondaryListItems}
                     </List>
                 </Drawer>
-                <Container maxWidth="lg" sx={{ mt: 2 , mb: 2 }}>
-                    <Outlet  />
+                <Container maxWidth="lg" sx={{ mt: 2, mb: 2 }}>
+                    <Outlet />
                     <Footer />
                 </Container>
             </Box>

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

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

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

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

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

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

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

@@ -37,9 +37,9 @@ export function ListMode(props) {
                                             <TableCell
                                                 sx={{
                                                     "display":'flex',
-                                                    "flex-direction":'row',
-                                                    "justify-content": "space-between",
-                                                    "flex-wrap": !isMovil ? "wrap": "nowrap",
+                                                    "flexDirection":'row',
+                                                    "justifyContent": "space-between",
+                                                    "flexWrap": !isMovil ? "wrap": "nowrap",
                                                 }} 
                                                 className="actions_butons_plaza"> 
                                                 <Button 

BIN
src/Images/puesto.jpg


+ 10 - 16
src/Pages/Home.jsx

@@ -1,5 +1,5 @@
 import { Col, Row } from 'react-bootstrap'
-import React, { } from 'react'
+import React, { useEffect, useState } from 'react'
 
 import { PersonOutline, VerifiedUser, ListAlt  } from '@mui/icons-material/'
 
@@ -7,30 +7,24 @@ import Actividades from '../Components/Home/Actividades'
 import Candidatos from '../Components/Home/Candidatos'
 import { Card } from '../Components/Card';
 
-// import useAuth from '../Auth/useAuth';
-// import { Service } from '../Utils/HTTP.js';
+import useAuth from '../Auth/useAuth';
 
 export function Home() {
 
-    /*
-    let auth = useAuth();
+    const auth = useAuth();
+    const [nombre, setNombre] = useState(null);
+
     useEffect(() => {
-        let token = auth.getToken();
-        let myService = new Service("/persona/view");
-        myService.get(token)
-        .then( ({data}) => {
-            console.log('Home Response :: ', data)
-        }).catch(e => {
-            console.log('Error Response :: ', e)
-        })
-    } ,[])
-*/
+        let { nombre: empresa } = auth.getProfile();
+        setNombre(empresa)
+    }, [auth])
+
 
     return (
         <section >
             <div className="content-section">
                 <div className="main">
-                    <h1>Bienvenido de nuevo Grupo DIT</h1>
+                    <h1>Bienvenido de nuevo {nombre}</h1>
                     <div className="panel_options">
                         <Row>
                             <Col md="4">

+ 2 - 8
src/Pages/Login.jsx

@@ -59,7 +59,7 @@ export function Login() {
             .then( response => {
 
                 console.log("Service Response :: ", response)
-                let { token, nombre, apelidos } = response;
+                let { token, nombre, apelidos, empresa } = response;
                 toast.success(`Bienvenido ${nombre} ${apelidos}!!`)
                 token = token.replace("Bearer ", "")
                     console.log(token);
@@ -69,13 +69,7 @@ export function Login() {
                 let restante = timestamp - Date.now();
 
                 setTimeout(() => alert("Token Expirado") , restante )
-
-                // console.log(exp * 1000)
-                // console.log(Date.now())
-                // let token_expire_in = new Date(new Date(1656562738 * 1000))
-                // let token_expire_in = new Date( exp * 1000)
-                // console.log("TOKEN EXP :: ",token_expire_in)
-                // console.log("Bearer ", token)
+                auth.setProfile(empresa)
 
                 setTimeout( () => {
                     setOpen(false)