import React, { useState, useCallback} from 'react'; import { Row, Col } from 'react-bootstrap' import { Toaster } from 'react-hot-toast'; // import toast, { Toaster } from 'react-hot-toast'; import { ToggleButton, ToggleButtonGroup, Box, Paper, Pagination, } from '@mui/material'; import { ViewList as ViewListIcon, ViewModule as ViewModuleIcon, } from '@mui/icons-material'; import { default as useAuth } from '../Auth/useAuth'; import { Service } from '../Utils/HTTP'; import { Divide } from '../Utils/Paginate'; import Express from '../Components/Modal/AgregarExpress'; import Manual from '../Components/Modal/AgregarManual'; import Editar from '../Components/Modal/EditPlaza'; import Eliminar from '../Components/Modal/EliminarPlaza'; import Mostrar from '../Components/Modal/MostrarPlaza'; import { ListMode } from '../Components/Puestos/ListMode' import { GridMode } from '../Components/Puestos/GridMode' import { Add as AddIcon, } from '@mui/icons-material/' import { Loading } from '../Components/Generics/loading' import { ErrorMessage } from '../Components/Generics/Error' import { useQuery } from 'react-query'; export function Puestos() { const auth = useAuth(); const token = auth.getToken(); const [page, setPage] = useState(1); const getAll = async () => { let rest = new Service("/plaza/getall") let response = await rest.getQuery(token); return response; } const { isLoading, error, data : result } = useQuery('puestos', getAll); const changePage = useCallback((_, value) => setPage(value),[]); const [alignment, setAlignment] = React.useState('grid'); const handleChange = useCallback((_event, newAlignment) => setAlignment(newAlignment),[]) const children = [ , , ]; const control = { value: alignment, onChange: handleChange, exclusive: true, }; let [manual, setManual] = React.useState(false); let [expres, setExpress] = React.useState(false); let [puesto, setPuesto] = React.useState(false); let [edit, setEdit] = React.useState(false); let [del, setDelete] = React.useState(false); let [show, setShow] = React.useState(false); const toggle = useCallback((type,puesto) => { setPuesto(puesto) switch(type){ case "VER": { setShow(!show); break; } case "EDIT": { setEdit(!edit) break; } case "DEL": { setDelete(!del) break; } default: break; } },[edit,del,show]) if (isLoading){ return(
) } if (error) { return (
) } const total_items = Divide(result.data).length return (
:not(style) + :not(style)': { mt: 2 }, }} > {children}
setManual(true)} className="btn_add_producto"> Agregar manual
setExpress(true)} className="add_producto">
Agregar express
setExpress(false)} /> setManual(false)} /> setDelete(false)} />
) }