Przeglądaj źródła

check test in dashboard

amenpunk 3 lat temu
rodzic
commit
09c1dd66e7
4 zmienionych plików z 118 dodań i 15 usunięć
  1. 8 0
      src/App.css
  2. 40 0
      src/Components/HomeUser/TestCard.jsx
  3. 62 13
      src/Pages/HomeUser.jsx
  4. 8 2
      src/Pages/Logincs.jsx

+ 8 - 0
src/App.css

@@ -275,3 +275,11 @@
     color : var(--main);
     margin :5px;
 }
+
+.test_list{
+    max-height: 500px;
+    display : flex;
+}
+
+
+

+ 40 - 0
src/Components/HomeUser/TestCard.jsx

@@ -0,0 +1,40 @@
+import * as React from 'react';
+import {
+    Box, Card, CardActions, CardContent, Button, Typography,
+    CardMedia, CardActionArea,
+} from '@mui/material'
+
+import QA from '../../Images/puesto.jpg'
+
+export function TestCard(props) {
+
+    let { test } = props;
+    console.log("TEST :: ", test)
+
+    return (
+        <Card sx={{ maxWidth: 500, maxHeight : 500 }}>
+            <CardActionArea>
+                <CardMedia
+                    component="img"
+                    height="140"
+                    image={QA}
+                    alt="green iguana"
+                />
+                <CardContent>
+                    <Typography gutterBottom variant="h5" component="div">
+                        {test.nombre}
+                    </Typography>
+                    <Typography variant="body2" color="text.secondary">
+                        {test.descripcion}
+                    </Typography>
+                </CardContent>
+            </CardActionArea>
+            <CardActions>
+                <Button size="small" color="primary">
+                    Realizar
+                </Button>
+            </CardActions>
+        </Card>
+    )
+
+}

+ 62 - 13
src/Pages/HomeUser.jsx

@@ -1,19 +1,68 @@
-import { 
-    Typography, Button
-} from '@mui/material';
+import { useState, useEffect, useRef  } from 'react';
+import { Typography, Button, Box, Paper, Divider } from '@mui/material';
+
+import useAuth from '../Auth/useAuth.js'
+import { Service } from '../Utils/HTTP.js';
+
+import { TestCard } from '../Components/HomeUser/TestCard';
 
 export function HomeUser(){
-    return (
-        <div>
-            <Typography paragraph>
-                Bienvenido User
-            </Typography>
-            <div>
-                <Button onClick={() => console.log("close")} 
-                    variant="contained">
-                    Cerrar Session
-                </Button>
+
+    const auth = useAuth();
+    const token = useRef(auth.getToken());
+    const [tests, setTests] = useState([]);
+
+    useEffect(() => {
+
+        let { email , password} = auth.getProfile();
+        let rest = new Service(`/plaza/contrasenia/${password}/${email}`);
+        rest
+        .get(token.current)
+            .then(({ data }) => {
+                console.log("data >>> ", data)
+                setTests(data.tests)
+            })
+            .catch(erro => {
+                console.error("ERR : ", erro)
+            })
+
+    },[auth])
+
+    return(
+        <div className="content-section">
+            <div className="main">
+                <Box sx={{ width: '100%' }}>
+                    <Paper elevation={0} sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh', boxShadow: 'none !important' }}>
+                        <h2>
+                            Bienvenido al sistemas de pruebas psicometricas.
+                        </h2>
+                        <h3>Instrucciones Generales</h3>
+                        <Typography>
+                             Bienvenido, el sistema tiene como objetivo evaluar diferentes caracteristicas como  medir y cuantificar los procesos cognoscitivos de la mente humana.
+
+                            Parar resolver las pruebas que estan asignadas te recomendamos busques un lugar apropiado ya que necesitaras  en promedio 2 horas libre y es importante que se tenga el 100% de tu concentracion.
+
+                        </Typography>
+
+                        <Divider style={{margin : 5}}/>
+
+                        <div className="test_list" style={{ marginTop :15 }}> 
+                            {
+                            tests.map( test => {
+                                return (
+                                    <TestCard key={test.id} test={test} />
+                                )
+                            })
+                            }
+                        </div>
+
+
+
+                    </Paper>
+                    <Button  onClick={auth.logout}>Salir</Button>
+                </Box>
             </div>
         </div>
     )
+
 }

+ 8 - 2
src/Pages/Logincs.jsx

@@ -51,6 +51,10 @@ export function LoginCs() {
         validationSchema: LoginSchema,
         onSubmit: async (values) => {
 
+            //
+            // QW5hbGlzdGEgZGUgY29tcHJhcw==
+            //
+            
             let { email, password } = values
             setOpen(true)
 
@@ -60,7 +64,7 @@ export function LoginCs() {
                 .then(response => {
 
                     console.log("Service Response :: ", response)
-                    let { token, nombre, apelidos, empresa } = response;
+                    let { token, nombre, apelidos} = response;
                     toast.success(`Bienvenido ${nombre} ${apelidos}!!`)
                     token = token.replace("Bearer ", "")
                     console.log(token);
@@ -72,7 +76,9 @@ export function LoginCs() {
                     // let restante = timestamp - Date.now();
 
                     // setTimeout(() => alert("Token Expirado"), restante)
-                    auth.setProfile(empresa)
+                    auth.setProfile({
+                        email, password
+                    })
                     auth.setRole(body_token)
 
                     setTimeout(() => {