|
@@ -28,7 +28,7 @@ const NewPlazaSchema = Yup.object().shape({
|
28
|
28
|
aredepto: Yup.number().required('Escoge alguna área'),
|
29
|
29
|
fecha: Yup.date("Ingresa una fecha válida"),
|
30
|
30
|
notas: Yup.string("Ingresa una nota válida").min(5).max(150),
|
31
|
|
- pruebas: Yup.array()
|
|
31
|
+ tests: Yup.array()
|
32
|
32
|
})
|
33
|
33
|
|
34
|
34
|
|
|
@@ -53,16 +53,15 @@ function Edit(props) {
|
53
|
53
|
const [checklist, setChecklist] = React.useState([]);
|
54
|
54
|
|
55
|
55
|
const addPrueba = (check,id) => {
|
56
|
|
- let { pruebas } = values
|
57
|
|
- console.log(pruebas)
|
|
56
|
+ let { tests } = values
|
58
|
57
|
let temp ;
|
59
|
58
|
if(check){
|
60
|
|
- temp = [...pruebas, {id}]
|
|
59
|
+ temp = [...tests, {id}]
|
61
|
60
|
}else{
|
62
|
|
- temp = pruebas.filter( test => test.id !== id);
|
|
61
|
+ temp = tests.filter( test => test.id !== id);
|
63
|
62
|
}
|
64
|
63
|
setChecklist(temp.map( test => test.id) )
|
65
|
|
- setValues({...values, pruebas: temp})
|
|
64
|
+ setValues({...values, tests: temp})
|
66
|
65
|
};
|
67
|
66
|
|
68
|
67
|
const getCategories = async () => {
|
|
@@ -85,7 +84,7 @@ function Edit(props) {
|
85
|
84
|
const close = () => toggle("EDIT");
|
86
|
85
|
|
87
|
86
|
const { data } = useQuery('categories', getCategories);
|
88
|
|
- const { data: tests } = useQuery('tests', getTest);
|
|
87
|
+ const { data: testsCatalog } = useQuery('tests', getTest);
|
89
|
88
|
|
90
|
89
|
const formik = useFormik({
|
91
|
90
|
initialValues: {
|
|
@@ -95,7 +94,7 @@ function Edit(props) {
|
95
|
94
|
aredepto: 1,
|
96
|
95
|
fecha: now,
|
97
|
96
|
notas: "",
|
98
|
|
- pruebas : []
|
|
97
|
+ tests : []
|
99
|
98
|
},
|
100
|
99
|
onSubmit: (fields, { resetForm }) => {
|
101
|
100
|
setOpen(true);
|
|
@@ -123,7 +122,6 @@ function Edit(props) {
|
123
|
122
|
const { errors, touched, handleSubmit, getFieldProps, setValues, values } = formik;
|
124
|
123
|
|
125
|
124
|
useEffect(() => {
|
126
|
|
- console.log("PUESTO :: ", puesto)
|
127
|
125
|
if (puesto) {
|
128
|
126
|
setValues({
|
129
|
127
|
id: puesto.id,
|
|
@@ -132,7 +130,7 @@ function Edit(props) {
|
132
|
130
|
aredepto: puesto.areadeptoplz_id,
|
133
|
131
|
fecha: new Date(puesto.create_day),
|
134
|
132
|
notas: puesto.notas,
|
135
|
|
- pruebas : puesto.tests
|
|
133
|
+ tests : puesto.tests
|
136
|
134
|
})
|
137
|
135
|
setChecklist(puesto.tests.map(( {id} ) => id))
|
138
|
136
|
}
|
|
@@ -168,8 +166,8 @@ function Edit(props) {
|
168
|
166
|
<Divider/>
|
169
|
167
|
<FormGroup>
|
170
|
168
|
{
|
171
|
|
- tests ?
|
172
|
|
- tests.data.map( test => (
|
|
169
|
+ testsCatalog ?
|
|
170
|
+ testsCatalog.data.map( test => (
|
173
|
171
|
<FormControlLabel
|
174
|
172
|
key={test.id}
|
175
|
173
|
control={
|