Reac front end for psicometric app

Prueba.jsx 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React, { useMemo, useState } from 'react';
  2. import { useParams } from 'react-router-dom'
  3. import { Service } from '../Utils/HTTP'
  4. import useAuth from '../Auth/useAuth.js';
  5. import { Box, Paper, Divider, Typography, Button } from '@mui/material'
  6. export function Prueba() {
  7. let { id } = useParams();
  8. let auth = useAuth();
  9. let token = useMemo(() => auth.getToken())
  10. let [data, setData] = useState({});
  11. useState(() => {
  12. let rest = new Service(`/prueba/findid/${id}`)
  13. rest.get(token)
  14. .then(resp => setData(resp.data))
  15. .catch( _e => setData({}))
  16. }, [id])
  17. const CreateAssign = () => {
  18. let now = new Date().toISOString();
  19. let user = auth.getProfile();
  20. let body = {
  21. "id": -1,
  22. "fechaasignacio": now,
  23. "fechafinexamen": now,
  24. "estado": "1",
  25. "score" : "0",
  26. "mensaje" : "0",
  27. "mensaje2" : "0",
  28. "idcontrasenia": user.password,
  29. "nombre": "assing CLEVAERR"
  30. }
  31. console.log(body)
  32. }
  33. return (
  34. <div className="content-section">
  35. <div className="main">
  36. <Box >
  37. <Paper className="prueba_body" elevation={1}>
  38. <h1>{data.nombre}</h1>
  39. <Divider/>
  40. <Typography style={{marginTop:15, textAlign: 'center'}}>{data.decription}</Typography>
  41. <Divider style={{marginTop:15}}/>
  42. <Button onClick={CreateAssign}>Inicar Prueba</Button>
  43. </Paper>
  44. </Box>
  45. </div>
  46. </div>
  47. );
  48. }