|
|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useState } from 'react';
|
|
|
+import React, { useState, useEffect } from 'react';
|
|
|
|
|
|
import UpdateIcon from '@mui/icons-material/Update';
|
|
|
import Typography from '@mui/material/Typography';
|
|
|
@@ -7,30 +7,65 @@ import Stack from '@mui/material/Stack';
|
|
|
import { Row, Col } from 'react-bootstrap';
|
|
|
|
|
|
import { Candidato } from './Candidato'
|
|
|
+const USER_LENGTH = 14
|
|
|
|
|
|
-export default function Candidatos () {
|
|
|
|
|
|
- let list = [{
|
|
|
- password :'repartidor',
|
|
|
- puesto : "Piloto Repartidor",
|
|
|
- DPI : 1583266600501,
|
|
|
- aplicacion : "27/12/2018 12:02 PM",
|
|
|
- pendientes : "No"
|
|
|
- }]
|
|
|
-
|
|
|
- for( let _ of new Array(8) ){
|
|
|
- if(_) break
|
|
|
- list.push( list[0] )
|
|
|
+function Divide(arregloOriginal){
|
|
|
+ const LONGITUD_PEDAZOS = 5;
|
|
|
+ let arregloDeArreglos = [];
|
|
|
+ for (let i = 0; i < arregloOriginal.length; i += LONGITUD_PEDAZOS) {
|
|
|
+ let pedazo = arregloOriginal.slice(i, i + LONGITUD_PEDAZOS);
|
|
|
+ arregloDeArreglos.push(pedazo);
|
|
|
}
|
|
|
+ console.log(arregloDeArreglos)
|
|
|
+ return arregloDeArreglos
|
|
|
+}
|
|
|
+
|
|
|
+export default function Candidatos () {
|
|
|
|
|
|
const [page, setPage] = useState(1);
|
|
|
- // const [users, setUser] = useState(list);
|
|
|
- // const [curret, setCurrent] = useState([]);
|
|
|
+ const [users, setUser] = useState([]);
|
|
|
|
|
|
- const changePage = ( _ , value) => { if(_)
|
|
|
- setPage(value);
|
|
|
+ const changePage = ( _ , value) => {
|
|
|
+
|
|
|
+ let page_numer = value;
|
|
|
+
|
|
|
+ Divide(users)
|
|
|
+ setPage(page_numer);
|
|
|
};
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+
|
|
|
+ let list = [{
|
|
|
+ password :'repartidor',
|
|
|
+ puesto : "Piloto Repartidor",
|
|
|
+ DPI : 0,
|
|
|
+ // aplicacion : "27/12/2018 12:02 PM",
|
|
|
+ aplicacion : new Date().toUTCString(),
|
|
|
+ pendientes : "No"
|
|
|
+ }]
|
|
|
+
|
|
|
+ let a = 1;
|
|
|
+ for( let _ of new Array(USER_LENGTH) ){
|
|
|
+ if(_) break
|
|
|
+
|
|
|
+ let temp = {
|
|
|
+ ...list[0],
|
|
|
+ DPI : a * 1000
|
|
|
+ }
|
|
|
+
|
|
|
+ a=a+1;
|
|
|
+ list.push(temp)
|
|
|
+ }
|
|
|
+
|
|
|
+ let divided = Divide(list);
|
|
|
+ console.log('DIVDED 0 >> ',JSON.stringify( divided[0] ))
|
|
|
+
|
|
|
+ setUser(divided)
|
|
|
+
|
|
|
+ }, [])
|
|
|
+
|
|
|
+
|
|
|
|
|
|
return (
|
|
|
<div className="body_historial">
|
|
|
@@ -50,8 +85,9 @@ export default function Candidatos () {
|
|
|
</Row>
|
|
|
</div>
|
|
|
{
|
|
|
- list ?
|
|
|
- list.map( (user, index) => (<Candidato key={user.DPI + index} user={{ ...user, index }}/>))
|
|
|
+ users.length ?
|
|
|
+ users[page - 1]
|
|
|
+ .map( user => (<Candidato key={user.DPI} user={user}/>))
|
|
|
: undefined
|
|
|
}
|
|
|
<Row style={{ padding : 5 }}>
|
|
|
@@ -61,7 +97,7 @@ export default function Candidatos () {
|
|
|
<Pagination
|
|
|
siblingCount={5}
|
|
|
shape='rounded'
|
|
|
- count={list.length}
|
|
|
+ count={users.length}
|
|
|
page={page}
|
|
|
onChange={changePage} />
|
|
|
</Stack>
|