|
|
@@ -28,7 +28,7 @@ const NewPlazaSchema = Yup.object().shape({
|
|
|
aredepto: Yup.number().required('Escoge alguna área'),
|
|
|
fecha: Yup.date("Ingresa una fecha válida"),
|
|
|
notas: Yup.string("Ingresa una nota válida").min(5).max(150),
|
|
|
- pruebas: Yup.array()
|
|
|
+ tests: Yup.array()
|
|
|
})
|
|
|
|
|
|
|
|
|
@@ -53,16 +53,15 @@ function Edit(props) {
|
|
|
const [checklist, setChecklist] = React.useState([]);
|
|
|
|
|
|
const addPrueba = (check,id) => {
|
|
|
- let { pruebas } = values
|
|
|
- console.log(pruebas)
|
|
|
+ let { tests } = values
|
|
|
let temp ;
|
|
|
if(check){
|
|
|
- temp = [...pruebas, {id}]
|
|
|
+ temp = [...tests, {id}]
|
|
|
}else{
|
|
|
- temp = pruebas.filter( test => test.id !== id);
|
|
|
+ temp = tests.filter( test => test.id !== id);
|
|
|
}
|
|
|
setChecklist(temp.map( test => test.id) )
|
|
|
- setValues({...values, pruebas: temp})
|
|
|
+ setValues({...values, tests: temp})
|
|
|
};
|
|
|
|
|
|
const getCategories = async () => {
|
|
|
@@ -85,7 +84,7 @@ function Edit(props) {
|
|
|
const close = () => toggle("EDIT");
|
|
|
|
|
|
const { data } = useQuery('categories', getCategories);
|
|
|
- const { data: tests } = useQuery('tests', getTest);
|
|
|
+ const { data: testsCatalog } = useQuery('tests', getTest);
|
|
|
|
|
|
const formik = useFormik({
|
|
|
initialValues: {
|
|
|
@@ -95,7 +94,7 @@ function Edit(props) {
|
|
|
aredepto: 1,
|
|
|
fecha: now,
|
|
|
notas: "",
|
|
|
- pruebas : []
|
|
|
+ tests : []
|
|
|
},
|
|
|
onSubmit: (fields, { resetForm }) => {
|
|
|
setOpen(true);
|
|
|
@@ -123,7 +122,6 @@ function Edit(props) {
|
|
|
const { errors, touched, handleSubmit, getFieldProps, setValues, values } = formik;
|
|
|
|
|
|
useEffect(() => {
|
|
|
- console.log("PUESTO :: ", puesto)
|
|
|
if (puesto) {
|
|
|
setValues({
|
|
|
id: puesto.id,
|
|
|
@@ -132,7 +130,7 @@ function Edit(props) {
|
|
|
aredepto: puesto.areadeptoplz_id,
|
|
|
fecha: new Date(puesto.create_day),
|
|
|
notas: puesto.notas,
|
|
|
- pruebas : puesto.tests
|
|
|
+ tests : puesto.tests
|
|
|
})
|
|
|
setChecklist(puesto.tests.map(( {id} ) => id))
|
|
|
}
|
|
|
@@ -168,8 +166,8 @@ function Edit(props) {
|
|
|
<Divider/>
|
|
|
<FormGroup>
|
|
|
{
|
|
|
- tests ?
|
|
|
- tests.data.map( test => (
|
|
|
+ testsCatalog ?
|
|
|
+ testsCatalog.data.map( test => (
|
|
|
<FormControlLabel
|
|
|
key={test.id}
|
|
|
control={
|