|
@@ -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">×</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
|
+
|