Browse Source

feedback update

amenpunk 3 years ago
parent
commit
b44b323be6

+ 0 - 2
src/App.js

6
 import { Container } from 'react-bootstrap'
6
 import { Container } from 'react-bootstrap'
7
 import { AuthProvider } from './Auth/AuthProvider'
7
 import { AuthProvider } from './Auth/AuthProvider'
8
 import { QueryClient, QueryClientProvider } from 'react-query'
8
 import { QueryClient, QueryClientProvider } from 'react-query'
9
-import { ReactQueryDevtools } from 'react-query/devtools'
10
 
9
 
11
 import Routes from './Components/Routes'
10
 import Routes from './Components/Routes'
12
 const queryClient = new QueryClient({
11
 const queryClient = new QueryClient({
40
                     </API_GATEWAY.Provider>
39
                     </API_GATEWAY.Provider>
41
                 </AuthProvider>
40
                 </AuthProvider>
42
             </Router>
41
             </Router>
43
-            <ReactQueryDevtools initialIsOpen={false} />
44
         </QueryClientProvider>
42
         </QueryClientProvider>
45
     );
43
     );
46
 }
44
 }

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

1
 import React from "react";
1
 import React from "react";
2
 import '../../Css/loading.css'
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
     return(
11
     return(
16
         <div className="loading_or_content">
12
         <div className="loading_or_content">
17
             <div className="snippet" data-title=".dot-pulse">
13
             <div className="snippet" data-title=".dot-pulse">
18
                 <div className="stage">
14
                 <div className="stage">
19
-                    <div className="dot-pulse"></div>
15
+                    <div className={types[0]}></div>
20
                 </div>
16
                 </div>
21
             </div>
17
             </div>
22
         </div>
18
         </div>

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

2
 import * as Yup from 'yup';
2
 import * as Yup from 'yup';
3
 import { useFormik, Form, FormikProvider } from 'formik';
3
 import { useFormik, Form, FormikProvider } from 'formik';
4
 import { Modal } from 'react-bootstrap'
4
 import { Modal } from 'react-bootstrap'
5
+import toast, { Toaster } from 'react-hot-toast';
5
 
6
 
6
 import DateFnsUtils from '@date-io/date-fns';
7
 import DateFnsUtils from '@date-io/date-fns';
7
 import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
8
 import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
33
         puestosuperior: Yup.number("El puesto superior debe ser un número").required("El puesto es requerido"),
34
         puestosuperior: Yup.number("El puesto superior debe ser un número").required("El puesto es requerido"),
34
         aredepto: Yup.number().required('Escoge alguna área'),
35
         aredepto: Yup.number().required('Escoge alguna área'),
35
         fecha: Yup.date("Ingresa una fecha válida"),
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
     const [departamento, setDepartamento] = React.useState('');
40
     const [departamento, setDepartamento] = React.useState('');
76
                     resetForm();
77
                     resetForm();
77
                     onClose();
78
                     onClose();
78
                     queryClient.invalidateQueries('puestos')
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
                 onClick={handleClose} >
202
                 onClick={handleClose} >
197
                 <CircularProgress color="inherit" />
203
                 <CircularProgress color="inherit" />
198
             </Backdrop>
204
             </Backdrop>
199
-
205
+            <Toaster position="top-right" />
200
         </Modal>
206
         </Modal>
201
     )
207
     )
202
 }
208
 }

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

2
 import * as Yup from 'yup';
2
 import * as Yup from 'yup';
3
 import { useFormik, Form, FormikProvider } from 'formik';
3
 import { useFormik, Form, FormikProvider } from 'formik';
4
 import { Modal } from 'react-bootstrap'
4
 import { Modal } from 'react-bootstrap'
5
+import toast, { Toaster } from 'react-hot-toast';
5
 
6
 
6
 import DateFnsUtils from '@date-io/date-fns';
7
 import DateFnsUtils from '@date-io/date-fns';
7
 import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
8
 import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
38
     let { visible, toggle, puesto } = props
39
     let { visible, toggle, puesto } = props
39
 
40
 
40
     const [departamento, setDepartamento] = React.useState('');
41
     const [departamento, setDepartamento] = React.useState('');
41
-    // const [open, setOpen] = React.useState(false);
42
+    const [open, setOpen] = React.useState(false);
42
 
43
 
