|
@@ -2,7 +2,13 @@ import React, { useState, useEffect } from 'react';
|
|
|
import { Row, Col } from 'react-bootstrap'
|
|
import { Row, Col } from 'react-bootstrap'
|
|
|
import toast, { Toaster } from 'react-hot-toast';
|
|
import toast, { Toaster } from 'react-hot-toast';
|
|
|
|
|
|
|
|
-import { ToggleButton, ToggleButtonGroup, Box, Paper } from '@mui/material';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ ToggleButton,
|
|
|
|
|
+ ToggleButtonGroup,
|
|
|
|
|
+ Box,
|
|
|
|
|
+ Paper,
|
|
|
|
|
+ Pagination,
|
|
|
|
|
+} from '@mui/material';
|
|
|
|
|
|
|
|
import { ViewList as ViewListIcon, ViewModule as ViewModuleIcon, } from '@mui/icons-material';
|
|
import { ViewList as ViewListIcon, ViewModule as ViewModuleIcon, } from '@mui/icons-material';
|
|
|
|
|
|
|
@@ -24,11 +30,29 @@ import { Add as AddIcon, } from '@mui/icons-material/'
|
|
|
const Success = () => toast.success('Plaza Agregada!!')
|
|
const Success = () => toast.success('Plaza Agregada!!')
|
|
|
const Error = () => toast.error('Ups creo que ocurrio un error, intentalo nuevamente')
|
|
const Error = () => toast.error('Ups creo que ocurrio un error, intentalo nuevamente')
|
|
|
|
|
|
|
|
|
|
+function Divide(arregloOriginal){
|
|
|
|
|
+ const LONGITUD_PEDAZOS = 9;
|
|
|
|
|
+ let arregloDeArreglos = [];
|
|
|
|
|
+ for (let i = 0; i < arregloOriginal.length; i += LONGITUD_PEDAZOS) {
|
|
|
|
|
+ let pedazo = arregloOriginal.slice(i, i + LONGITUD_PEDAZOS);
|
|
|
|
|
+ arregloDeArreglos.push(pedazo);
|
|
|
|
|
+ }
|
|
|
|
|
+ return arregloDeArreglos
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export function Puestos() {
|
|
export function Puestos() {
|
|
|
|
|
|
|
|
const auth = useAuth();
|
|
const auth = useAuth();
|
|
|
- const [data, setData] = useState({});
|
|
|
|
|
|
|
+ const [data, setData] = useState([]);
|
|
|
|
|
+ const [page, setPage] = useState(1);
|
|
|
const token = auth.getToken();
|
|
const token = auth.getToken();
|
|
|
|
|
+
|
|
|
|
|
+ const changePage = ( _ , value) => {
|
|
|
|
|
+ let page_numer = value;
|
|
|
|
|
+ // let divided = Divide(data)
|
|
|
|
|
+ setPage(page_numer);
|
|
|
|
|
+ // setData(divided)
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
|
|
|
@@ -46,7 +70,7 @@ export function Puestos() {
|
|
|
data: e
|
|
data: e
|
|
|
};
|
|
};
|
|
|
})
|
|
})
|
|
|
- setData(entries)
|
|
|
|
|
|
|
+ setData(Divide(entries))
|
|
|
})
|
|
})
|
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
|
console.log('error fetching data ', error );
|
|
console.log('error fetching data ', error );
|
|
@@ -54,12 +78,10 @@ export function Puestos() {
|
|
|
|
|
|
|
|
},[token])
|
|
},[token])
|
|
|
|
|
|
|
|
- const [alignment, setAlignment] = React.useState('list');
|
|
|
|
|
|
|
+ // const [alignment, setAlignment] = React.useState('list');
|
|
|
|
|
+ const [alignment, setAlignment] = React.useState('grid');
|
|
|
|
|
|
|
|
- const handleChange = (_event, newAlignment) => {
|
|
|
|
|
- console.log("new alignment :: ", newAlignment );
|
|
|
|
|
- setAlignment(newAlignment)
|
|
|
|
|
- } ;
|
|
|
|
|
|
|
+ const handleChange = (_event, newAlignment) => setAlignment(newAlignment)
|
|
|
|
|
|
|
|
const children = [
|
|
const children = [
|
|
|
<ToggleButton value="list" key="list">
|
|
<ToggleButton value="list" key="list">
|
|
@@ -78,7 +100,7 @@ export function Puestos() {
|
|
|
|
|
|
|
|
let [puesto, setPuesto] = React.useState(false);
|
|
let [puesto, setPuesto] = React.useState(false);
|
|
|
|
|
|
|
|
- let [manual, setManual] = React.useState(true);
|
|
|
|
|
|
|
+ let [manual, setManual] = React.useState(false);
|
|
|
let [expres, setExpress] = React.useState(false);
|
|
let [expres, setExpress] = React.useState(false);
|
|
|
|
|
|
|
|
let [edit, setEdit] = React.useState(false);
|
|
let [edit, setEdit] = React.useState(false);
|
|
@@ -89,7 +111,7 @@ export function Puestos() {
|
|
|
<div className="content-section">
|
|
<div className="content-section">
|
|
|
<div className="main">
|
|
<div className="main">
|
|
|
<Box sx={{ width: '100%' }}>
|
|
<Box sx={{ width: '100%' }}>
|
|
|
- <Paper sx={{ width: '100%', mb: 2, padding : 2, height: '95vh' }}>
|
|
|
|
|
|
|
+ <Paper sx={{ width: '100%', mb: 2, padding : 2, height: '100%', minHeight:'95vh' }}>
|
|
|
|
|
|
|
|
<Row style={{paddingBottom : 15}}>
|
|
<Row style={{paddingBottom : 15}}>
|
|
|
<Col md="2" sm="2" xs="2">
|
|
<Col md="2" sm="2" xs="2">
|
|
@@ -118,6 +140,7 @@ export function Puestos() {
|
|
|
<Row>
|
|
<Row>
|
|
|
<GridMode
|
|
<GridMode
|
|
|
data={data}
|
|
data={data}
|
|
|
|
|
+ index={page - 1}
|
|
|
setPuesto={setPuesto}
|
|
setPuesto={setPuesto}
|
|
|
setEdit={setEdit}
|
|
setEdit={setEdit}
|
|
|
setDelete={setDelete}
|
|
setDelete={setDelete}
|
|
@@ -129,6 +152,7 @@ export function Puestos() {
|
|
|
<Row>
|
|
<Row>
|
|
|
<ListMode
|
|
<ListMode
|
|
|
data={data}
|
|
data={data}
|
|
|
|
|
+ index={page -1}
|
|
|
setPuesto={setPuesto}
|
|
setPuesto={setPuesto}
|
|
|
setEdit={setEdit}
|
|
setEdit={setEdit}
|
|
|
setDelete={setDelete}
|
|
setDelete={setDelete}
|
|
@@ -137,6 +161,21 @@ export function Puestos() {
|
|
|
</Row>
|
|
</Row>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
+ <Pagination
|
|
|
|
|
+ sx={{
|
|
|
|
|
+ "& ul" :{
|
|
|
|
|
+ "padding-top" : "20px",
|
|
|
|
|
+ "justify-content": "center"
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
|
|
+ siblingCount={2}
|
|
|
|
|
+ boundaryCount={2}
|
|
|
|
|
+ shape='rounded'
|
|
|
|
|
+ count={data.length}
|
|
|
|
|
+ page={page}
|
|
|
|
|
+ onChange={changePage}
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
</Paper>
|
|
</Paper>
|
|
|
</Box>
|
|
</Box>
|
|
|
|
|
|