|
@@ -2,6 +2,7 @@ import React, { memo, useCallback, useMemo, useEffect } from 'react';
|
|
|
import * as Yup from 'yup';
|
|
import * as Yup from 'yup';
|
|
|
import { useFormik, Form, FormikProvider } from 'formik';
|
|
import { useFormik, Form, FormikProvider } from 'formik';
|
|
|
import { Modal } from 'react-bootstrap'
|
|
import { Modal } from 'react-bootstrap'
|
|
|
|
|
+import toast, { Toaster } from 'react-hot-toast';
|
|
|
|
|
|
|
|
import DateFnsUtils from '@date-io/date-fns';
|
|
import DateFnsUtils from '@date-io/date-fns';
|
|
|
import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
|
|
import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
|
|
@@ -38,7 +39,7 @@ function Edit(props) {
|
|
|
let { visible, toggle, puesto } = props
|
|
let { visible, toggle, puesto } = props
|
|
|
|
|
|
|
|
const [departamento, setDepartamento] = React.useState('');
|
|
const [departamento, setDepartamento] = React.useState('');
|
|
|
- // const [open, setOpen] = React.useState(false);
|
|
|
|
|
|
|
+ const [open, setOpen] = React.useState(false);
|
|
|
|
|
|
|
|
const changeDepartamento = useCallback((event) => {
|
|
const changeDepartamento = useCallback((event) => {
|
|
|
setDepartamento(event.target.value);
|
|
setDepartamento(event.target.value);
|
|
@@ -73,12 +74,20 @@ function Edit(props) {
|
|
|
notas: ""
|
|
notas: ""
|
|
|
},
|
|
},
|
|
|
onSubmit: (fields, { resetForm }) => {
|
|
onSubmit: (fields, { resetForm }) => {
|
|
|
|
|
+ setOpen(true);
|
|
|
fields['fecha'] = new Date(fields.fecha).toISOString();
|
|
fields['fecha'] = new Date(fields.fecha).toISOString();
|
|
|
|
|
|
|
|
puestoMutation.mutate(fields, {
|
|
puestoMutation.mutate(fields, {
|
|
|
onSuccess: () => {
|
|
onSuccess: () => {
|
|
|
close();
|
|
close();
|
|
|
|
|
+ setOpen(false)
|
|
|
|
|
+ toast.success("Puesto Actualizado!!")
|
|
|
queryClient.invalidateQueries('puestos')
|
|
queryClient.invalidateQueries('puestos')
|
|
|
|
|
+ },
|
|
|
|
|
+ onError:() => {
|
|
|
|
|
+ close();
|
|
|
|
|
+ setOpen(false)
|
|
|
|
|
+ toast.error("Lo sentimos ocurrió error inténtalo más tarde")
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -211,12 +220,12 @@ function Edit(props) {
|
|
|
</FormikProvider>
|
|
</FormikProvider>
|
|
|
</Modal.Body>
|
|
</Modal.Body>
|
|
|
<Backdrop
|
|
<Backdrop
|
|
|
- // sx={{ color: '#fd4b4b', zIndex: (theme) => theme.zIndex.drawer + 1 }}
|
|
|
|
|
- // open={open}
|
|
|
|
|
- // onClick={() => console.log('backdrop')} >
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ sx={{ color: '#fd4b4b', zIndex: (theme) => theme.zIndex.drawer + 1 }}
|
|
|
|
|
+ open={open}
|
|
|
|
|
+ onClick={() => console.log('backdrop')} >
|
|
|
<CircularProgress color="inherit" />
|
|
<CircularProgress color="inherit" />
|
|
|
</Backdrop>
|
|
</Backdrop>
|
|
|
|
|
+ <Toaster position="top-right" />
|
|
|
|
|
|
|
|
</Modal>
|
|
</Modal>
|
|
|
)
|
|
)
|