|
@@ -1,4 +1,4 @@
|
1
|
|
-import React, { useState } from 'react';
|
|
1
|
+import React, { useState, useEffect } from 'react';
|
2
|
2
|
|
3
|
3
|
import UpdateIcon from '@mui/icons-material/Update';
|
4
|
4
|
import Typography from '@mui/material/Typography';
|
|
@@ -7,30 +7,65 @@ import Stack from '@mui/material/Stack';
|
7
|
7
|
import { Row, Col } from 'react-bootstrap';
|
8
|
8
|
|
9
|
9
|
import { Candidato } from './Candidato'
|
|
10
|
+const USER_LENGTH = 14
|
10
|
11
|
|
11
|
|
-export default function Candidatos () {
|
12
|
12
|
|
13
|
|
- let list = [{
|
14
|
|
- password :'repartidor',
|
15
|
|
- puesto : "Piloto Repartidor",
|
16
|
|
- DPI : 1583266600501,
|
17
|
|
- aplicacion : "27/12/2018 12:02 PM",
|
18
|
|
- pendientes : "No"
|
19
|
|
- }]
|
20
|
|
-
|
21
|
|
- for( let _ of new Array(8) ){
|
22
|
|
- if(_) break
|
23
|
|
- list.push( list[0] )
|
|
13
|
+function Divide(arregloOriginal){
|
|
14
|
+ const LONGITUD_PEDAZOS = 5;
|
|
15
|
+ let arregloDeArreglos = [];
|
|
16
|
+ for (let i = 0; i < arregloOriginal.length; i += LONGITUD_PEDAZOS) {
|
|
17
|
+ let pedazo = arregloOriginal.slice(i, i + LONGITUD_PEDAZOS);
|
|
18
|
+ arregloDeArreglos.push(pedazo);
|
24
|
19
|
}
|
|
20
|
+ console.log(arregloDeArreglos)
|
|
21
|
+ return arregloDeArreglos
|
|
22
|
+}
|
|
23
|
+
|
|
24
|
+export default function Candidatos () {
|
25
|
25
|
|
26
|
26
|
const [page, setPage] = useState(1);
|
27
|
|
- // const [users, setUser] = useState(list);
|
28
|
|
- // const [curret, setCurrent] = useState([]);
|
|
27
|
+ const [users, setUser] = useState([]);
|
29
|
28
|
|
30
|
|
- const changePage = ( _ , value) => { if(_)
|
31
|
|
- setPage(value);
|
|
29
|
+ const changePage = ( _ , value) => {
|
|
30
|
+
|
|
31
|
+ let page_numer = value;
|
|
32
|
+
|
|
33
|
+ Divide(users)
|
|
34
|
+ setPage(page_numer);
|
32
|
35
|
};
|
33
|
36
|
|
|
37
|
+ useEffect(() => {
|
|
38
|
+
|
|
39
|
+ let list = [{
|
|
40
|
+ password :'repartidor',
|
|
41
|
+ puesto : "Piloto Repartidor",
|
|
42
|
+ DPI : 0,
|
|
43
|
+ // aplicacion : "27/12/2018 12:02 PM",
|
|
44
|
+ aplicacion : new Date().toUTCString(),
|
|
45
|
+ pendientes : "No"
|
|
46
|
+ }]
|
|
47
|
+
|
|
48
|
+ let a = 1;
|
|
49
|
+ for( let _ of new Array(USER_LENGTH) ){
|
|
50
|
+ if(_) break
|
|
51
|
+
|
|
52
|
+ let temp = {
|
|
53
|
+ ...list[0],
|
|
54
|
+ DPI : a * 1000
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ a=a+1;
|
|
58
|
+ list.push(temp)
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+ let divided = Divide(list);
|
|
62
|
+ console.log('DIVDED 0 >> ',JSON.stringify( divided[0] ))
|
|
63
|
+
|
|
64
|
+ setUser(divided)
|
|
65
|
+
|
|
66
|
+ }, [])
|
|
67
|
+
|
|
68
|
+
|
34
|
69
|
|
35
|
70
|
return (
|
36
|
71
|
<div className="body_historial">
|
|
@@ -50,8 +85,9 @@ export default function Candidatos () {
|
50
|
85
|
</Row>
|
51
|
86
|
</div>
|
52
|
87
|
{
|
53
|
|
- list ?
|
54
|
|
- list.map( (user, index) => (<Candidato key={user.DPI + index} user={{ ...user, index }}/>))
|
|
88
|
+ users.length ?
|
|
89
|
+ users[page - 1]
|
|
90
|
+ .map( user => (<Candidato key={user.DPI} user={user}/>))
|
55
|
91
|
: undefined
|
56
|
92
|
}
|
57
|
93
|
<Row style={{ padding : 5 }}>
|
|
@@ -61,7 +97,7 @@ export default function Candidatos () {
|
61
|
97
|
<Pagination
|
62
|
98
|
siblingCount={5}
|
63
|
99
|
shape='rounded'
|
64
|
|
- count={list.length}
|
|
100
|
+ count={users.length}
|
65
|
101
|
page={page}
|
66
|
102
|
onChange={changePage} />
|
67
|
103
|
</Stack>
|