Reac front end for psicometric app

Candidatos.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import React, { useState, useEffect } from 'react';
  2. import UpdateIcon from '@mui/icons-material/Update';
  3. import {
  4. Typography, Pagination, Stack,
  5. // CircularProgress, Box
  6. } from '@mui/material'
  7. import { Row, Col } from 'react-bootstrap';
  8. import { Candidato, Preview } from './Candidato'
  9. // const USER_LENGTH = 14
  10. const USER_LENGTH = 120
  11. function Divide(arregloOriginal){
  12. const LONGITUD_PEDAZOS = 8;
  13. let arregloDeArreglos = [];
  14. for (let i = 0; i < arregloOriginal.length; i += LONGITUD_PEDAZOS) {
  15. let pedazo = arregloOriginal.slice(i, i + LONGITUD_PEDAZOS);
  16. arregloDeArreglos.push(pedazo);
  17. }
  18. return arregloDeArreglos
  19. }
  20. export default function Candidatos () {
  21. const [page, setPage] = useState(1);
  22. const [users, setUser] = useState([]);
  23. const changePage = ( _ , value) => {
  24. let page_numer = value;
  25. Divide(users)
  26. setPage(page_numer);
  27. };
  28. useEffect(() => {
  29. setTimeout(() => {
  30. let list = [{
  31. password : 'tester',
  32. puesto : "Piloto Repartidor",
  33. DPI : 0,
  34. // aplicacion : "27/12/2018 12:02 PM",
  35. aplicacion : new Date().toUTCString(),
  36. pendientes : "No"
  37. }]
  38. let a = 1;
  39. for( let _ of new Array(USER_LENGTH) ){
  40. if(_) break
  41. let temp = {
  42. ...list[0],
  43. DPI : a * 1000,
  44. password : Math.random().toString(36).slice(5),
  45. aplicacion : new Date(10,12,a).toUTCString(),
  46. }
  47. a=a+1;
  48. list.push(temp)
  49. }
  50. let divided = Divide(list);
  51. setUser(divided)
  52. },3000)
  53. }, [])
  54. return (
  55. <div className="body_historial">
  56. <div className="header_historial">
  57. <UpdateIcon style={{ color : "white", fontSize : 25, margin : 0, marginRight: 15, marginLeft :15 }}/>
  58. <p className="titlie_main">HISTORIAL DE ACCESO DE CANDIDATOS</p>
  59. </div>
  60. <div className="content_historial">
  61. <p>Últimos candidatos que han ingresado al sistema:</p>
  62. <div className="cabeceras">
  63. <Row>
  64. <div className="col20"><p>Contraseña</p></div>
  65. <div className="col20"><p>Puesto</p> </div>
  66. <div className="col20"><p>No. Identificación</p></div>
  67. <div className="col20"><p>Fecha de aplicación</p></div>
  68. <div className="col20"><p>Pruebas Pendientes</p></div>
  69. </Row>
  70. </div>
  71. {
  72. users.length
  73. ? users[page - 1].map( user => (<Candidato key={user.DPI} user={user}/>))
  74. : <Preview lenght={10}/>
  75. }
  76. <Row style={{ padding : 5 }}>
  77. <Col>
  78. <Stack style={{ display : 'flex', flexDirection : 'row', alignItems: 'baseline' }} spacing={2}>
  79. <Typography style={{ paddingTop : 15, paddingRight : 10 }}>Page: {page}</Typography>
  80. <Pagination
  81. siblingCount={5}
  82. shape='rounded'
  83. count={users.length}
  84. page={page}
  85. onChange={changePage} />
  86. </Stack>
  87. </Col>
  88. </Row>
  89. </div>
  90. </div>
  91. )
  92. }