|
@@ -1,4 +1,4 @@
|
1
|
|
-import React from 'react'
|
|
1
|
+import React, { useEffect } from 'react'
|
2
|
2
|
import * as Yup from 'yup';
|
3
|
3
|
|
4
|
4
|
import { useFormik, Form, FormikProvider } from 'formik';
|
|
@@ -13,50 +13,60 @@ import {
|
13
|
13
|
CheckBoxOutlineBlank as CheckBoxOutlineBlankIcon
|
14
|
14
|
} from '@mui/icons-material';
|
15
|
15
|
|
16
|
|
-const icon = <CheckBoxOutlineBlankIcon fontSize="small" />;
|
|
16
|
+const delete_icon = <CheckBoxOutlineBlankIcon fontSize="small" />;
|
17
|
17
|
const checkedIcon = <CheckBoxIcon fontSize="small" />;
|
18
|
18
|
|
|
19
|
+
|
|
20
|
+
|
19
|
21
|
export function StepTree(props) {
|
20
|
22
|
|
21
|
23
|
const PlazaScheme = Yup.object().shape({
|
22
|
|
- puesto: Yup.object().required('Escoge un puesto valido')
|
|
24
|
+ puesto:
|
|
25
|
+ Yup.array()
|
|
26
|
+ .required('Escoge un puesto valido')
|
|
27
|
+ .min(1,"Debes escoger por lo menos una prueba")
|
23
|
28
|
});
|
24
|
29
|
|
25
|
|
- let { handleNext, handleBack } = props
|
|
30
|
+ let { handleNext, handleBack, password, setPassword } = props
|
26
|
31
|
|
27
|
32
|
const formik = useFormik({
|
28
|
33
|
initialValues: {
|
29
|
|
- puesto: {}
|
|
34
|
+ puesto: password.index_pruebas
|
30
|
35
|
},
|
31
|
36
|
onSubmit: (fields) => {
|
32
|
|
- console.log('SUBMIT > ',fields)
|
|
37
|
+ console.log('PRUEBAS ::',fields)
|
|
38
|
+ setPassword({
|
|
39
|
+ ...password,
|
|
40
|
+ index_pruebas : fields.puesto
|
|
41
|
+ })
|
33
|
42
|
handleNext()
|
34
|
43
|
},
|
35
|
44
|
validationSchema: PlazaScheme,
|
36
|
45
|
});
|
37
|
46
|
|
38
|
|
- const {errors, touched, handleSubmit, getFieldProps, setValues } = formik;
|
39
|
|
-
|
|
47
|
+ const {errors, touched, handleSubmit, getFieldProps, setValues, values} = formik;
|
40
|
48
|
return (
|
41
|
49
|
<FormikProvider style={{ padding : 25 }} value={formik}>
|
42
|
50
|
<Form autoComplete="off" noValidate onSubmit={handleSubmit}>
|
43
|
51
|
<Stack spacing={2}>
|
44
|
|
-
|
45
|
52
|
<Autocomplete
|
|
53
|
+ {...getFieldProps('puesto')}
|
46
|
54
|
multiple
|
47
|
55
|
id="checkboxes-tags-demo"
|
48
|
56
|
options={top100Films}
|
49
|
57
|
disableCloseOnSelect
|
50
|
|
- getOptionLabel={(option) => option.label}
|
51
|
|
- onChange={(a,b,c) => {
|
|
58
|
+ getOptionLabel={(option) => {
|
|
59
|
+ return option.label
|
|
60
|
+ }}
|
|
61
|
+ onChange={(a,current_list,c,individual,f) => {
|
52
|
62
|
setValues({
|
53
|
|
- puesto : b[0]
|
|
63
|
+ puesto:current_list
|
54
|
64
|
})
|
55
|
65
|
}}
|
56
|
66
|
renderOption={(props, option, { selected }) => (
|
57
|
67
|
<li {...props}>
|
58
|
68
|
<Checkbox
|
59
|
|
- icon={icon}
|
|
69
|
+ icon={delete_icon}
|
60
|
70
|
checkedIcon={checkedIcon}
|
61
|
71
|
|
62
|
72
|
checked={selected}
|