|
@@ -1,4 +1,4 @@
|
|
|
-import React, { memo, useMemo, useEffect } from 'react';
|
|
|
|
|
|
|
+import React, { memo, useEffect } from 'react';
|
|
|
import { Modal } from 'react-bootstrap'
|
|
import { Modal } from 'react-bootstrap'
|
|
|
import { useForm, Controller } from "react-hook-form";
|
|
import { useForm, Controller } from "react-hook-form";
|
|
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
@@ -49,12 +49,30 @@ function Edit(props) {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const onSubmit = data => {
|
|
const onSubmit = data => {
|
|
|
- console.log("SUBMIT: ",data)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ let body = {
|
|
|
|
|
+ ...data,
|
|
|
|
|
+ fecha : new Date(data.fecha).toISOString()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ puestoMutation.mutate(body, {
|
|
|
|
|
+ onSuccess: () => {
|
|
|
|
|
+ close();
|
|
|
|
|
+ setOpen(false)
|
|
|
|
|
+ toast.success("Puesto Actualizado!!")
|
|
|
|
|
+ queryClient.invalidateQueries('puestos')
|
|
|
|
|
+ },
|
|
|
|
|
+ onError:() => {
|
|
|
|
|
+ close();
|
|
|
|
|
+ setOpen(false)
|
|
|
|
|
+ toast.error("Lo sentimos ocurrió error inténtalo más tarde")
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const now = useMemo(() => new Date(), [])
|
|
|
|
|
const auth = useSelector((state) => state.token)
|
|
const auth = useSelector((state) => state.token)
|
|
|
- // const queryClient = useQueryClient()
|
|
|
|
|
|
|
+ const queryClient = useQueryClient()
|
|
|
let { visible, toggle } = props
|
|
let { visible, toggle } = props
|
|
|
|
|
|
|
|
const [open, setOpen] = React.useState(false);
|
|
const [open, setOpen] = React.useState(false);
|
|
@@ -72,7 +90,6 @@ function Edit(props) {
|
|
|
}
|
|
}
|
|
|
setChecklist(temp.map( test => test.id) )
|
|
setChecklist(temp.map( test => test.id) )
|
|
|
setValue('tests', temp)
|
|
setValue('tests', temp)
|
|
|
- // setValue({...values, tests: temp})
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const getCategories = async () => {
|
|
const getCategories = async () => {
|
|
@@ -110,7 +127,7 @@ function Edit(props) {
|
|
|
reset({...response.data, areadepto : areadeptoplz_id, fecha : new Date(fecha) , tests : temp_test })
|
|
reset({...response.data, areadepto : areadeptoplz_id, fecha : new Date(fecha) , tests : temp_test })
|
|
|
})
|
|
})
|
|
|
.catch(console.log)
|
|
.catch(console.log)
|
|
|
- },[visible])
|
|
|
|
|
|
|
+ },[visible, auth,reset])
|
|
|
|
|
|
|
|
const changeTab = (_event, newValue) => setTab(newValue);
|
|
const changeTab = (_event, newValue) => setTab(newValue);
|
|
|
|
|
|