|
@@ -1,4 +1,4 @@
|
1
|
|
-import React, { memo, useMemo, useEffect } from 'react';
|
|
1
|
+import React, { memo, useEffect } from 'react';
|
2
|
2
|
import { Modal } from 'react-bootstrap'
|
3
|
3
|
import { useForm, Controller } from "react-hook-form";
|
4
|
4
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
@@ -49,12 +49,30 @@ function Edit(props) {
|
49
|
49
|
});
|
50
|
50
|
|
51
|
51
|
const onSubmit = data => {
|
52
|
|
- console.log("SUBMIT: ",data)
|
|
52
|
+
|
|
53
|
+ let body = {
|
|
54
|
+ ...data,
|
|
55
|
+ fecha : new Date(data.fecha).toISOString()
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ puestoMutation.mutate(body, {
|
|
59
|
+ onSuccess: () => {
|
|
60
|
+ close();
|
|
61
|
+ setOpen(false)
|
|
62
|
+ toast.success("Puesto Actualizado!!")
|
|
63
|
+ queryClient.invalidateQueries('puestos')
|
|
64
|
+ },
|
|
65
|
+ onError:() => {
|
|
66
|
+ close();
|
|
67
|
+ setOpen(false)
|
|
68
|
+ toast.error("Lo sentimos ocurrió error inténtalo más tarde")
|
|
69
|
+ }
|
|
70
|
+ })
|
|
71
|
+
|
53
|
72
|
}
|
54
|
73
|
|
55
|
|
- const now = useMemo(() => new Date(), [])
|
56
|
74
|
const auth = useSelector((state) => state.token)
|
57
|
|
- // const queryClient = useQueryClient()
|
|
75
|
+ const queryClient = useQueryClient()
|
58
|
76
|
let { visible, toggle } = props
|
59
|
77
|
|
60
|
78
|
const [open, setOpen] = React.useState(false);
|
|
@@ -72,7 +90,6 @@ function Edit(props) {
|
72
|
90
|
}
|
73
|
91
|
setChecklist(temp.map( test => test.id) )
|
74
|
92
|
setValue('tests', temp)
|
75
|
|
- // setValue({...values, tests: temp})
|
76
|
93
|
};
|
77
|
94
|
|
78
|
95
|
const getCategories = async () => {
|
|
@@ -110,7 +127,7 @@ function Edit(props) {
|
110
|
127
|
reset({...response.data, areadepto : areadeptoplz_id, fecha : new Date(fecha) , tests : temp_test })
|
111
|
128
|
})
|
112
|
129
|
.catch(console.log)
|
113
|
|
- },[visible])
|
|
130
|
+ },[visible, auth,reset])
|
114
|
131
|
|
115
|
132
|
const changeTab = (_event, newValue) => setTab(newValue);
|
116
|
133
|
|