|
@@ -24,6 +24,19 @@ import { useSelector } from 'react-redux';
|
24
|
24
|
|
25
|
25
|
const filter = createFilterOptions();
|
26
|
26
|
|
|
27
|
+ async function getPuestoSuperior (puesto, auth) {
|
|
28
|
+ if (puesto.length < 3) return []
|
|
29
|
+ let rest = new Service(`/plaza/keypuestosup?keyword=${puesto}`)
|
|
30
|
+ let result = await rest.get(auth.token)
|
|
31
|
+ console.log(result)
|
|
32
|
+ if (result?.data?.length > 0) {
|
|
33
|
+ result = result.data.map((item) => ({ 'title': item.nombre, year: item.id }))
|
|
34
|
+ return result;
|
|
35
|
+ }
|
|
36
|
+ return [];
|
|
37
|
+ }
|
|
38
|
+
|
|
39
|
+
|
27
|
40
|
function Manual(props) {
|
28
|
41
|
|
29
|
42
|
const auth = useSelector((state) => state.token)
|
|
@@ -38,13 +51,14 @@ function Manual(props) {
|
38
|
51
|
return await rest.getQuery(auth.token)
|
39
|
52
|
}
|
40
|
53
|
|
|
54
|
+
|
41
|
55
|
const { data } = useQuery('categories', getCategories);
|
42
|
56
|
const { data: testsCatalog } = useQuery('tests', getTest);
|
43
|
57
|
const queryClient = useQueryClient();
|
44
|
58
|
|
45
|
59
|
const NewPlazaSchema = Yup.object().shape({
|
46
|
60
|
nombrepuesto: Yup.string().required('El nombre es requerido').min(5, "El nombre del puesto debe ser mayor a 5 caracteres").max(100),
|
47
|
|
- puestosuperior: Yup.string().required("El puesto es requerido").min(5, "El nombre del puesto debe ser mayor a 5 caracteres").max(15),
|
|
61
|
+ puestosuperior: Yup.string().required("El puesto es requerido").min(5, "El nombre del puesto debe ser mayor a 5 caracteres").max(30),
|
48
|
62
|
aredepto: Yup.number().required('Escoge alguna área'),
|
49
|
63
|
fecha: Yup.date("Ingresa una fecha válida"),
|
50
|
64
|
notas: Yup.string("Ingresa una nota válida").min(5, "Ingresa una nota válida").max(150),
|
|
@@ -52,11 +66,46 @@ function Manual(props) {
|
52
|
66
|
})
|
53
|
67
|
|
54
|
68
|
const [departamento, setDepartamento] = React.useState('');
|
55
|
|
- const [puestoSup, setPuestoSup] = React.useState('The Godfather');
|
56
|
69
|
const [open, setOpen] = React.useState(false);
|
57
|
70
|
const [date, setDate] = React.useState(new Date());
|
58
|
71
|
const [tab, setTab] = React.useState(0);
|
59
|
72
|
const [checklist, setChecklist] = React.useState([]);
|
|
73
|
+ const [valueDialog, setValueDialog] = React.useState();
|
|
74
|
+ const [openDialog, toggleOpenDialog] = React.useState(false);
|
|
75
|
+ const [openSugg, setOpenSugg] = React.useState(false);
|
|
76
|
+ const [options, setOptions] = React.useState([]);
|
|
77
|
+ const [dialogValue, setDialogValue] = React.useState({
|
|
78
|
+ title: '',
|
|
79
|
+ year: '',
|
|
80
|
+ });
|
|
81
|
+
|
|
82
|
+ const loading = openSugg && options.length === 0;
|
|
83
|
+
|
|
84
|
+ React.useEffect(() => {
|
|
85
|
+
|
|
86
|
+ console.log('dialogValue', dialogValue)
|
|
87
|
+ let active = true;
|
|
88
|
+ console.log('loading', loading)
|
|
89
|
+ if (!loading) {
|
|
90
|
+ return undefined;
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ (async () => {
|
|
94
|
+ let puestos = await getPuestoSuperior(dialogValue.title, auth)
|
|
95
|
+ console.log('puestos', puestos)
|
|
96
|
+
|
|
97
|
+ if (active) {
|
|
98
|
+ setOptions(puestos);
|
|
99
|
+ }
|
|
100
|
+ })();
|
|
101
|
+
|
|
102
|
+ return () => {
|
|
103
|
+ active = false;
|
|
104
|
+ };
|
|
105
|
+
|
|
106
|
+ }, [loading, dialogValue, auth]);
|
|
107
|
+
|
|
108
|
+
|
60
|
109
|
|
61
|
110
|
const handleClose = () => false
|
62
|
111
|
|
|
@@ -64,13 +113,6 @@ function Manual(props) {
|
64
|
113
|
setDepartamento(event.target.value);
|
65
|
114
|
};
|
66
|
115
|
|
67
|
|
- const changePuestoSup = (event) => {
|
68
|
|
- setPuestoSup(event.target.value);
|
69
|
|
- };
|
70
|
|
-
|
71
|
|
- const [valueDialog, setValueDialog] = React.useState(null);
|
72
|
|
- const [openDialog, toggleOpenDialog] = React.useState(false);
|
73
|
|
-
|
74
|
116
|
const handleCloseDialog = () => {
|
75
|
117
|
setDialogValue({
|
76
|
118
|
title: '',
|
|
@@ -79,10 +121,6 @@ function Manual(props) {
|
79
|
121
|
toggleOpenDialog(false);
|
80
|
122
|
};
|
81
|
123
|
|
82
|
|
- const [dialogValue, setDialogValue] = React.useState({
|
83
|
|
- title: '',
|
84
|
|
- year: '',
|
85
|
|
- });
|
86
|
124
|
|
87
|
125
|
const handleSubmitDialog = (event) => {
|
88
|
126
|
event.preventDefault();
|
|
@@ -94,6 +132,7 @@ function Manual(props) {
|
94
|
132
|
};
|
95
|
133
|
|
96
|
134
|
const AutoCompleteChange = (event, newValue) => {
|
|
135
|
+ console.log('newValue', newValue)
|
97
|
136
|
if (typeof newValue === 'string') {
|
98
|
137
|
// timeout to avoid instant validation of the dialog's form.
|
99
|
138
|
setTimeout(() => {
|
|
@@ -166,7 +205,6 @@ function Manual(props) {
|
166
|
205
|
setTab(newValue);
|
167
|
206
|
};
|
168
|
207
|
|
169
|
|
-
|
170
|
208
|
const { errors, touched, handleSubmit, getFieldProps, values, setValues } = formik;
|
171
|
209
|
|
172
|
210
|
const addPrueba = (check, id) => {
|
|
@@ -316,11 +354,18 @@ function Manual(props) {
|
316
|
354
|
</Select>
|
317
|
355
|
*/}
|
318
|
356
|
|
319
|
|
-
|
320
|
357
|
<Autocomplete
|
321
|
358
|
fullWidth
|
322
|
359
|
value={valueDialog}
|
323
|
360
|
onChange={AutoCompleteChange}
|
|
361
|
+ open={openSugg}
|
|
362
|
+ onOpen={() => {
|
|
363
|
+ setOpenSugg(true);
|
|
364
|
+ }}
|
|
365
|
+ onClose={() => {
|
|
366
|
+ setOpenSugg(false);
|
|
367
|
+ }}
|
|
368
|
+ isOptionEqualToValue={(option, value) => option.title === value.title}
|
324
|
369
|
filterOptions={(options, params) => {
|
325
|
370
|
const filtered = filter(options, params);
|
326
|
371
|
|
|
@@ -334,7 +379,8 @@ function Manual(props) {
|
334
|
379
|
return filtered;
|
335
|
380
|
}}
|
336
|
381
|
id="puesto_superior_autocomplete"
|
337
|
|
- options={top100Films}
|
|
382
|
+ options={options}
|
|
383
|
+ loading={loading}
|
338
|
384
|
getOptionLabel={(option) => {
|
339
|
385
|
if (typeof option === 'string') {
|
340
|
386
|
return option;
|
|
@@ -349,29 +395,36 @@ function Manual(props) {
|
349
|
395
|
handleHomeEndKeys
|
350
|
396
|
renderOption={(props, option) => <li {...props}>{option.title}</li>}
|
351
|
397
|
freeSolo
|
352
|
|
- renderInput={(params) => <TextField {...params} label="Puesto Superior" />}
|
353
|
|
- />
|
|
398
|
+ renderInput={(params) => (
|
|
399
|
+ <TextField
|
|
400
|
+ {...params}
|
|
401
|
+ {...getFieldProps('puestosuperior')}
|
|
402
|
+ error={Boolean(touched.puestosuperior && errors.puestosuperior)}
|
|
403
|
+ label="Puesto Superior"
|
|
404
|
+ InputProps={{
|
|
405
|
+ ...params.InputProps,
|
|
406
|
+ onChange: (event) => {
|
|
407
|
+ let title = event.target.value;
|
|
408
|
+ console.log(title)
|
|
409
|
+ setOptions([]);
|
|
410
|
+ setDialogValue({
|
|
411
|
+ title: event.target.value,
|
|
412
|
+ year: '',
|
|
413
|
+ });
|
|
414
|
+ },
|
|
415
|
+ endAdornment: (
|
|
416
|
+ <React.Fragment>
|
|
417
|
+ {loading ? <CircularProgress color="inherit" size={20} /> : null}
|
|
418
|
+ {params.InputProps.endAdornment}
|
|
419
|
+ </React.Fragment>
|
|
420
|
+ ),
|
|
421
|
+ }}
|
|
422
|
+ />
|
|
423
|
+ )}
|
354
|
424
|
|
|
425
|
+ />
|
355
|
426
|
|
356
|
427
|
|
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
|
|
-
|
375
|
428
|
</FormControl>
|
376
|
429
|
|
377
|
430
|
</Stack>
|
|
@@ -464,131 +517,3 @@ function Manual(props) {
|
464
|
517
|
)
|
465
|
518
|
}
|
466
|
519
|
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
|
|
-
|