Browse Source

feedback update

amenpunk 2 years ago
parent
commit
b44b323be6

+ 0 - 2
src/App.js

@@ -6,7 +6,6 @@ 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'
10 9
 
11 10
 import Routes from './Components/Routes'
12 11
 const queryClient = new QueryClient({
@@ -40,7 +39,6 @@ function App() {
40 39
                     </API_GATEWAY.Provider>
41 40
                 </AuthProvider>
42 41
             </Router>
43
-            <ReactQueryDevtools initialIsOpen={false} />
44 42
         </QueryClientProvider>
45 43
     );
46 44
 }

+ 5 - 9
src/Components/Generics/loading.jsx

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

+ 8 - 2
src/Components/Modal/AgregarManual.js

@@ -2,6 +2,7 @@ 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
+import toast, { Toaster } from 'react-hot-toast';
5 6
 
6 7
 import DateFnsUtils from '@date-io/date-fns';
7 8
 import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
@@ -33,7 +34,7 @@ function Manual(props) {
33 34
         puestosuperior: Yup.number("El puesto superior debe ser un número").required("El puesto es requerido"),
34 35
         aredepto: Yup.number().required('Escoge alguna área'),
35 36
         fecha: Yup.date("Ingresa una fecha válida"),
36
-        notas: Yup.string("Ingresa una nota válida").min(5).max(150),
37
+        notas: Yup.string("Ingresa una nota válida").min(5,"Ingresa una nota válida").max(150),
37 38
     })
38 39
 
39 40
     const [departamento, setDepartamento] = React.useState('');
@@ -76,6 +77,11 @@ function Manual(props) {
76 77
                     resetForm();
77 78
                     onClose();
78 79
                     queryClient.invalidateQueries('puestos')
80
+                    toast.success("Puesto Agregado")
81
+                },
82
+                onError:() =>{
83
+                    setOpen(false)
84
+                    toast.error("Ups!! Ocurrio un error, inténtalo más tarde")
79 85
                 }
80 86
             })
81 87
         },
@@ -196,7 +202,7 @@ function Manual(props) {
196 202
                 onClick={handleClose} >
197 203
                 <CircularProgress color="inherit" />
198 204
             </Backdrop>
199
-
205
+            <Toaster position="top-right" />
200 206
         </Modal>
201 207
     )
202 208
 }

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

@@ -2,6 +2,7 @@ import React, { memo, useCallback, useMemo, useEffect } 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
+import toast, { Toaster } from 'react-hot-toast';
5 6
 
6 7
 import DateFnsUtils from '@date-io/date-fns';
7 8
 import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
