Bladeren bron

new apis fixes

amenpunk 1 jaar geleden
bovenliggende
commit
04b853435f

+ 312 - 26
src/Components/Modal/AgregarManual.js

@@ -1,7 +1,6 @@
1 1
 import React, { memo } from 'react';
2 2
 import * as Yup from 'yup';
3 3
 import { useFormik, Form, FormikProvider } from 'formik';
4
-import { Dialog, DialogContent, DialogTitle, DialogActions } from '@mui/material'
5 4
 import toast from 'react-hot-toast';
6 5
 
7 6
 import { AdapterDateFns as DateFnsUtils } from '@mui/x-date-pickers/AdapterDateFns';
@@ -11,14 +10,20 @@ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
11 10
 import {
12 11
   Button, Stack, TextField, MenuItem, FormControl, InputLabel, Select,
13 12
   Backdrop, CircularProgress, Box, Divider,
14
-  Tabs, Tab, FormGroup, Checkbox, FormControlLabel
13
+  Tabs, Tab, FormGroup, Checkbox, FormControlLabel,
14
+  Dialog, DialogContent, DialogTitle, DialogActions,
15
+  DialogContentText,
15 16
 } from '@mui/material';
16 17
 
18
+import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
19
+
17 20
 import { Service } from '../../Utils/HTTP';
18 21
 import { useQuery, useMutation, useQueryClient } from 'react-query';
19 22
 import { TabPanel } from './TabPanel'
20 23
 import { useSelector } from 'react-redux';
21 24
 
