浏览代码

useQuery start config

amenpunk 2 年之前
父节点
当前提交
42f3d96e1d

+ 7 - 0
src/App.css

@@ -240,3 +240,10 @@
240 240
     z-index : 999;
241 241
 }
242 242
 
243
+#loading_or_content{
244
+    display: grid;
245
+    min-height:100vh;
246
+    place-content:center;
247
+}
248
+
249
+

+ 8 - 6
src/App.js

@@ -6,16 +6,17 @@ import { BrowserRouter as Router } from "react-router-dom";
6 6
 import { Container } from 'react-bootstrap'
7 7
 import { AuthProvider } from './Auth/AuthProvider'
8 8
 import { QueryClient, QueryClientProvider } from 'react-query'
9
+import { ReactQueryDevtools } from 'react-query/devtools'
9 10
 
10 11
 import Routes from './Components/Routes'
11 12
 const queryClient = new QueryClient()
12 13
 
13
-const GATEWAY =  {
14
-    dev : {
15
-        API : 'http://localhost:8000',
14
+const GATEWAY = {
15
+    dev: {
16
+        API: 'http://localhost:8000',
16 17
     },
17
-    pro : {
18
-        API : '',
18
+    pro: {
19
+        API: '',
19 20
     }
20 21
 }
21 22
 
@@ -28,11 +29,12 @@ function App() {
28 29
                 <AuthProvider>
29 30
                     <API_GATEWAY.Provider value={GATEWAY.dev}>
30 31
                         <Container fluid>
31
-                            <Routes/>
32
+                            <Routes />
32 33
                         </Container>
33 34
                     </API_GATEWAY.Provider>
34 35
                 </AuthProvider>
35 36
             </Router>
37
+            <ReactQueryDevtools initialIsOpen={false} />
36 38
         </QueryClientProvider>
37 39
     );
38 40
 }

+ 21 - 0
src/Components/Generics/Error.jsx

@@ -0,0 +1,21 @@
1
+import { Col, Row } from 'react-bootstrap'
2
+
3
+import RoboError from '../../Images/robo_error.png'
4
+import PriorityHighIcon from '@mui/icons-material/PriorityHigh';
5
+
6
+export function ErrorMessage() {
7
+    return (
8
+        <div>
9
+            <Row className="row" style={{flexDirection:'row'}}>
10
+                <Col md="6">
11
+                    <img src={RoboError} alt="robo error" />
12
+                </Col>
13
+                <Col md="6">
14
+                    <h1>Upss... <PriorityHighIcon fontSize="large" style={{ fontSize:95 }} /></h1>
15
+                    <h3>Algo salió mal..</h3>
16
+                    <p>Lo sentimos porfavor intentalo  nuevamente</p>
17
+                </Col>
18
+            </Row>
19
+        </div>
20
+    )
21
+}

+ 24 - 0
src/Components/Generics/loading.jsx

@@ -0,0 +1,24 @@
1
+import React from "react";
2
+import '../../Css/loading.css'
3
+
4
+export function Loading( props ) {
5
+
6
+    let { type } = props
7
+
8
+    let types = [
9
+        "dot-elastic","dot-flashing", "dot-collision", "dot-revolution", "dot-carousel", "dot-fire",
10
+        "dot-spin","dot-falling", "dot-stretching"
11
+    ];
12
+
13
+    console.log(type, types)
14
+
15
+    return(
16
+        <div className="loading_or_content">
17
+            <div className="snippet" data-title=".dot-pulse">
18
+                <div className="stage">
19
+                    <div className="dot-pulse"></div>
20
+                </div>
21
+            </div>
22
+        </div>
23
+    )
24
+}

+ 3 - 1
src/Components/Modal/AgregarExpress.js

@@ -7,7 +7,7 @@ const ExpressSchema = Yup.object().shape({
7 7
     link : Yup.string().required('El enlace es requerido').url("Debes agregar un enlace válido, recurda iniciar con http o https ").min(5).max(190),
8 8
 })
9 9
 
10
-export  default function Express (props) {
10
+function Express (props) {
11 11
 
12 12
     let { visible, onClose, success } = props
13 13
 
@@ -52,3 +52,5 @@ export  default function Express (props) {
52 52
         </Modal>
53 53
     )
54 54
 }
55
+
56
+export default React.memo(Express)

+ 47 - 46
src/Components/Modal/AgregarManual.js

@@ -1,30 +1,30 @@
1
-import React from 'react';
1
+import React, { memo } from 'react';
2 2
 import * as Yup from 'yup';
3 3
 import { useFormik, Form, FormikProvider } from 'formik';
4 4
 import { Modal } from 'react-bootstrap'
5 5
 
6 6
 import DateFnsUtils from '@date-io/date-fns';
7
-import { DesktopDatePicker,LocalizationProvider } from '@mui/lab';
7
+import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
8 8
 
9
-import {  
10
-    Button, Stack, TextField, MenuItem,FormControl, InputLabel, Select,
9
+import {
10
+    Button, Stack, TextField, MenuItem, FormControl, InputLabel, Select,
11 11
     Backdrop, CircularProgress
12 12
 } from '@mui/material';
13 13
 
14 14
 import { Service } from '../../Utils/HTTP';
15
-import  useAuth from '../../Auth/useAuth';
15
+import useAuth from '../../Auth/useAuth';
16 16
 
17 17
 
18
-export default function Manual ( props ) {
18
+function Manual(props) {
19 19
 
20 20
     const NewPlazaSchema = Yup.object().shape({
21
-        nombrepuesto : Yup.string().required('El nombre es requerido').min(5, "El nombre del  puesto debe ser mayor a 5 caracteres").max(100),
22
-        puestosuperior : Yup.number("El puesto superior debe ser un número").required("El puesto es requerido"),
23
-        aredepto : Yup.number().required('Escoge alguna área'),
24
-        fecha : Yup.date("Ingresa una fecha válida"),
25
-        notas : Yup.string("Ingresa una nota válida").min(5).max(150),
21
+        nombrepuesto: Yup.string().required('El nombre es requerido').min(5, "El nombre del  puesto debe ser mayor a 5 caracteres").max(100),
22
+        puestosuperior: Yup.number("El puesto superior debe ser un número").required("El puesto es requerido"),
23
+        aredepto: Yup.number().required('Escoge alguna área'),
24
+        fecha: Yup.date("Ingresa una fecha válida"),
25
+        notas: Yup.string("Ingresa una nota válida").min(5).max(150),
26 26
     })
27
-    
27
+
28 28
     const [departamento, setDepartamento] = React.useState('');
29 29
     const [open, setOpen] = React.useState(false);
30 30
     const handleClose = () => false
@@ -38,7 +38,7 @@ export default function Manual ( props ) {
38 38
     const auth = useAuth();
39 39
     const token = auth.getToken();
40 40
 
41
-    let { visible, onClose, Complete, categorias  } = props
41
+    let { visible, onClose, Complete, categorias } = props
42 42
 
43 43
     const formik = useFormik({
44 44
         initialValues: {
@@ -48,45 +48,45 @@ export default function Manual ( props ) {
48 48
             fecha: date,
49 49
             notas: "",
50 50
         },
51
-        onSubmit: ( fields, { resetForm } ) => {
51
+        onSubmit: (fields, { resetForm }) => {
52 52
 
53 53
             setOpen(true)
54
-            fields['fecha'] =  new Date(fields.fecha).toISOString();
54
+            fields['fecha'] = new Date(fields.fecha).toISOString();
55 55
             fields['areadeptoplz_id'] = 1;
56 56
             fields['id'] = -1;
57 57
 
58 58
             let Rest = new Service('/plaza/save');
59 59
 
60 60
             Rest
61
-            .post( fields, token )
62
-            .then( _ => {
63
-                resetForm();
64
-                Complete(true, "Puesto agregado exitosamente");
65
-                onClose();
66
-                setOpen(false)
67
-            })
68
-            .catch(err => {
69
-                console.error(err)
70
-                Complete(false,"Ocurrio un error intentalo nuevamente");
71
-                setOpen(false)
72
-            })
61
+                .post(fields, token)
62
+                .then(_ => {
63
+                    resetForm();
64
+                    Complete(true, "Puesto agregado exitosamente");
65
+                    onClose();
66
+                    setOpen(false)
67
+                })
68
+                .catch(err => {
69
+                    console.error(err)
70
+                    Complete(false, "Ocurrio un error intentalo nuevamente");
71
+                    setOpen(false)
72
+                })
73 73
 
74 74
         },
75 75
         validationSchema: NewPlazaSchema,
76 76
     });
77 77
 
78
-    const { errors, touched, handleSubmit, getFieldProps} = formik;
78
+    const { errors, touched, handleSubmit, getFieldProps } = formik;
79 79
 
80 80
     return (
81 81
 
82 82
         <Modal size="lg" aria-labelledby="contained-modal-title-vcenter" centered show={visible} onHide={onClose}>
83 83
             <Modal.Header>
84
-                <button onClick={onClose}  type="button" className="close" data-dismiss="modal">&times;</button>
85
-                <h4 className="modal-title" style={{color : '#252525'}}>Agregar plaza</h4>
84
+                <button onClick={onClose} type="button" className="close" data-dismiss="modal">&times;</button>
85
+                <h4 className="modal-title" style={{ color: '#252525' }}>Agregar plaza</h4>
86 86
             </Modal.Header>
87 87
             <Modal.Body className="modal-body">
88 88
 
89
-                <FormikProvider style={{ padding : 25 }} value={formik}>
89
+                <FormikProvider style={{ padding: 25 }} value={formik}>
90 90
                     <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
91 91
                         <Stack spacing={3}>
92 92
 
@@ -120,19 +120,19 @@ export default function Manual ( props ) {
120 120
                                         {...getFieldProps('aredepto')}
121 121
                                         error={Boolean(touched.aredepto && errors.aredepto)} >
122 122
                                         {
123
-                                        categorias ?
124
-                                            categorias.map( cate => {
125
-                                                return (
126
-                                                    <MenuItem key={cate.id} value={cate.id}>{cate.nombre}</MenuItem>
127
-                                                )
128
-                                            })
129
-                                            : <MenuItem>Null</MenuItem>
130
-                                    }
123
+                                            categorias ?
124
+                                                categorias.map(cate => {
125
+                                                    return (
126
+                                                        <MenuItem key={cate.id} value={cate.id}>{cate.nombre}</MenuItem>
127
+                                                    )
128
+                                                })
129
+                                                : <MenuItem>Null</MenuItem>
130
+                                        }
131 131
                                     </Select>
132 132
                                 </FormControl>
133 133
 
134 134
 
135
-                                <LocalizationProvider 
135
+                                <LocalizationProvider
136 136
                                     dateAdapter={DateFnsUtils}>
137 137
                                     <DesktopDatePicker
138 138
                                         label="Fecha Creación"
@@ -141,12 +141,12 @@ export default function Manual ( props ) {
141 141
                                         {...getFieldProps('fecha')}
142 142
                                         value={date}
143 143
                                         onChange={setDate}
144
-                                        renderInput={(params) => 
145
-                                            <TextField 
144
+                                        renderInput={(params) =>
145
+                                            <TextField
146 146
                                                 disabled={true}
147 147
                                                 label="Fecha Creación"
148 148
                                                 fullWidth
149
-                                                {...params} 
149
+                                                {...params}
150 150
                                             />}
151 151
                                     />
152 152
                                 </LocalizationProvider>
@@ -165,7 +165,7 @@ export default function Manual ( props ) {
165 165
                                     {...getFieldProps('notas')}
166 166
                                     error={Boolean(touched.notas && errors.notas)}
167 167
                                     helperText={touched.notas && errors.notas}
168
-                                    />
168
+                                />
169 169
                             </Stack>
170 170
                         </Stack>
171 171
 
@@ -173,7 +173,7 @@ export default function Manual ( props ) {
173 173
                         <Modal.Footer>
174 174
                             <Button
175 175
                                 type="submit"
176
-                                className="registerBtn" 
176
+                                className="registerBtn"
177 177
                                 variant="contained"
178 178
                                 sx={{ mt: 1, mr: 1 }} >
179 179
                                 {'Guardar'}
@@ -187,9 +187,10 @@ export default function Manual ( props ) {
187 187
                 sx={{ color: '#fd4b4b', zIndex: (theme) => theme.zIndex.drawer + 1 }}
188 188
                 open={open}
189 189
                 onClick={handleClose} >
190
-            <CircularProgress color="inherit" />
190
+                <CircularProgress color="inherit" />
191 191
             </Backdrop>
192 192
 
193 193
         </Modal>
194 194
     )
195 195
 }
196
+export default memo(Manual);

+ 5 - 2
src/Components/Modal/EditPlaza.js

@@ -1,4 +1,4 @@
1
-import React, { useEffect } from 'react';
1
+import React, { useEffect, memo } from 'react';
2 2
 import * as Yup from 'yup';
3 3
 import { useFormik, Form, FormikProvider } from 'formik';
4 4
 import { Modal } from 'react-bootstrap'
@@ -14,7 +14,7 @@ import {
14 14
 import { Service } from '../../Utils/HTTP';
15 15
 import  useAuth from '../../Auth/useAuth';
16 16
 
17
-export default function Edit(props) {
17
+function Edit(props) {
18 18
 
19 19
     const NewPlazaSchema = Yup.object().shape({
20 20
         id: Yup.number(),
@@ -207,3 +207,6 @@ export default function Edit(props) {
207 207
         </Modal>
208 208
     )
209 209
 }
210
+
211
+
212
+export default memo(Edit);

+ 5 - 2
src/Components/Modal/EliminarPlaza.js

@@ -1,7 +1,7 @@
1
-import React from 'react';
1
+import React, { memo } from 'react';
2 2
 import { Modal, Row, Col } from 'react-bootstrap'
3 3
 
4
-export default function Eliminar(props) {
4
+export function Eliminar(props) {
5 5
 
6 6
     let { visible, onClose, puesto } = props
7 7
 
@@ -35,3 +35,6 @@ export default function Eliminar(props) {
35 35
         </Modal>
36 36
     )
37 37
 }
38
+
39
+
40
+export default memo(Eliminar);

+ 4 - 2
src/Components/Modal/MostrarPlaza.js

@@ -1,8 +1,8 @@
1
-import React from 'react';
1
+import React, {memo} from 'react';
2 2
 import { Modal, Col, Row } from 'react-bootstrap'
3 3
 import QA from '../../Images/puesto.jpg'
4 4
 
5
-export default function Mostrar(props) {
5
+function Mostrar(props) {
6 6
 
7 7
     let { visible, onClose, puesto } = props
8 8
 
@@ -41,3 +41,5 @@ export default function Mostrar(props) {
41 41
         </Modal>
42 42
     )
43 43
 }
44
+
45
+export default memo(Mostrar);

文件差异内容过多而无法显示
+ 1178 - 0
src/Css/loading.css


二进制
src/Images/robo_error.png


+ 133 - 107
src/Pages/Puestos.jsx

@@ -1,9 +1,9 @@
1
-import React, { useState, useEffect }  from 'react';
1
+import React, { useState, useCallback } from 'react';
2 2
 import { Row, Col } from 'react-bootstrap'
3 3
 
4 4
 import toast, { Toaster } from 'react-hot-toast';
5 5
 
6
-import { 
6
+import {
7 7
     ToggleButton, ToggleButtonGroup, Box,
8 8
     Paper, Pagination,
9 9
 } from '@mui/material';
@@ -12,7 +12,7 @@ import { ViewList as ViewListIcon, ViewModule as ViewModuleIcon, } from '@mui/ic
12 12
 
13 13
 import { default as useAuth } from '../Auth/useAuth';
14 14
 import { Service } from '../Utils/HTTP';
15
-import { Divide } from '../Utils/Paginate';
15
+// import { Divide } from '../Utils/Paginate';
16 16
 
17 17
 import Express from '../Components/Modal/AgregarExpress';
18 18
 import Manual from '../Components/Modal/AgregarManual';
@@ -25,93 +25,98 @@ import { ListMode } from '../Components/Puestos/ListMode'
25 25
 import { GridMode } from '../Components/Puestos/GridMode'
26 26
 import { Add as AddIcon, } from '@mui/icons-material/'
27 27
 
28
+import { Loading } from '../Components/Generics/loading'
29
+import { ErrorMessage } from '../Components/Generics/Error'
30
+
31
+import { useQuery } from 'react-query';
28 32
 
29 33
 export function Puestos() {
30 34
 
31
-    const Complete =  (status, message) => {
32
-        console.log(status, message);
35
+    const auth = useAuth();
36
+    const token = auth.getToken();
33 37
 
34
-        if(!status){
38
+    const Complete = useCallback((status, message) => {
39
+
40
+        if (!status) {
35 41
             return toast.error(message)
36 42
         }
37 43
 
38 44
         let rest = new Service("/plaza/getall")
39 45
         rest
40 46
             .get(token)
41
-            .then(({data}) => {
42
-                let entries = data.map( e => {
43
-                    return {
44
-                        nombre : e.nombrepuesto,
45
-                        description : e.notas,
46
-                        id : e.id,
47
-                        created: e.create_day,
48
-                        data: e
49
-                    };
50
-                })
51
-                setData(Divide(entries))
47
+            .then(({ data }) => {
48
+                return data;
49
+                // let entries = data.map(e => {
50
+                //     return {
51
+                //         nombre: e.nombrepuesto,
52
+                //         description: e.notas,
53
+                //         id: e.id,
54
+                //         created: e.create_day,
55
+                //         data: e
56
+                //     };
57
+                // })
58
+                //setData(Divide(entries))
52 59
             })
53 60
             .catch((error) => {
54
-                console.log('error fetching data  ', error );
61
+                console.log('error fetching data  ', error);
55 62
             })
56 63
 
57 64
         toast.success(message)
58
-    } 
59
-
60
-    const auth = useAuth();
61
-
62
-    const [data, setData] = useState([]);
63
-    const [page, setPage] = useState(1);
64
-    const [categorias, setCategorias] = useState([]);
65
-
66
-    const token = auth.getToken();
67
-
68
-    const changePage = ( _ , value) => setPage(value);
69
-
70
-    useEffect(() => {
65
+    },[token])
71 66
 
67
+    const getAll = useCallback(async () => {
72 68
         let rest = new Service("/plaza/getall")
69
+        let response =  await rest.getQuery(token); 
70
+        return response;
71
+    },[token])
72
+
73
+    useCallback(() => {
74
+        let rest = new Service("/categoria/getAll")
73 75
         rest
74 76
             .get(token)
75
-            .then(({data}) => {
76
-                let entries = data.map( e => {
77
-                    return {
78
-                        nombre : e.nombrepuesto,
79
-                        description : e.notas,
80
-                        id : e.id,
81
-                        created: e.create_day,
82
-                        data: e
83
-                    };
84
-                })
85
-                setData(Divide(entries))
86
-            })
87
-            .catch((error) => {
88
-                console.log('error fetching data  ', error );
89
-            })
90
-    
91
-        rest = new Service("/categoria/getAll")
92
-        rest
93
-            .get(token)
94
-            .then(({data}) => {
95
-                setCategorias(data)
77
+            .then(({ data }) => {
78
+                console.log(data)
79
+                setCategorias(data);
96 80
             })
97 81
             .catch((error) => {
98
-                console.log('error fetching data  ', error );
82
+                console.log('error fetching data  ', error);
83
+                return error;
99 84
             })
100 85
 
101
-
102 86
     },[token])
103 87
 
88
+    const { isLoading, error, data } = useQuery('puestos', getAll);
89
+    console.log( isLoading, error, data )
90
+
91
+    const [page, setPage] = useState(1);
92
+    const [categorias, setCategorias] = useState([]);
93
+
94
+    const changePage = useCallback((_, value) => setPage(value),[]);
95
+
96
+    // useEffect(() => {
97
+    //     // let entries = data.map( e => {
98
+    //     //     return {
99
+    //     //         nombre : e.nombrepuesto,
100
+    //     //         description : e.notas,
101
+    //     //         id : e.id,
102
+    //     //         created: e.create_day,
103
+    //     //         data: e
104
+    //     //     };
105
+    //     // })
106
+    //     // setData(Divide(entries))
107
+    // }, [])
108
+
104 109
     // const [alignment, setAlignment] = React.useState('list');
105 110
     const [alignment, setAlignment] = React.useState('grid');
106 111
 
107
-    const handleChange = (_event, newAlignment) => setAlignment(newAlignment)
112
+    const handleChange = useCallback((_event, newAlignment) => setAlignment(newAlignment),[])
108 113
 
109 114
     const children = [
110 115
         <ToggleButton value="list" key="list">
111 116
             <ViewListIcon />
112 117
         </ToggleButton>,
113 118
         <ToggleButton value="grid" key="grid">
114
-            <ViewModuleIcon/>
119
+            <ViewModuleIcon />
115 120
         </ToggleButton>,
116 121
     ];
117 122
 
@@ -130,16 +135,28 @@ export function Puestos() {
130 135
     let [del, setDelete] = React.useState(false);
131 136
     let [show, setShow] = React.useState(false);
132 137
 
138
+    if (isLoading) return <Loading />
139
+
140
+    if (error) {
141
+        return (
142
+            <Paper sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh' }}>
143
+                <main id="loading_or_content">
144
+                    <ErrorMessage/>
145
+                </main>
146
+            </Paper>
147
+        )
148
+    }
149
+
133 150
     return (
134 151
         <div className="content-section">
135 152
             <div className="main">
136 153
                 <Box sx={{}}>
137
-                    <Paper sx={{ mb: 2, padding : 2, height: '100%', minHeight:'95vh' }}>
154
+                    <Paper sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh' }}>
138 155
 
139
-                        <Row style={{paddingBottom : 15}}>
156
+                        <Row style={{ paddingBottom: 15 }}>
140 157
                             <Col md="2" sm="2" xs="2">
141 158
                                 <div className="breadcrumb-header">
142
-                                    <Box sx={{ float : 'left',display: 'flex', flexDirection: 'column', alignItems: 'center', '& > :not(style) + :not(style)': { mt: 2 }, }} >
159
+                                    <Box sx={{ float: 'left', display: 'flex', flexDirection: 'column', alignItems: 'center', '& > :not(style) + :not(style)': { mt: 2 }, }} >
143 160
                                         <ToggleButtonGroup size="small" {...control}>
144 161
                                             {children}
145 162
                                         </ToggleButtonGroup>
@@ -148,72 +165,81 @@ export function Puestos() {
148 165
                             </Col>
149 166
                             <Col md="10" sm='10' xs="10">
150 167
                                 <div className="add_producto">
151
-                                    <div onClick={() => setManual(true) } className="btn_add_producto"> 
152
-                                        <span className="btn_plaza_common" >Agregar manual <AddIcon fontSize="small"/></span> 
168
+                                    <div onClick={() => setManual(true)} className="btn_add_producto">
169
+                                        <span className="btn_plaza_common" >Agregar manual <AddIcon fontSize="small" /></span>
153 170
                                     </div>
154 171
                                 </div>
155
-                                <div onClick={() => setExpress(true) } className="add_producto">
156
-                                    <div className="btn_add_producto"> 
157
-                                        <span className="btn_plaza_common">Agregar express <AddIcon fontSize="small"/></span> 
172
+                                <div onClick={() => setExpress(true)} className="add_producto">
173
+                                    <div className="btn_add_producto">
174
+                                        <span className="btn_plaza_common">Agregar express <AddIcon fontSize="small" /></span>
158 175
                                     </div>
159 176
                                 </div>
160 177
                             </Col>
161 178
                         </Row>
162
-                        <div className={`main_productos ${ alignment === 'grid' ? 'activar_vista' : 'desactivar_vista'  }`} id="grid_view">
163
-                            <Row>
164
-                                <GridMode
165
-                                    showing={alignment}
166
-                                    data={data}
167
-                                    index={page - 1}
168
-                                    setPuesto={setPuesto}
169
-                                    setEdit={setEdit}
170
-                                    setDelete={setDelete}
171
-                                    setShow={setShow}
179
+
180
+                        <div >
181
+                            <div className={`main_productos ${alignment === 'grid' ? 'activar_vista' : 'desactivar_vista'}`} id="grid_view">
182
+                                <Row>
183
+                                    <GridMode
184
+                                        showing={alignment}
185
+                                        data={[]}
186
+                                        // data={data}
187
+                                        index={0}
188
+                                        // index={page - 1}
189
+                                        setPuesto={setPuesto}
190
+                                        setEdit={setEdit}
191
+                                        setDelete={setDelete}
192
+                                        setShow={setShow}
172 193
                                     />
173
-                            </Row>
174
-                        </div>
175
-                        <div className={`main_list_products ${alignment === 'list' ?  'activar_vista' : 'desactivar_vista'}`} id="list_view_products">
176
-                            <Row>
177
-                                <ListMode 
178
-                                    showing={alignment}
179
-                                    data={data}
180
-                                    index={page - 1}
181
-                                    setPuesto={setPuesto}
182
-                                    setEdit={setEdit}
183
-                                    setDelete={setDelete}
184
-                                    setShow={setShow}
194
+                                </Row>
195
+                            </div>
196
+                            <div className={`main_list_products ${alignment === 'list' ? 'activar_vista' : 'desactivar_vista'}`} id="list_view_products">
197
+                                <Row>
198
+                                    <ListMode
199
+                                        showing={alignment}
200
+                                        data={[]}
201
+                                        // data={data}
202
+                                        // index={page - 1}
203
+                                        index={0}
204
+                                        setPuesto={setPuesto}
205
+                                        setEdit={setEdit}
206
+                                        setDelete={setDelete}
207
+                                        setShow={setShow}
185 208
                                     />
186
-                            </Row>
187
-                        </div>
188
-
189
-                        <Pagination 
190
-                            sx={{
191
-                                "& ul" :{
192
-                                    paddingTop: "20px",
193
-                                    justifyContent: "center"
194
-                                }
195
-                            }}
196
-                            siblingCount={2} 
197
-                            boundaryCount={2}
198
-                            shape='rounded' 
199
-                            count={data.length} 
200
-                            page={page} 
201
-                            onChange={changePage} 
209
+                                </Row>
210
+                            </div>
211
+
212
+                            <Pagination
213
+                                sx={{
214
+                                    "& ul": {
215
+                                        paddingTop: "20px",
216
+                                        justifyContent: "center"
217
+                                    }
218
+                                }}
219
+                                siblingCount={2}
220
+                                boundaryCount={2}
221
+                                shape='rounded'
222
+                                // count={data.length}
223
+                                count={0}
224
+                                page={page}
225
+                                onChange={changePage}
202 226
                             />
203 227
 
228
+
229
+                        </div>
230
+
204 231
                     </Paper>
205 232
                 </Box>
206
-
207 233
             </div>
208 234
 
209
-            <Express setExpress={setExpress} visible={expres} onClose={() => setExpress(false) } />
210
-            <Manual categorias={categorias} Complete={Complete} visible={manual} onClose={() => setManual(false)}/>
235
+            <Express setExpress={setExpress} visible={expres} onClose={() => setExpress(false)} />
236
+            <Manual categorias={categorias} Complete={Complete} visible={manual} onClose={() => setManual(false)} />
211 237
 
212 238
             <Editar categorias={categorias} Complete={Complete} puesto={puesto} visible={edit} onClose={() => setEdit(false)} />
213 239
             <Eliminar puesto={puesto} visible={del} onClose={() => setDelete(false)} />
214
-            <Mostrar  puesto={puesto} visible={show} onClose={() => setShow(false)} />
240
+            <Mostrar puesto={puesto} visible={show} onClose={() => setShow(false)} />
215 241
 
216
-            <Toaster  position="bottom-right" reverseOrder={false} />
242
+            <Toaster position="bottom-right" reverseOrder={false} />
217 243
 
218 244
         </div>
219 245
     )

+ 11 - 1
src/Utils/HTTP.js

@@ -10,6 +10,15 @@ export class Service {
10 10
         // this.api =  'http://psicoadmin.ditca.org:8081/user?user=patrik&password=12345'
11 11
     }
12 12
 
13
+
14
+    async getQuery(token){
15
+        return await axios.get(this.url, {
16
+            headers: {
17
+                'Authorization': `Bearer ${token}`
18
+            }
19
+        })
20
+    }
21
+
13 22
     async get(token){
14 23
         return axios.get(this.url, {
15 24
             headers: {
@@ -20,7 +29,8 @@ export class Service {
20 29
             return res;
21 30
         })
22 31
         .catch((error) => {
23
-            return error;
32
+            console.log("ERROR :: ", error)
33
+            return new Error("GG");
24 34
         })
25 35
     }
26 36