|
@@ -4,10 +4,13 @@ import { Toaster } from 'react-hot-toast';
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
ToggleButton, ToggleButtonGroup, Box,
|
|
ToggleButton, ToggleButtonGroup, Box,
|
|
|
- Paper, Pagination, Chip
|
|
|
|
|
|
|
+ Paper, Pagination, Chip, TextField, InputAdornment,
|
|
|
} from '@mui/material';
|
|
} from '@mui/material';
|
|
|
|
|
|
|
|
-import { ViewList as ViewListIcon, ViewModule as ViewModuleIcon, } from '@mui/icons-material';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ ViewList as ViewListIcon, ViewModule as ViewModuleIcon,
|
|
|
|
|
+ Search as SearchIcon
|
|
|
|
|
+} from '@mui/icons-material';
|
|
|
|
|
|
|
|
import { Service } from '../Utils/HTTP';
|
|
import { Service } from '../Utils/HTTP';
|
|
|
import { Divide } from '../Utils/Paginate';
|
|
import { Divide } from '../Utils/Paginate';
|
|
@@ -33,6 +36,7 @@ export function Puestos() {
|
|
|
|
|
|
|
|
const auth = useSelector((state) => state.token)
|
|
const auth = useSelector((state) => state.token)
|
|
|
const [page, setPage] = useState(1);
|
|
const [page, setPage] = useState(1);
|
|
|
|
|
+ const [temp, setTemp] = useState(null);
|
|
|
|
|
|
|
|
const getAll = async () => {
|
|
const getAll = async () => {
|
|
|
let rest = new Service("/plaza/getall")
|
|
let rest = new Service("/plaza/getall")
|
|
@@ -67,9 +71,9 @@ export function Puestos() {
|
|
|
let [edit, setEdit] = React.useState(null);
|
|
let [edit, setEdit] = React.useState(null);
|
|
|
let [del, setDelete] = React.useState(null);
|
|
let [del, setDelete] = React.useState(null);
|
|
|
let [show, setShow] = React.useState(null);
|
|
let [show, setShow] = React.useState(null);
|
|
|
|
|
+ let [filter, setFilter] = React.useState(null);
|
|
|
|
|
|
|
|
const toggle = useCallback((type, puesto) => {
|
|
const toggle = useCallback((type, puesto) => {
|
|
|
- // console.log('usecall: ',puesto)
|
|
|
|
|
setPuesto(puesto)
|
|
setPuesto(puesto)
|
|
|
switch (type) {
|
|
switch (type) {
|
|
|
case "VER": {
|
|
case "VER": {
|
|
@@ -89,9 +93,9 @@ export function Puestos() {
|
|
|
}, [del, show])
|
|
}, [del, show])
|
|
|
|
|
|
|
|
|
|
|
|
|
- if(isLoading){
|
|
|
|
|
- return(
|
|
|
|
|
- <Loading/>
|
|
|
|
|
|
|
+ if (isLoading) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Loading />
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -104,25 +108,53 @@ export function Puestos() {
|
|
|
</Paper>
|
|
</Paper>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
- const total_items = Divide(result.data).length
|
|
|
|
|
|
|
+ const total_items = Divide(filter ? filter : result.data).length
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className="content-section">
|
|
<div className="content-section">
|
|
|
<div className="main">
|
|
<div className="main">
|
|
|
<Box>
|
|
<Box>
|
|
|
<Paper sx={{ mb: 2, padding: 2, }}>
|
|
<Paper sx={{ mb: 2, padding: 2, }}>
|
|
|
-
|
|
|
|
|
- <Row style={{ paddingBottom: 15 }}>
|
|
|
|
|
- <Col md="2" sm="2" xs="2">
|
|
|
|
|
|
|
+ <Row style={{ alignItems: 'center', padding : 10 }}>
|
|
|
|
|
+ <Col md="6" sm="12" xs="12">
|
|
|
<div className="breadcrumb-header">
|
|
<div className="breadcrumb-header">
|
|
|
- <Box sx={{ float: 'left', display: 'flex', flexDirection: 'column', alignItems: 'center', '& > :not(style) + :not(style)': { mt: 2 }, }} >
|
|
|
|
|
- <ToggleButtonGroup size="small" {...control}>
|
|
|
|
|
|
|
+ <Box sx={{ float: 'left', display: 'flex', flexDirection: 'row', alignItems: 'center' }} >
|
|
|
|
|
+ <ToggleButtonGroup style={{ marginRight: 20 }} size="small" {...control}>
|
|
|
{children}
|
|
{children}
|
|
|
</ToggleButtonGroup>
|
|
</ToggleButtonGroup>
|
|
|
|
|
+ <TextField
|
|
|
|
|
+ id="search_plaza_input"
|
|
|
|
|
+ onChange={(event) => {
|
|
|
|
|
+ let nombre = event.target.value
|
|
|
|
|
+ if (nombre) {
|
|
|
|
|
+ let temp = result.data.filter(plaza => {
|
|
|
|
|
+ let isset = plaza.nombrepuesto.toUpperCase().includes(nombre.toUpperCase())
|
|
|
|
|
+ return isset
|
|
|
|
|
+ })
|
|
|
|
|
+ console.log(temp)
|
|
|
|
|
+ setFilter(temp)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ setFilter(null)
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
|
|
+ InputProps={{
|
|
|
|
|
+ startAdornment: (
|
|
|
|
|
+ <InputAdornment position="start">
|
|
|
|
|
+ <SearchIcon />
|
|
|
|
|
+ </InputAdornment>
|
|
|
|
|
+ ),
|
|
|
|
|
+ }}
|
|
|
|
|
+ variant="standard"
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
</Box>
|
|
</Box>
|
|
|
|
|
+
|
|
|
</div>
|
|
</div>
|
|
|
</Col>
|
|
</Col>
|
|
|
- <Col md="10" sm='10' xs="10">
|
|
|
|
|
|
|
+ <Col md="6" sm='12' xs="12">
|
|
|
<div className="add_producto">
|
|
<div className="add_producto">
|
|
|
<div onClick={() => setManual(true)} className="btn_add_producto">
|
|
<div onClick={() => setManual(true)} className="btn_add_producto">
|
|
|
<span className="btn_plaza_common" >Agregar manual <AddIcon fontSize="small" /></span>
|
|
<span className="btn_plaza_common" >Agregar manual <AddIcon fontSize="small" /></span>
|
|
@@ -136,13 +168,13 @@ export function Puestos() {
|
|
|
</Col>
|
|
</Col>
|
|
|
</Row>
|
|
</Row>
|
|
|
|
|
|
|
|
- <div>
|
|
|
|
|
- <div className={`main_productos ${alignment === 'grid' ? 'activar_vista' : 'desactivar_vista'}`} id="grid_view">
|
|
|
|
|
|
|
+ <div >
|
|
|
|
|
+ <div className={` main_grid_plazas main_productos ${alignment === 'grid' ? 'activar_vista' : 'desactivar_vista'}`} id="grid_view">
|
|
|
<Row>
|
|
<Row>
|
|
|
<GridMode
|
|
<GridMode
|
|
|
toggle={toggle}
|
|
toggle={toggle}
|
|
|
showing={alignment}
|
|
showing={alignment}
|
|
|
- data={Divide(result.data)}
|
|
|
|
|
|
|
+ data={filter ? Divide(filter) : Divide(result.data)}
|
|
|
index={page - 1}
|
|
index={page - 1}
|
|
|
/>
|
|
/>
|
|
|
</Row>
|
|
</Row>
|
|
@@ -152,30 +184,60 @@ export function Puestos() {
|
|
|
<ListMode
|
|
<ListMode
|
|
|
toggle={toggle}
|
|
toggle={toggle}
|
|
|
showing={alignment}
|
|
showing={alignment}
|
|
|
- data={Divide(result.data)}
|
|
|
|
|
|
|
+ data={filter ? Divide(filter) : Divide(result.data)}
|
|
|
index={page - 1}
|
|
index={page - 1}
|
|
|
/>
|
|
/>
|
|
|
</Row>
|
|
</Row>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <div id="pagi_bottom">
|
|
|
|
|
- <Pagination
|
|
|
|
|
- sx={{
|
|
|
|
|
- "& ul": {
|
|
|
|
|
- paddingTop: "20px",
|
|
|
|
|
- justifyContent: "center"
|
|
|
|
|
- }
|
|
|
|
|
- }}
|
|
|
|
|
- siblingCount={2}
|
|
|
|
|
- boundaryCount={2}
|
|
|
|
|
- shape='rounded'
|
|
|
|
|
- count={total_items}
|
|
|
|
|
- page={page}
|
|
|
|
|
- onChange={changePage}
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
- <Chip label={"Total: " + (result ? result.data.length : 0)} />
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <Row className="mamo">
|
|
|
|
|
+ <Col id="pagi_bottom" >
|
|
|
|
|
+
|
|
|
|
|
+ <Pagination
|
|
|
|
|
+ sx={{
|
|
|
|
|
+ "& ul": {
|
|
|
|
|
+ paddingTop: "20px",
|
|
|
|
|
+ justifyContent: "center"
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
|
|
+ siblingCount={2}
|
|
|
|
|
+ boundaryCount={2}
|
|
|
|
|
+ shape='rounded'
|
|
|
|
|
+ count={total_items}
|
|
|
|
|
+ page={page}
|
|
|
|
|
+ onChange={changePage}
|
|
|
|
|
+ />
|
|
|
|
|
+ <div className="chip_and_search">
|
|
|
|
|
+
|
|
|
|
|
+ <TextField
|
|
|
|
|
+ id="search_plaza_input"
|
|
|
|
|
+ onChange={(event) => {
|
|
|
|
|
+ let nombre = event.target.value
|
|
|
|
|
+ if (nombre) {
|
|
|
|
|
+ let temp = result.data.filter(plaza => {
|
|
|
|
|
+ let isset = plaza.nombrepuesto.toUpperCase().includes(nombre.toUpperCase())
|
|
|
|
|
+ return isset
|
|
|
|
|
+ })
|
|
|
|
|
+ console.log(temp)
|
|
|
|
|
+ setFilter(temp)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ setFilter(null)
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
|
|
+ InputProps={{
|
|
|
|
|
+ startAdornment: (
|
|
|
|
|
+ <InputAdornment position="start">
|
|
|
|
|
+ <SearchIcon />
|
|
|
|
|
+ </InputAdornment>
|
|
|
|
|
+ ),
|
|
|
|
|
+ }}
|
|
|
|
|
+ variant="standard"
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
|
|
+ <Chip style={{ marginLeft: 10, margin: 5 }} label={"Total: " + (result ? result.data.length : 0)} />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </Col>
|
|
|
|
|
+ </Row>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
</Paper>
|
|
</Paper>
|