25
+const filter = createFilterOptions();
26
+
22 27
 function Manual(props) {
23 28
 
24 29
   const auth = useSelector((state) => state.token)
@@ -39,7 +44,7 @@ function Manual(props) {
39 44
 
40 45
   const NewPlazaSchema = Yup.object().shape({
41 46
     nombrepuesto: Yup.string().required('El nombre es requerido').min(5, "El nombre del  puesto debe ser mayor a 5 caracteres").max(100),
42
-    puestosuperior: Yup.number("El puesto superior debe ser un número").required("El puesto es requerido"),
47
+    puestosuperior: Yup.string().required("El puesto es requerido").min(5, "El nombre del  puesto debe ser mayor a 5 caracteres").max(15),
43 48
     aredepto: Yup.number().required('Escoge alguna área'),
44 49
     fecha: Yup.date("Ingresa una fecha válida"),
45 50
     notas: Yup.string("Ingresa una nota válida").min(5, "Ingresa una nota válida").max(150),
@@ -47,7 +52,7 @@ function Manual(props) {
47 52
   })
48 53
 
49 54
   const [departamento, setDepartamento] = React.useState('');
50
-  const [puestoSup, setPuestoSup] = React.useState('');
55
+  const [puestoSup, setPuestoSup] = React.useState('The Godfather');
51 56
   const [open, setOpen] = React.useState(false);
52 57
   const [date, setDate] = React.useState(new Date());
53 58
   const [tab, setTab] = React.useState(0);
@@ -63,6 +68,52 @@ function Manual(props) {
63 68
     setPuestoSup(event.target.value);
64 69
   };
65 70
 
71
+  const [valueDialog, setValueDialog] = React.useState(null);
72
+  const [openDialog, toggleOpenDialog] = React.useState(false);
73
+
74
+  const handleCloseDialog = () => {
75
+    setDialogValue({
76
+      title: '',
77
+      year: '',
78
+    });
79
+    toggleOpenDialog(false);
80
+  };
81
+
82
+  const [dialogValue, setDialogValue] = React.useState({
83
+    title: '',
84
+    year: '',
85
+  });
86
+
87
+  const handleSubmitDialog = (event) => {
88
+    event.preventDefault();
89
+    setValueDialog({
90
+      title: dialogValue.title,
91
+      year: parseInt(dialogValue.year, 10),
92
+    });
93
+    handleCloseDialog();
94
+  };
95
+
96
+  const AutoCompleteChange = (event, newValue) => {
97
+    if (typeof newValue === 'string') {
98
+      // timeout to avoid instant validation of the dialog's form.
99
+      setTimeout(() => {
100
+        toggleOpenDialog(true);
101
+        setDialogValue({
102
+          title: newValue,
103
+          year: '',
104
+        });
105
+      });
106
+    } else if (newValue && newValue.inputValue) {
107
+      toggleOpenDialog(true);
108
+      setDialogValue({
109
+        title: newValue.inputValue,
110
+        year: '',
111
+      });
112
+    } else {
113
+      setValueDialog(newValue);
114
+    }
115
+  }
116
+
66 117
   const agregarPuesto = async (puesto) => {
67 118
     let rest = new Service('/plaza/save');
68 119
     return await rest.postQuery(puesto, auth.token);
@@ -75,7 +126,7 @@ function Manual(props) {
75 126
   const formik = useFormik({
76 127
     initialValues: {
77 128
       nombrepuesto: "",
78
-      puestosuperior: 1,
129
+      puestosuperior: "The Godfather",
79 130
       aredepto: 1,
80 131
       fecha: date,
81 132
       notas: "",
@@ -83,7 +134,7 @@ function Manual(props) {
83 134
     },
84 135
     onSubmit: (fields, { resetForm }) => {
85 136
 
86
-      if(fields.tests.length === 0){
137
+      if (fields.tests.length === 0) {
87 138
         toast.error("Recuerda que seleccionar al menos un test")
88 139
         setTab(1)
89 140
         return
@@ -139,9 +190,9 @@ function Manual(props) {
139 190
       aria-labelledby="contained-modal-title-vcenter"
140 191
       onClose={onClose}>
141 192
 
142
-      <DialogTitle>
193
+      <DialogTitle className="modal-title" style={{ color: '#252525' }}>
143 194
         <button onClick={onClose} type="button" className="close" data-dismiss="modal">&times;</button>
144
-        <h4 className="modal-title" style={{ color: '#252525' }}>Agregar Puesto</h4>
195
+        Agregar Puesto
145 196
       </DialogTitle>
146 197
 
147 198
       <DialogContent className="modal-body">
@@ -151,6 +202,54 @@ function Manual(props) {
151 202
           <Tab label="Pruebas" />
152 203
         </Tabs>
153 204
 
205
+        <Dialog open={openDialog} onClose={handleCloseDialog}>
206
+          <form onSubmit={handleSubmitDialog}>
207
+            <DialogTitle>Agrega un nuevo Puesto</DialogTitle>
208
+            <DialogContent>
209
+              <DialogContentText>
210
+                Agrega la descripcion del puesto
211
+              </DialogContentText>
212
+
213
+              <TextField
214
+                autoFocus
215
+                margin="dense"
216
+                id="name"
217
+                value={dialogValue.title}
218
+                onChange={(event) =>
219
+                  setDialogValue({
220
+                    ...dialogValue,
221
+                    title: event.target.value,
222
+                  })
223
+                }
224
+                label="Puesto"
225
+                type="text"
226
+                variant="standard"
227
+              />
228
+
229
+              <TextField
230
+                margin="dense"
231
+                id="name"
232
+                value={dialogValue.year}
233
+                onChange={(event) =>
234
+                  setDialogValue({
235
+                    ...dialogValue,
236
+                    year: event.target.value,
237
+                  })
238
+                }
239
+                label="Descripción"
240
+                type="text"
241
+                variant="standard"
242
+              />
243
+            </DialogContent>
244
+            <DialogActions>
245
+              <Button onClick={handleCloseDialog}>Cancelar</Button>
246
+              <Button type="submit">Agregar</Button>
247
+            </DialogActions>
248
+          </form>
249
+        </Dialog>
250
+
251
+
252
+
154 253
         <FormikProvider style={{ paddingTop: 25 }} value={formik}>
155 254
           <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
156 255
 
@@ -185,7 +284,6 @@ function Manual(props) {
185 284
 
186 285
               <Stack spacing={3}>
187 286
 
188
-
189 287
                 <Stack direction={{ xs: 'column', sm: 'row' }} spacing={4}>
190 288
                   <TextField
191 289
                     label="Nombre"
@@ -196,24 +294,84 @@ function Manual(props) {
196 294
                   />
197 295
 
198 296
                   <FormControl fullWidth>
297
+
298
+                    {/*
199 299
                     <InputLabel id="demo-simple-select-label">Puesto Superior</InputLabel>
200
-                    <Select
201
-                      labelId="demo-simple-select-label"
202
-                      value={puestoSup}
203
-                      label="Puesto Superior"
204
-                      onChange={changePuestoSup}
205
-                      {...getFieldProps('puestosuperior')}
206
-                      error={Boolean(touched.puestosuperior && errors.puestosuperior)} >
207
-                      {
208
-                        data ?
209
-                          data.data.map(cate => {
210
-                            return (
211
-                              <MenuItem key={cate.id} value={cate.id}>{cate.nombre}</MenuItem>
212
-                            )
213
-                          })
214
-                          : <MenuItem>Null</MenuItem>
215
-                      }
216
-                    </Select>
300
+                      <Select
301
+                        labelId="demo-simple-select-label"
302
+                        value={puestoSup}
303
+                        label="Puesto Superior"
304
+                        onChange={changePuestoSup}
305
+                        {...getFieldProps('puestosuperior')}
306
+                        error={Boolean(touched.puestosuperior && errors.puestosuperior)} >
307
+                        {
308
+                          data ?
309
+                            data.data.map(cate => {
310
+                              return (
311
+                                <MenuItem key={cate.id} value={cate.id}>{cate.nombre}</MenuItem>
312
+                              )
313
+                            })
314
+                            : <MenuItem>Null</MenuItem>
315
+                        }
316
+                      </Select>
317
+*/}
318
+
319
+
320
+                    <Autocomplete
321
+                      fullWidth
322
+                      value={valueDialog}
323
+                      onChange={AutoCompleteChange}
324
+                      filterOptions={(options, params) => {
325
+                        const filtered = filter(options, params);
326
+
327
+                        if (params.inputValue !== '') {
328
+                          filtered.push({
329
+                            inputValue: params.inputValue,
330
+                            title: `Add "${params.inputValue}"`,
331
+                          });
332
+                        }
333
+
334
+                        return filtered;
335
+                      }}
336
+                      id="puesto_superior_autocomplete"
337
+                      options={top100Films}
338
+                      getOptionLabel={(option) => {
339
+                        if (typeof option === 'string') {
340
+                          return option;
341
+                        }
342
+                        if (option.inputValue) {
343
+                          return option.inputValue;
344
+                        }
345
+                        return option.title;
346
+                      }}
347
+                      selectOnFocus
348
+                      clearOnBlur
349
+                      handleHomeEndKeys
350
+                      renderOption={(props, option) => <li {...props}>{option.title}</li>}
351
+                      freeSolo
352
+                      renderInput={(params) => <TextField {...params} label="Puesto Superior" />}
353
+                    />
354
+
355
+
356
+
357
+                    {/*
358
+                      <Autocomplete
359
+                        id="grouped-demo"
360
+                        value={puestoSup}
361
+                        label="Puesto Superior"
362
+                        freeSolo
363
+                        options={top100Films.map((option) => option.title)}
364
+                        renderInput={(params) =>
365
+                          <TextField
366
+                            onChange={changePuestoSup}
367
+                            error={Boolean(touched.puestosuperior && errors.puestosuperior)}
368
+                            {...getFieldProps('puestosuperior')}
369
+                            {...params}
370
+                            label="Puesto Superior" />
371
+                        }
372
+                      />
373
+*/}
374
+
217 375
                   </FormControl>
218 376
 
219 377
                 </Stack>
@@ -306,3 +464,131 @@ function Manual(props) {
306 464
   )
307 465
 }
308 466
 export default memo(Manual);
467
+
468
+const top100Films = [
469
+  { title: 'The Shawshank Redemption', year: 1994 },
470
+  { title: 'The Godfather', year: 1972 },
471
+  { title: 'The Godfather: Part II', year: 1974 },
472
+  { title: 'The Dark Knight', year: 2008 },
473
+  { title: '12 Angry Men', year: 1957 },
474
+  { title: "Schindler's List", year: 1993 },
475
+  { title: 'Pulp Fiction', year: 1994 },
476
+  {
477
+    title: 'The Lord of the Rings: The Return of the King',
478
+    year: 2003,
479
+  },
480
+  { title: 'The Good, the Bad and the Ugly', year: 1966 },
481
+  { title: 'Fight Club', year: 1999 },
482
+  {
483
+    title: 'The Lord of the Rings: The Fellowship of the Ring',
484
+    year: 2001,
485
+  },
486
+  {
487
+    title: 'Star Wars: Episode V - The Empire Strikes Back',
488
+    year: 1980,
489
+  },
490
+  { title: 'Forrest Gump', year: 1994 },
491
+  { title: 'Inception', year: 2010 },
492
+  {
493
+    title: 'The Lord of the Rings: The Two Towers',
494
+    year: 2002,
495
+  },
496
+  { title: "One Flew Over the Cuckoo's Nest", year: 1975 },
497
+  { title: 'Goodfellas', year: 1990 },
498
+  { title: 'The Matrix', year: 1999 },
499
+  { title: 'Seven Samurai', year: 1954 },
500
+  {
501
+    title: 'Star Wars: Episode IV - A New Hope',
502
+    year: 1977,
503
+  },
504
+  { title: 'City of God', year: 2002 },
505
+  { title: 'Se7en', year: 1995 },
506
+  { title: 'The Silence of the Lambs', year: 1991 },
507
+  { title: "It's a Wonderful Life", year: 1946 },
508
+  { title: 'Life Is Beautiful', year: 1997 },
509
+  { title: 'The Usual Suspects', year: 1995 },
510
+  { title: 'Léon: The Professional', year: 1994 },
511
+  { title: 'Spirited Away', year: 2001 },
512
+  { title: 'Saving Private Ryan', year: 1998 },
513
+  { title: 'Once Upon a Time in the West', year: 1968 },
514
+  { title: 'American History X', year: 1998 },
515
+  { title: 'Interstellar', year: 2014 },
516
+  { title: 'Casablanca', year: 1942 },
517
+  { title: 'City Lights', year: 1931 },
518
+  { title: 'Psycho', year: 1960 },
519
+  { title: 'The Green Mile', year: 1999 },
520
+  { title: 'The Intouchables', year: 2011 },
521
+  { title: 'Modern Times', year: 1936 },
522
+  { title: 'Raiders of the Lost Ark', year: 1981 },
523
+  { title: 'Rear Window', year: 1954 },
524
+  { title: 'The Pianist', year: 2002 },
525
+  { title: 'The Departed', year: 2006 },
526
+  { title: 'Terminator 2: Judgment Day', year: 1991 },
527
+  { title: 'Back to the Future', year: 1985 },
528
+  { title: 'Whiplash', year: 2014 },
529
+  { title: 'Gladiator', year: 2000 },
530
+  { title: 'Memento', year: 2000 },
531
+  { title: 'The Prestige', year: 2006 },
532
+  { title: 'The Lion King', year: 1994 },
533
+  { title: 'Apocalypse Now', year: 1979 },
534
+  { title: 'Alien', year: 1979 },
535
+  { title: 'Sunset Boulevard', year: 1950 },
536
+  {
537
+    title: 'Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb',
538
+    year: 1964,
539
+  },
540
+  { title: 'The Great Dictator', year: 1940 },
541
+  { title: 'Cinema Paradiso', year: 1988 },
542
+  { title: 'The Lives of Others', year: 2006 },
543
+  { title: 'Grave of the Fireflies', year: 1988 },
544
+  { title: 'Paths of Glory', year: 1957 },
545
+  { title: 'Django Unchained', year: 2012 },
546
+  { title: 'The Shining', year: 1980 },
547
+  { title: 'WALL·E', year: 2008 },
548
+  { title: 'American Beauty', year: 1999 },
549
+  { title: 'The Dark Knight Rises', year: 2012 },
550
+  { title: 'Princess Mononoke', year: 1997 },
551
+  { title: 'Aliens', year: 1986 },
552
+  { title: 'Oldboy', year: 2003 },
553
+  { title: 'Once Upon a Time in America', year: 1984 },
554
+  { title: 'Witness for the Prosecution', year: 1957 },
555
+  { title: 'Das Boot', year: 1981 },
556
+  { title: 'Citizen Kane', year: 1941 },
557
+  { title: 'North by Northwest', year: 1959 },
558
+  { title: 'Vertigo', year: 1958 },
559
+  {
560
+    title: 'Star Wars: Episode VI - Return of the Jedi',
561
+    year: 1983,
562
+  },
563
+  { title: 'Reservoir Dogs', year: 1992 },
564
+  { title: 'Braveheart', year: 1995 },
565
+  { title: 'M', year: 1931 },
566
+  { title: 'Requiem for a Dream', year: 2000 },
567
+  { title: 'Amélie', year: 2001 },
568
+  { title: 'A Clockwork Orange', year: 1971 },
569
+  { title: 'Like Stars on Earth', year: 2007 },
570
+  { title: 'Taxi Driver', year: 1976 },
571
+  { title: 'Lawrence of Arabia', year: 1962 },
572
+  { title: 'Double Indemnity', year: 1944 },
573
+  {
574
+    title: 'Eternal Sunshine of the Spotless Mind',
575
+    year: 2004,
576
+  },
577
+  { title: 'Amadeus', year: 1984 },
578
+  { title: 'To Kill a Mockingbird', year: 1962 },
579
+  { title: 'Toy Story 3', year: 2010 },
580
+  { title: 'Logan', year: 2017 },
581
+  { title: 'Full Metal Jacket', year: 1987 },
582
+  { title: 'Dangal', year: 2016 },
583
+  { title: 'The Sting', year: 1973 },
584
+  { title: '2001: A Space Odyssey', year: 1968 },
585
+  { title: "Singin' in the Rain", year: 1952 },
586
+  { title: 'Toy Story', year: 1995 },
587
+  { title: 'Bicycle Thieves', year: 1948 },
588
+  { title: 'The Kid', year: 1921 },
589
+  { title: 'Inglourious Basterds', year: 2009 },
590
+  { title: 'Snatch', year: 2000 },
591
+  { title: '3 Idiots', year: 2009 },
592
+  { title: 'Monty Python and the Holy Grail', year: 1975 },
593
+];
594
+

+ 1 - 1
src/Components/Puestos/Card.jsx

@@ -16,7 +16,7 @@ export function PuestoCard(props) {
16 16
     return (
17 17
         <Card sx={{ maxWidth: 345 }}>
18 18
             <CardMedia
19
-        className="cardmedia_puesto"
19
+                className="cardmedia_puesto"
20 20
                 component="img"
21 21
                 alt="green iguana"
22 22
                 height="140"

+ 171 - 0
src/Components/Resultados/Config.jsx

@@ -0,0 +1,171 @@
1
+import { createTheme } from '@mui/material';
2
+
3
+export const TableStyle = () => createTheme({
4
+  components: {
5
+
6
+    MuiSvgIcon: {
7
+      styleOverrides: {
8
+        root: {
9
+          color: 'var(--main)'
10
+        }
11
+      }
12
+    },
13
+
14
+    MUIDataTableSelectCell: {
15
+      styleOverrides: {
16
+        root: {
17
+          backgroundColor: '#FFF'
18
+        }
19
+      }
20
+    },
21
+    MuiCheckbox: {
22
+      styleOverrides: {
23
+        root: {
24
+          color: 'var(--main)'
25
+        }
26
+      }
27
+    },
28
+    MuiChecked: {
29
+      styleOverrides: {
30
+        root: {
31
+          color: 'red'
32
+        }
33
+      }
34
+    },
35
+    MUIDataTableToolbar: {
36
+      styleOverrides: {
37
+        root: {
38
+          paddingLeft: 15
39
+        }
40
+      }
41
+    },
42
+    MuiRowSelected: {
43
+      styleOverrides: {
44
+        root: {
45
+          backgroundColor: "#FFF"
46
+        }
47
+      }
48
+    },
49
+    MuiPaper: {
50
+      styleOverrides: {
51
+        root: {
52
+          boxShadow: 'none'
53
+        }
54
+      }
55
+
56
+    },
57
+    MUIDataTableSelectedCell: {
58
+      styleOverrides: {
59
+        root: {
60
+          backgroundColor: "#FFF"
61
+        }
62
+      }
63
+    },
64
+    MUITableCell: {
65
+      styleOverrides: {
66
+        root: {
67
+          backgroundColor: "#FFF"
68
+        }
69
+      }
70
+    },
71
+    MUIDataTableBodyRow: {
72
+      styleOverrides: {
73
+        root: {
74
+          backgroundColor: "#FFF"
75
+        }
76
+      }
77
+    },
78
+    MUIDataTableBodyCell: {
79
+      styleOverrides: {
80
+        root: {
81
+          backgroundColor: "#FFF"
82
+        }
83
+      }
84
+    },
85
+    MuiTablePagination: {
86
+      styleOverrides: {
87
+        toolbar: {
88
+          paddingTop: 7,
89
+          alignItems: 'baseline'
90
+        }
91
+      }
92
+    }
93
+  }
94
+})
95
+
96
+export const Encabezados = [
97
+  {
98
+    name: 'id',
99
+    numeric: true,
100
+    label: 'ID',
101
+    options: {
102
+      display: false
103
+    }
104
+  },
105
+  {
106
+    name: 'pwd',
107
+    numeric: false,
108
+    disablePadding: true,
109
+    label: 'Contraseña',
110
+  },
111
+  {
112
+    name: 'users',
113
+    numeric: false,
114
+    disablePadding: true,
115
+    label: 'Usuarios',
116
+  },
117
+  {
118
+    name: 'asings',
119
+    numeric: false,
120
+    disablePadding: true,
121
+    label: 'Asignaciones',
122
+  },
123
+]
124
+
125
+
126
+export const TextLabels = {
127
+  body: {
128
+    noMatch: "No se encontró ningún elemento",
129
+    toolTip: "Ordenar",
130
+    columnHeaderTooltip: column => `Ordenar por ${column.label}`
131
+  },
132
+  pagination: {
133
+    next: "Siguiente Pagina",
134
+    previous: "Pagina Anterior",
135
+    rowsPerPage: "Elementos por Página",
136
+    displayRows: "de",
137
+  },
138
+  toolbar: {
139
+    search: "Buscar",
140
+    downloadCsv: "Descargar CSV",
141
+    print: "Imprimir",
142
+    viewColumns: "Seleccionar Columnas",
143
+    filterTable: "Filtrar Tabla",
144
+  },
145
+  filter: {
146
+    all: "Todos",
147
+    title: "FILTROS",
148
+    reset: "Limpiar",
149
+  },
150
+  viewColumns: {
151
+    title: "Mostrar Columnas",
152
+    titleAria: "Mostrar/Ocultar Columnas",
153
+  },
154
+  selectedRows: {
155
+    text: "Elemento(s) selecionado",
156
+    delete: "Eliminar",
157
+    deleteAria: "Eliminar Columnas Seleccionadas",
158
+  },
159
+}
160
+
161
+export const BuildColumns = (columns) => {
162
+  return columns.map((column) => {
163
+    return {
164
+      'id' : 0,
165
+      'pwd' : atob( column.pwd ),
166
+      'users' : "",
167
+      'asings' : "",
168
+    }
169
+  })
170
+
171
+}

+ 46 - 0
src/Components/Resultados/TestDataTable.jsx

@@ -0,0 +1,46 @@
1
+// import { useEffect } from 'react';
2
+import { ThemeProvider } from '@mui/material/styles';
3
+import { TableStyle, Encabezados, BuildColumns } from './Config'
4
+import { useSelector } from 'react-redux';
5
+import { useQuery } from 'react-query';
6
+import { Service } from '../../Utils/HTTP'
7
+import MUIDataTable from "mui-datatables";
8
+
9
+export const TestDataTable = () => {
10
+  
11
+  const auth = useSelector((state) => state.token)
12
+
13
+  const options = {
14
+    filterType: 'checkbox',
15
+    customToolbar: () => { },
16
+    // textLabels: TextLabels,
17
+    onRowClick: (test) => {
18
+      console.log(test)
19
+      // let [plaza, pwd] = password;
20
+      // setPassword({pwd,plz:plaza});
21
+      // setVisible(true);
22
+    },
23
+    elevation: 9
24
+  };
25
+
26
+  const getAllPwd = async () => {
27
+    let rest = new Service('/contrasenia/getallbyidUsr');
28
+    return await rest.getQuery(auth.token)
29
+  }
30
+
31
+  const { data, status } = useQuery('homepwd', getAllPwd);
32
+  console.log('DATA: ', data)
33
+
34
+
35
+  return (
36
+    <ThemeProvider theme={TableStyle}>
37
+      <MUIDataTable
38
+        sx={{ '& MuiPaper': { elevation: 0, boxShadow: 'none', color: "red" } }}
39
+        title={"Expedientes"}
40
+        data={BuildColumns( status === 'success' ? data.data : [])}
41
+        columns={Encabezados}
42
+        options={options}
43
+      />
44
+    </ThemeProvider>
45
+  )
46
+}

+ 1 - 0
src/Components/Routes.js

@@ -63,6 +63,7 @@ export default function MyRoutes() {
63 63
           </RequireToken>
64 64
         }>
65 65
 
66
+        <Route path="" element={<Home />} />
66 67
         <Route path="home" element={<Home />} />
67 68
         <Route path="puestos" element={<Puestos />} />
68 69
         <Route path="perfil" element={<Profile />} />

+ 1 - 0
src/Pages/Login.jsx

@@ -68,6 +68,7 @@ export function Login() {
68 68
           toast.success(`Bienvenido ${nombre} ${apelidos} !!`)
69 69
           token = token.replace("Bearer ", "")
70 70
           console.log("TOKEN: ", token)
71
+          window.token = token;
71 72
           let body_token = jwt_decode(token);
72 73
           let timestamp = body_token.exp * 1000;
73 74
           let restante = timestamp - Date.now();

+ 2 - 2
src/Pages/Puestos.jsx

@@ -139,7 +139,7 @@ export function Puestos() {
139 139
             </Row>
140 140
             <div style={{ padding: 7 }}>
141 141
               <div className={` main_grid_plazas main_productos ${alignment === 'grid' ? 'activar_vista' : 'desactivar_vista'}`} id="grid_view">
142
-                <Row style={{ minHeight: '75vh' }}>
142
+                <Row style={{ minHeight: '57vh' }}>
143 143
                   <GridMode
144 144
                     toggle={toggle}
145 145
                     showing={alignment}
@@ -149,7 +149,7 @@ export function Puestos() {
149 149
                 </Row>
150 150
               </div>
151 151
               <div className={`main_list_products ${alignment === 'list' ? 'activar_vista' : 'desactivar_vista'}`} id="list_view_products">
152
-                <Row style={{ minHeight: '75vh' }}>
152
+                <Row style={{ minHeight: '57vh' }}>
153 153
                   <ListMode
154 154
                     toggle={toggle}
155 155
                     showing={alignment}

+ 25 - 17
src/Pages/Resultados.jsx

@@ -4,11 +4,14 @@ import { Service } from '../Utils/HTTP';
4 4
 import { useSelector } from 'react-redux';
5 5
 import { Document, Page, pdfjs } from 'react-pdf/dist/esm/entry.webpack';
6 6
 import { Loading } from '../Components/Generics/loading'
7
+import { TestDataTable } from '../Components/Resultados/TestDataTable'
7 8
 import DownloadIcon from '@mui/icons-material/Download';
8 9
 import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
9 10
 import 'react-pdf/dist/esm/Page/TextLayer.css';
10 11
 import '../pdf.css'
11 12
 // import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
13
+//
14
+//
12 15
 import { 
13 16
   Button, Box, Paper,LinearProgress,
14 17
   Typography
@@ -55,12 +58,6 @@ const MyDocument = (props) => {
55 58
 
56 59
   const [progress, setProgress] = useState(10);
57 60
 
58
-  if(!pdf){
59
-    <Loading/>
60
-  }
61
-
62
-  console.log(progress)
63
-
64 61
   return (
65 62
     <div>
66 63
 
@@ -107,17 +104,19 @@ const MyDocument = (props) => {
107 104
 
108 105
       <div className="Example__container">
109 106
         <div className="Example__container__document">
110
-          <Document 
111
-            renderMode="canvas" 
112
-            file={pdf?.data} 
113
-            onLoadSuccess={onDocumentLoadSuccess} 
114
-            loading={Loading}
115
-            onLoadProgress={({loaded, total}) => {
116
-              setProgress((loaded / total) * 100)
117
-            }}
118
-          >
107
+          { pdf ?
108
+            (<Document 
109
+              renderMode="canvas" 
110
+              file={pdf?.data} 
111
+              onLoadSuccess={onDocumentLoadSuccess} 
112
+              loading={Loading}
113
+              onLoadProgress={({loaded, total}) => {
114
+                setProgress((loaded / total) * 100)
115
+              }}
116
+            >
119 117
               <Page loading={Loading} pageNumber={pageNumber} />
120
-          </Document>
118
+            </Document>) : null
119
+          }
121 120
         </div>
122 121
       </div>
123 122
     </div>
@@ -133,6 +132,10 @@ export function Resultados() {
133 132
 
134 133
   useEffect(() => {
135 134
 
135
+    if(!id) {
136
+      console.log('no hay id')
137
+      return
138
+    }
136 139
     let url = `/report/cleaverResult/${id}?output=pdf`
137 140
     let rest = new Service(url);
138 141
 
@@ -152,7 +155,12 @@ export function Resultados() {
152 155
           <Paper 
153 156
             elevation={2} 
154 157
             sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh', boxShadow: 'none !important' }}>
155
-            <MyDocument token={auth.token} id={id} pdf={pdf} />
158
+            <h1>Reporte de Resultados</h1><hr/>
159
+            {
160
+              pdf ? 
161
+                ( <MyDocument token={auth.token} id={id} pdf={pdf} />) : null
162
+            }
163
+            <TestDataTable/>
156 164
           </Paper>
157 165
         </Box>
158 166
       </div>

+ 262 - 44
src/temp.js

@@ -1,51 +1,269 @@
1 1
 import * as React from 'react';
2
-import dayjs from 'dayjs';
3
-import Stack from '@mui/material/Stack';
4 2
 import TextField from '@mui/material/TextField';
5
-import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
6
-import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
7
-import { TimePicker } from '@mui/x-date-pickers/TimePicker';
8
-import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
9
-import { DesktopDatePicker } from '@mui/x-date-pickers/DesktopDatePicker';
10
-import { MobileDatePicker } from '@mui/x-date-pickers/MobileDatePicker';
11
-
12
-export default function MaterialUIPickers() {
13
-  const [value, setValue] = React.useState(dayjs('2014-08-18T21:11:54'));
14
-
15
-  const handleChange = (newValue) => {
16
-    setValue(newValue);
3
+import Dialog from '@mui/material/Dialog';
4
+import DialogTitle from '@mui/material/DialogTitle';
5
+import DialogContent from '@mui/material/DialogContent';
6
+import DialogContentText from '@mui/material/DialogContentText';
7
+import DialogActions from '@mui/material/DialogActions';
8
+import Button from '@mui/material/Button';
9
+import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
10
+
11
+const filter = createFilterOptions();
12
+
13
+export default function FreeSoloCreateOptionDialog() {
14
+  const [value, setValue] = React.useState(null);
15
+  const [open, toggleOpen] = React.useState(false);
16
+
17
+  const handleClose = () => {
18
+    setDialogValue({
19
+      title: '',
20
+      year: '',
21
+    });
22
+    toggleOpen(false);
23
+  };
24
+
25
+  const [dialogValue, setDialogValue] = React.useState({
26
+    title: '',
27
+    year: '',
28
+  });
29
+
30
+  const handleSubmit = (event) => {
31
+    event.preventDefault();
32
+    setValue({
33
+      title: dialogValue.title,
34
+      year: parseInt(dialogValue.year, 10),
35
+    });
36
+    handleClose();
17 37
   };
18 38
 
19 39
   return (
20
-    <LocalizationProvider dateAdapter={AdapterDayjs}>
21
-      <Stack spacing={3}>
22
-        <DesktopDatePicker
23
-          label="Date desktop"
24
-          inputFormat="MM/DD/YYYY"
25
-          value={value}
26
-          onChange={handleChange}
27
-          renderInput={(params) => <TextField {...params} />}
28
-        />
29
-        <MobileDatePicker
30
-          label="Date mobile"
31
-          inputFormat="MM/DD/YYYY"
32
-          value={value}
33
-          onChange={handleChange}
34
-          renderInput={(params) => <TextField {...params} />}
35
-        />
36
-        <TimePicker
37
-          label="Time"
38
-          value={value}
39
-          onChange={handleChange}
40
-          renderInput={(params) => <TextField {...params} />}
41
-        />
42
-        <DateTimePicker
43
-          label="Date&Time picker"
44
-          value={value}
45
-          onChange={handleChange}
46
-          renderInput={(params) => <TextField {...params} />}
47
-        />
48
-      </Stack>
49
-    </LocalizationProvider>
40
+    <React.Fragment>
41
+      <Autocomplete
42
+        value={value}
43
+        onChange={(event, newValue) => {
44
+
45
+          if (typeof newValue === 'string') {
46
+            // timeout to avoid instant validation of the dialog's form.
47
+            setTimeout(() => {
48
+              toggleOpen(true);
49
+              setDialogValue({
50
+                title: newValue,
51
+                year: '',
52
+              });
53
+            });
54
+          } else if (newValue && newValue.inputValue) {
55
+            toggleOpen(true);
56
+            setDialogValue({
57
+              title: newValue.inputValue,
58
+              year: '',
59
+            });
60
+          } else {
61
+            setValue(newValue);
62
+          }
63
+        }}
64
+        filterOptions={(options, params) => {
65
+          const filtered = filter(options, params);
66
+
67
+          if (params.inputValue !== '') {
68
+            filtered.push({
69
+              inputValue: params.inputValue,
70
+              title: `Add "${params.inputValue}"`,
71
+            });
72
+          }
73
+
74
+          return filtered;
75
+        }}
76
+        id="free-solo-dialog-demo"
77
+        options={top100Films}
78
+        getOptionLabel={(option) => {
79
+          // e.g value selected with enter, right from the input
80
+          if (typeof option === 'string') {
81
+            return option;
82
+          }
83
+          if (option.inputValue) {
84
+            return option.inputValue;
85
+          }
86
+          return option.title;
87
+        }}
88
+        selectOnFocus
89
+        clearOnBlur
90
+        handleHomeEndKeys
91
+        renderOption={(props, option) => <li {...props}>{option.title}</li>}
92
+        sx={{ width: 300 }}
93
+        freeSolo
94
+        renderInput={(params) => <TextField {...params} label="Free solo dialog" />}
95
+      />
96
+      <Dialog open={open} onClose={handleClose}>
97
+        <form onSubmit={handleSubmit}>
98
+          <DialogTitle>Add a new film</DialogTitle>
99
+          <DialogContent>
100
+            <DialogContentText>
101
+              Did you miss any film in our list? Please, add it!
102
+            </DialogContentText>
103
+            <TextField
104
+              autoFocus
105
+              margin="dense"
106
+              id="name"
107
+              value={dialogValue.title}
108
+              onChange={(event) =>
109
+                setDialogValue({
110
+                  ...dialogValue,
111
+                  title: event.target.value,
112
+                })
113
+              }
114
+              label="title"
115
+              type="text"
116
+              variant="standard"
117
+            />
118
+            <TextField
119
+              margin="dense"
120
+              id="name"
121
+              value={dialogValue.year}
122
+              onChange={(event) =>
123
+                setDialogValue({
124
+                  ...dialogValue,
125
+                  year: event.target.value,
126
+                })
127
+              }
128
+              label="year"
129
+              type="number"
130
+              variant="standard"
131
+            />
132
+          </DialogContent>
133
+          <DialogActions>
134
+            <Button onClick={handleClose}>Cancel</Button>
135
+            <Button type="submit">Add</Button>
136
+          </DialogActions>
137
+        </form>
138
+      </Dialog>
139
+    </React.Fragment>
50 140
   );
51 141
 }
142
+
143
+// Top 100 films as rated by IMDb users. http://www.imdb.com/chart/top
144
+const top100Films = [
145
+  { title: 'The Shawshank Redemption', year: 1994 },
146
+  { title: 'The Godfather', year: 1972 },
147
+  { title: 'The Godfather: Part II', year: 1974 },
148
+  { title: 'The Dark Knight', year: 2008 },
149
+  { title: '12 Angry Men', year: 1957 },
150
+  { title: "Schindler's List", year: 1993 },
151
+  { title: 'Pulp Fiction', year: 1994 },
152
+  {
153
+    title: 'The Lord of the Rings: The Return of the King',
154
+    year: 2003,
155
+  },
156
+  { title: 'The Good, the Bad and the Ugly', year: 1966 },
157
+  { title: 'Fight Club', year: 1999 },
158
+  {
159
+    title: 'The Lord of the Rings: The Fellowship of the Ring',
160
+    year: 2001,
161
+  },
162
+  {
163
+    title: 'Star Wars: Episode V - The Empire Strikes Back',
164
+    year: 1980,
165
+  },
166
+  { title: 'Forrest Gump', year: 1994 },
167
+  { title: 'Inception', year: 2010 },
168
+  {
169
+    title: 'The Lord of the Rings: The Two Towers',
170
+    year: 2002,
171
+  },
172
+  { title: "One Flew Over the Cuckoo's Nest", year: 1975 },
173
+  { title: 'Goodfellas', year: 1990 },
174
+  { title: 'The Matrix', year: 1999 },
175
+  { title: 'Seven Samurai', year: 1954 },
176
+  {
177
+    title: 'Star Wars: Episode IV - A New Hope',
178
+    year: 1977,
179
+  },
180
+  { title: 'City of God', year: 2002 },
181
+  { title: 'Se7en', year: 1995 },
182
+  { title: 'The Silence of the Lambs', year: 1991 },
183
+  { title: "It's a Wonderful Life", year: 1946 },
184
+  { title: 'Life Is Beautiful', year: 1997 },
185
+  { title: 'The Usual Suspects', year: 1995 },
186
+  { title: 'Léon: The Professional', year: 1994 },
187
+  { title: 'Spirited Away', year: 2001 },
188
+  { title: 'Saving Private Ryan', year: 1998 },
189
+  { title: 'Once Upon a Time in the West', year: 1968 },
190
+  { title: 'American History X', year: 1998 },
191
+  { title: 'Interstellar', year: 2014 },
192
+  { title: 'Casablanca', year: 1942 },
193
+  { title: 'City Lights', year: 1931 },
194
+  { title: 'Psycho', year: 1960 },
195
+  { title: 'The Green Mile', year: 1999 },
196
+  { title: 'The Intouchables', year: 2011 },
197
+  { title: 'Modern Times', year: 1936 },
198
+  { title: 'Raiders of the Lost Ark', year: 1981 },
199
+  { title: 'Rear Window', year: 1954 },
200
+  { title: 'The Pianist', year: 2002 },
201
+  { title: 'The Departed', year: 2006 },
202
+  { title: 'Terminator 2: Judgment Day', year: 1991 },
203
+  { title: 'Back to the Future', year: 1985 },
204
+  { title: 'Whiplash', year: 2014 },
205
+  { title: 'Gladiator', year: 2000 },
206
+  { title: 'Memento', year: 2000 },
207
+  { title: 'The Prestige', year: 2006 },
208
+  { title: 'The Lion King', year: 1994 },
209
+  { title: 'Apocalypse Now', year: 1979 },
210
+  { title: 'Alien', year: 1979 },
211
+  { title: 'Sunset Boulevard', year: 1950 },
212
+  {
213
+    title: 'Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb',
214
+    year: 1964,
215
+  },
216
+  { title: 'The Great Dictator', year: 1940 },
217
+  { title: 'Cinema Paradiso', year: 1988 },
218
+  { title: 'The Lives of Others', year: 2006 },
219
+  { title: 'Grave of the Fireflies', year: 1988 },
220
+  { title: 'Paths of Glory', year: 1957 },
221
+  { title: 'Django Unchained', year: 2012 },
222
+  { title: 'The Shining', year: 1980 },
223
+  { title: 'WALL·E', year: 2008 },
224
+  { title: 'American Beauty', year: 1999 },
225
+  { title: 'The Dark Knight Rises', year: 2012 },
226
+  { title: 'Princess Mononoke', year: 1997 },
227
+  { title: 'Aliens', year: 1986 },
228
+  { title: 'Oldboy', year: 2003 },
229
+  { title: 'Once Upon a Time in America', year: 1984 },
230
+  { title: 'Witness for the Prosecution', year: 1957 },
231
+  { title: 'Das Boot', year: 1981 },
232
+  { title: 'Citizen Kane', year: 1941 },
233
+  { title: 'North by Northwest', year: 1959 },
234
+  { title: 'Vertigo', year: 1958 },
235
+  {
236
+    title: 'Star Wars: Episode VI - Return of the Jedi',
237
+    year: 1983,
238
+  },
239
+  { title: 'Reservoir Dogs', year: 1992 },
240
+  { title: 'Braveheart', year: 1995 },
241
+  { title: 'M', year: 1931 },
242
+  { title: 'Requiem for a Dream', year: 2000 },
243
+  { title: 'Amélie', year: 2001 },
244
+  { title: 'A Clockwork Orange', year: 1971 },
245
+  { title: 'Like Stars on Earth', year: 2007 },
246
+  { title: 'Taxi Driver', year: 1976 },
247
+  { title: 'Lawrence of Arabia', year: 1962 },
248
+  { title: 'Double Indemnity', year: 1944 },
249
+  {
250
+    title: 'Eternal Sunshine of the Spotless Mind',
251
+    year: 2004,
252
+  },
253
+  { title: 'Amadeus', year: 1984 },
254
+  { title: 'To Kill a Mockingbird', year: 1962 },
255
+  { title: 'Toy Story 3', year: 2010 },
256
+  { title: 'Logan', year: 2017 },
257
+  { title: 'Full Metal Jacket', year: 1987 },
258
+  { title: 'Dangal', year: 2016 },
259
+  { title: 'The Sting', year: 1973 },
260
+  { title: '2001: A Space Odyssey', year: 1968 },
261
+  { title: "Singin' in the Rain", year: 1952 },
262
+  { title: 'Toy Story', year: 1995 },
263
+  { title: 'Bicycle Thieves', year: 1948 },
264
+  { title: 'The Kid', year: 1921 },
265
+  { title: 'Inglourious Basterds', year: 2009 },
266
+  { title: 'Snatch', year: 2000 },
267
+  { title: '3 Idiots', year: 2009 },
268
+  { title: 'Monty Python and the Holy Grail', year: 1975 },
269
+];