43
     const changeDepartamento = useCallback((event) => {
44
     const changeDepartamento = useCallback((event) => {
44
         setDepartamento(event.target.value);
45
         setDepartamento(event.target.value);
73
             notas: ""
74
             notas: ""
74
         },
75
         },
75
         onSubmit: (fields, { resetForm }) => {
76
         onSubmit: (fields, { resetForm }) => {
77
+            setOpen(true);
76
             fields['fecha'] = new Date(fields.fecha).toISOString();
78
             fields['fecha'] = new Date(fields.fecha).toISOString();
77
 
79
 
78
             puestoMutation.mutate(fields, {
80
             puestoMutation.mutate(fields, {
79
                 onSuccess: () => {
81
                 onSuccess: () => {
80
                     close();
82
                     close();
83
+                    setOpen(false)
84
+                    toast.success("Puesto Actualizado!!")
81
                     queryClient.invalidateQueries('puestos')
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
                 </FormikProvider>
220
                 </FormikProvider>
212
             </Modal.Body>
221
             </Modal.Body>
213
             <Backdrop
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
                 <CircularProgress color="inherit" />
226
                 <CircularProgress color="inherit" />
219
             </Backdrop>
227
             </Backdrop>
228
+            <Toaster position="top-right" />
220
 
229
 
221
         </Modal>
230
         </Modal>
222
     )
231
     )

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

57
         <List>
57
         <List>
58
             <ListSubheader inset>MENÚ</ListSubheader>
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
             <ListItem selected={open} onClick={showPruebas}>
64
             <ListItem selected={open} onClick={showPruebas}>
74
             <Collapse in={open} timeout="auto" unmountOnExit>
74
             <Collapse in={open} timeout="auto" unmountOnExit>
75
                 <List component="div" disablePadding>
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
                 </List>
81
                 </List>

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

8
 export function ListMode(props) {
8
 export function ListMode(props) {
9
     
9
     
10
     const opciones = { weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' };
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
     const isMovil = Size('(min-width:770px)');
13
     const isMovil = Size('(min-width:770px)');
14
 
14
 
15
     return(
15
     return(
16
         <Col md="12">
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
                     <thead>
19
                     <thead>
20
                         <tr >
20
                         <tr >
21
-                            <th className="text-center">Nombre de la plaza</th>
21
+                            <th className="text-center">Nombre</th>
22
                             <th className="text-center">Descripción</th>
22
                             <th className="text-center">Descripción</th>
23
                             <th className="text-center">Creacion</th>
23
                             <th className="text-center">Creacion</th>
24
-                            <th className="text-center">Acciones</th>
24
+                            <th className="text-center">Acción</th>
25
                         </tr>
25
                         </tr>
26
                     </thead>
26
                     </thead>
27
                     <tbody>
27
                     <tbody>
31
                                     return (
31
                                     return (
32
                                     <Zoom key={plaza.id} in={true}>
32
                                     <Zoom key={plaza.id} in={true}>
33
                                         <tr >
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
                                             <TableCell
37
                                             <TableCell
38
                                                 sx={{
38
                                                 sx={{
39
                                                     "display":'flex',
39
                                                     "display":'flex',
44
                                                 className="actions_butons_plaza"> 
44
                                                 className="actions_butons_plaza"> 
45
                                                 <Button 
45
                                                 <Button 
46
                                                     onClick={() => {
46
                                                     onClick={() => {
47
-                                                        setPuesto(plaza) 
48
-                                                        setShow(true)
47
+                                                        console.log("VER")
49
                                                     }} 
48
                                                     }} 
50
                                                     className="ver_producto">
49
                                                     className="ver_producto">
51
                                                     {!isMovil ? <ShowI/> : "Ver"}
50
                                                     {!isMovil ? <ShowI/> : "Ver"}
52
                                                 </Button>
51
                                                 </Button>
53
                                                 <Button 
52
                                                 <Button 
54
                                                     onClick={() => {
53
                                                     onClick={() => {
55
-                                                        setPuesto(plaza) 
56
-                                                        setEdit(true)
54
+                                                        console.log("EDITAR")
57
                                                     }} 
55
                                                     }} 
58
                                                     className="editar_producto">
56
                                                     className="editar_producto">
59
                                                     {!isMovil ? <EditI/> : "Editar"}
57
                                                     {!isMovil ? <EditI/> : "Editar"}
60
                                                 </Button>
58
                                                 </Button>
61
                                                 <Button 
59
                                                 <Button 
62
                                                     onClick={() => {
60
                                                     onClick={() => {
63
-                                                        setPuesto(plaza) 
64
-                                                        setDelete(true) 
61
+                                                        console.log("ELIMINAR")
65
                                                     }} 
62
                                                     }} 
66
                                                     className="eliminar_producto">
63
                                                     className="eliminar_producto">
67
                                                     {!isMovil ? <Deletei/> : "Eliminar"}
64
                                                     {!isMovil ? <Deletei/> : "Eliminar"}

+ 10 - 3
src/Css/all.css

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

+ 7 - 4
src/Pages/Puestos.jsx

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

+ 1 - 1
src/Utils/Paginate.js

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