@@ -38,7 +39,7 @@ function Edit(props) {
38 39
     let { visible, toggle, puesto } = props
39 40
 
40 41
     const [departamento, setDepartamento] = React.useState('');
41
-    // const [open, setOpen] = React.useState(false);
42
+    const [open, setOpen] = React.useState(false);
42 43
 
43 44
     const changeDepartamento = useCallback((event) => {
44 45
         setDepartamento(event.target.value);
@@ -73,12 +74,20 @@ function Edit(props) {
73 74
             notas: ""
74 75
         },
75 76
         onSubmit: (fields, { resetForm }) => {
77
+            setOpen(true);
76 78
             fields['fecha'] = new Date(fields.fecha).toISOString();
77 79
 
78 80
             puestoMutation.mutate(fields, {
79 81
                 onSuccess: () => {
80 82
                     close();
83
+                    setOpen(false)
84
+                    toast.success("Puesto Actualizado!!")
81 85
                     queryClient.invalidateQueries('puestos')
86
+                },
87
+                onError:() => {
88
+                    close();
89
+                    setOpen(false)
90
+                    toast.error("Lo sentimos ocurrió error inténtalo más tarde")
82 91
                 }
83 92
             })
84 93
 
@@ -211,12 +220,12 @@ function Edit(props) {
211 220
                 </FormikProvider>
212 221
             </Modal.Body>
213 222
             <Backdrop
214
-            // sx={{ color: '#fd4b4b', zIndex: (theme) => theme.zIndex.drawer + 1 }}
215
-            // open={open}
216
-            // onClick={() => console.log('backdrop')} >
217
-            >
223
+                sx={{ color: '#fd4b4b', zIndex: (theme) => theme.zIndex.drawer + 1 }}
224
+                open={open}
225
+                onClick={() => console.log('backdrop')} >
218 226
                 <CircularProgress color="inherit" />
219 227
             </Backdrop>
228
+            <Toaster position="top-right" />
220 229
 
221 230
         </Modal>
222 231
     )

+ 4 - 4
src/Components/Navigation/listItems.js

@@ -57,8 +57,8 @@ export const MainListItems = (props) =>  {
57 57
         <List>
58 58
             <ListSubheader inset>MENÚ</ListSubheader>
59 59
             {
60
-                MainItems.map( ({ icon, title, route}) =>  (
61
-                    <NavItem icon={icon} title={title} route={route} />
60
+                MainItems.map( ({ icon, title, route}, i) =>  (
61
+                    <NavItem key={i} icon={icon} title={title} route={route} />
62 62
                 ))
63 63
             }
64 64
             <ListItem selected={open} onClick={showPruebas}>
@@ -74,8 +74,8 @@ export const MainListItems = (props) =>  {
74 74
             <Collapse in={open} timeout="auto" unmountOnExit>
75 75
                 <List component="div" disablePadding>
76 76
                     {
77
-                        PruebaItems.map( ({ route, title}) => 
78
-                            ( <NavItem setOpen={setOpen} { ...props} open={open} route={route} title={title} />)
77
+                        PruebaItems.map( ({ route, title},i) => 
78
+                            ( <NavItem key={i} setOpen={setOpen} { ...props} open={open} route={route} title={title} />)
79 79
                         )
80 80
                     }
81 81
                 </List>

+ 11 - 14
src/Components/Puestos/ListMode.jsx

@@ -8,20 +8,20 @@ import Deletei from '@mui/icons-material/Delete';
8 8
 export function ListMode(props) {
9 9
     
10 10
     const opciones = { weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' };
11
-    let { setEdit, setDelete, setShow, setPuesto, data, index, showing } = props;
11
+    let {  data, index, showing } = props;
12 12
 
13 13
     const isMovil = Size('(min-width:770px)');
14 14
 
15 15
     return(
16 16
         <Col md="12">
17
-            <div className="body-table">
18
-                <Table responsive borderless id="tablaproductos">
17
+            <div className={!isMovil ? "body-table-responsive" : "body-table"}>
18
+                <Table responsive borderless id="tablaproductos" style={{ color : 'white' }}>
19 19
                     <thead>
20 20
                         <tr >
21
-                            <th className="text-center">Nombre de la plaza</th>
21
+                            <th className="text-center">Nombre</th>
22 22
                             <th className="text-center">Descripción</th>
23 23
                             <th className="text-center">Creacion</th>
24
-                            <th className="text-center">Acciones</th>
24
+                            <th className="text-center">Acción</th>
25 25
                         </tr>
26 26
                     </thead>
27 27
                     <tbody>
@@ -31,9 +31,9 @@ export function ListMode(props) {
31 31
                                     return (
32 32
                                     <Zoom key={plaza.id} in={true}>
33 33
                                         <tr >
34
-                                            <td className="text-center">{ plaza.nombre }</td>
35
-                                            <td className="text-center">{ plaza.description }</td>
36
-                                            <td className="text-center">{ new Date( plaza.created ).toLocaleDateString('es-GT',opciones) }</td>
34
+                                            <td className="text-center">{ plaza.nombrepuesto }</td>
35
+                                            <td className="text-center">{ plaza.notas }</td>
36
+                                            <td className="text-center">{ new Date( plaza.createday ).toLocaleDateString('es-GT',opciones) }</td>
37 37
                                             <TableCell
38 38
                                                 sx={{
39 39
                                                     "display":'flex',
@@ -44,24 +44,21 @@ export function ListMode(props) {
44 44
                                                 className="actions_butons_plaza"> 
45 45
                                                 <Button 
46 46
                                                     onClick={() => {
47
-                                                        setPuesto(plaza) 
48
-                                                        setShow(true)
47
+                                                        console.log("VER")
49 48
                                                     }} 
50 49
                                                     className="ver_producto">
51 50
                                                     {!isMovil ? <ShowI/> : "Ver"}
52 51
                                                 </Button>
53 52
                                                 <Button 
54 53
                                                     onClick={() => {
55
-                                                        setPuesto(plaza) 
56
-                                                        setEdit(true)
54
+                                                        console.log("EDITAR")
57 55
                                                     }} 
58 56
                                                     className="editar_producto">
59 57
                                                     {!isMovil ? <EditI/> : "Editar"}
60 58
                                                 </Button>
61 59
                                                 <Button 
62 60
                                                     onClick={() => {
63
-                                                        setPuesto(plaza) 
64
-                                                        setDelete(true) 
61
+                                                        console.log("ELIMINAR")
65 62
                                                     }} 
66 63
                                                     className="eliminar_producto">
67 64
                                                     {!isMovil ? <Deletei/> : "Eliminar"}

+ 10 - 3
src/Css/all.css

@@ -327,6 +327,13 @@ li.nav-item {
327 327
     border-radius: 2px;
328 328
     box-shadow: 0 1px 2px rgba(0,0,0,.15), 0 -1px 0 rgba(0,0,0,.02); 
329 329
 }
330
+.body-table-responsive {
331
+    font-size:13px;
332
+    padding: 2px;
333
+    background: #24344d;
334
+    border-radius: 2px;
335
+    box-shadow: 0 1px 2px rgba(0,0,0,.15), 0 -1px 0 rgba(0,0,0,.02); 
336
+}
330 337
 .body-table th {
331 338
     font-size: 14px;
332 339
     color: #fff;
@@ -1302,7 +1309,7 @@ button.restore_btn:hover {
1302 1309
     background: #2ec5d3;
1303 1310
     border: 1px solid transparent;
1304 1311
     color: #fff;
1305
-    padding: 8px 20px;
1312
+    padding: 3px 7px;
1306 1313
     border-radius: 20px;
1307 1314
     transition: all 0.3s;
1308 1315
 }
@@ -1316,7 +1323,7 @@ button.restore_btn:hover {
1316 1323
     background: #5893df!important;
1317 1324
     border: 1px solid transparent;
1318 1325
     color: #fff;
1319
-    padding: 8px 20px;
1326
+    padding: 3px 7px;
1320 1327
     border-radius: 20px;
1321 1328
     transition: all 0.3s;
1322 1329
 }
@@ -1330,7 +1337,7 @@ button.restore_btn:hover {
1330 1337
     background: #ec5e69!important;
1331 1338
     border: 1px solid transparent;
1332 1339
     color: #fff;
1333
-    padding: 8px 20px;
1340
+    padding: 3px 7px;
1334 1341
     border-radius: 20px;
1335 1342
     transition: all 0.3s;
1336 1343
 }

+ 7 - 4
src/Pages/Puestos.jsx

@@ -32,7 +32,6 @@ import { ErrorMessage } from '../Components/Generics/Error'
32 32
 import { useQuery } from 'react-query';
33 33
 
34 34
 export function Puestos() {
35
-    console.log("render puestos")
36 35
 
37 36
     const auth = useAuth();
38 37
     const token = auth.getToken();
@@ -83,9 +82,12 @@ export function Puestos() {
83 82
                 setEdit(!edit)
84 83
                 break;
85 84
             }
85
+            case "DEL": {
86
+                setDelete(!del)
87
+                break;
88
+            }
86 89
             default: break;
87 90
         }
88
-        console.table(edit,del,show)
89 91
     },[edit,del,show])
90 92
 
91 93
     if (isLoading){
@@ -114,7 +116,7 @@ export function Puestos() {
114 116
         <div className="content-section">
115 117
             <div className="main">
116 118
                 <Box sx={{}}>
117
-                    <Paper sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh' }}>
119
+                    <Paper sx={{ mb: 2, padding: 2, }}>
118 120
 
119 121
                         <Row style={{ paddingBottom: 15 }}>
120 122
                             <Col md="2" sm="2" xs="2">
@@ -141,7 +143,7 @@ export function Puestos() {
141 143
                         </Row>
142 144
 
143 145
                         <div >
144
-                            <div className={`main_productos ${alignment === 'grid' ? 'activar_vista' : 'desactivar_vista'}`} id="grid_view">
146
+                            <div  className={`main_productos ${alignment === 'grid' ? 'activar_vista' : 'desactivar_vista'}`} id="grid_view">
145 147
                                 <Row>
146 148
                                     <GridMode
147 149
                                         toggle={toggle}
@@ -154,6 +156,7 @@ export function Puestos() {
154 156
                             <div className={`main_list_products ${alignment === 'list' ? 'activar_vista' : 'desactivar_vista'}`} id="list_view_products">
155 157
                                 <Row>
156 158
                                     <ListMode
159
+                                        toggle={toggle}
157 160
                                         showing={alignment}
158 161
                                         data={Divide( result.data )}
159 162
                                         index={page - 1}

+ 1 - 1
src/Utils/Paginate.js

@@ -1,5 +1,5 @@
1 1
 export function Divide(arregloOriginal){
2
-    const LONGITUD_PEDAZOS = 6;
2
+    const LONGITUD_PEDAZOS = 9;
3 3
     let arregloDeArreglos = [];
4 4
     for (let i = 0; i < arregloOriginal.length; i += LONGITUD_PEDAZOS) {
5 5
         let pedazo = arregloOriginal.slice(i, i + LONGITUD_PEDAZOS);