|
@@ -5,39 +5,48 @@ import { Modal } from 'react-bootstrap'
|
|
|
|
|
|
|
|
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';
|
|
|
-import { Button, Stack, TextField, } from '@mui/material';
|
|
|
|
|
|
|
+import { Button, Stack, TextField, MenuItem,FormControl, InputLabel, Select } from '@mui/material';
|
|
|
|
|
|
|
|
import { Service } from '../../Utils/HTTP';
|
|
import { Service } from '../../Utils/HTTP';
|
|
|
import useAuth from '../../Auth/useAuth';
|
|
import useAuth from '../../Auth/useAuth';
|
|
|
|
|
|
|
|
|
|
+import { departamentos } from '../Password/Rows'
|
|
|
|
|
+
|
|
|
|
|
|
|
|
export default function Manual ( props ) {
|
|
export default function Manual ( props ) {
|
|
|
|
|
|
|
|
const NewPlazaSchema = Yup.object().shape({
|
|
const NewPlazaSchema = Yup.object().shape({
|
|
|
- nombrepuesto : Yup.string().required('El nombre es requerido').min(5).max(100),
|
|
|
|
|
|
|
+ nombrepuesto : Yup.string().required('El nombre es requerido').min(5, "El nombre del puesto debe ser mayor a 5 caracteres").max(100),
|
|
|
puestosuperior : Yup.number("El puesto superior debe ser un número"),
|
|
puestosuperior : Yup.number("El puesto superior debe ser un número"),
|
|
|
aredepto : Yup.number().required('Escoge alguna área'),
|
|
aredepto : Yup.number().required('Escoge alguna área'),
|
|
|
fecha : Yup.date("Ingresa una fecha válida"),
|
|
fecha : Yup.date("Ingresa una fecha válida"),
|
|
|
notas : Yup.string("Ingresa una nota válida").min(5).max(150),
|
|
notas : Yup.string("Ingresa una nota válida").min(5).max(150),
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ const [departamento, setDepartamento] = React.useState('');
|
|
|
|
|
+
|
|
|
|
|
+ const changeDepartamento = (event) => {
|
|
|
|
|
+ setDepartamento(event.target.value);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
|
|
|
const [date, setDate] = React.useState(new Date());
|
|
const [date, setDate] = React.useState(new Date());
|
|
|
const auth = useAuth();
|
|
const auth = useAuth();
|
|
|
const token = auth.getToken();
|
|
const token = auth.getToken();
|
|
|
|
|
|
|
|
- let { visible, onClose, success, error } = props
|
|
|
|
|
|
|
+ let { visible, onClose, Complete } = props
|
|
|
|
|
|
|
|
const formik = useFormik({
|
|
const formik = useFormik({
|
|
|
initialValues: {
|
|
initialValues: {
|
|
|
- nombrepuesto: "QA ENGINIER",
|
|
|
|
|
- puestosuperior: 3,
|
|
|
|
|
|
|
+ nombrepuesto: "",
|
|
|
|
|
+ puestosuperior: "",
|
|
|
aredepto: 1,
|
|
aredepto: 1,
|
|
|
fecha: date,
|
|
fecha: date,
|
|
|
- notas: "alguna nota ",
|
|
|
|
|
|
|
+ notas: "",
|
|
|
},
|
|
},
|
|
|
- onSubmit: (fields) => {
|
|
|
|
|
|
|
+ onSubmit: ( fields, { resetForm } ) => {
|
|
|
|
|
|
|
|
- fields['fecha'] = "2023-06-11T00:22:15.211"//new Date(fields.fecha).toString() //getDate(fields.fecha);
|
|
|
|
|
|
|
+ fields['fecha'] = new Date(fields.fecha).toISOString();
|
|
|
fields['areadeptoplz_id'] = 1;
|
|
fields['areadeptoplz_id'] = 1;
|
|
|
fields['id'] = -1;
|
|
fields['id'] = -1;
|
|
|
|
|
|
|
@@ -45,21 +54,21 @@ export default function Manual ( props ) {
|
|
|
|
|
|
|
|
Rest
|
|
Rest
|
|
|
.post( fields, token )
|
|
.post( fields, token )
|
|
|
- .then(data => {
|
|
|
|
|
|
|
+ .then( _ => {
|
|
|
|
|
+ resetForm();
|
|
|
|
|
+ Complete(true);
|
|
|
onClose();
|
|
onClose();
|
|
|
- success();
|
|
|
|
|
- console.log('data ', data)
|
|
|
|
|
})
|
|
})
|
|
|
.catch(err => {
|
|
.catch(err => {
|
|
|
- error();
|
|
|
|
|
console.error(err)
|
|
console.error(err)
|
|
|
|
|
+ Complete(false);
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
validationSchema: NewPlazaSchema,
|
|
validationSchema: NewPlazaSchema,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- const { errors, touched, handleSubmit, getFieldProps } = formik;
|
|
|
|
|
|
|
+ const { errors, touched, handleSubmit, getFieldProps} = formik;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
|
|
|
|
@@ -73,6 +82,7 @@ export default function Manual ( props ) {
|
|
|
<FormikProvider style={{ padding : 25 }} value={formik}>
|
|
<FormikProvider style={{ padding : 25 }} value={formik}>
|
|
|
<Form autoComplete="off" noValidate onSubmit={handleSubmit}>
|
|
<Form autoComplete="off" noValidate onSubmit={handleSubmit}>
|
|
|
<Stack spacing={3}>
|
|
<Stack spacing={3}>
|
|
|
|
|
+
|
|
|
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
|
|
|
|
|
|
<TextField
|
|
<TextField
|
|
@@ -93,14 +103,26 @@ export default function Manual ( props ) {
|
|
|
|
|
|
|
|
</Stack>
|
|
</Stack>
|
|
|
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
|
- <TextField
|
|
|
|
|
- label="Departamento"
|
|
|
|
|
- fullWidth
|
|
|
|
|
- type="text"
|
|
|
|
|
- {...getFieldProps('aredepto')}
|
|
|
|
|
- error={Boolean(touched.aredepto && errors.aredepto)}
|
|
|
|
|
- helperText={touched.aredepto && errors.aredepto}
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <FormControl fullWidth>
|
|
|
|
|
+ <InputLabel id="demo-simple-select-label">Departamento</InputLabel>
|
|
|
|
|
+ <Select
|
|
|
|
|
+ labelId="demo-simple-select-label"
|
|
|
|
|
+ value={departamento}
|
|
|
|
|
+ label="Departamento"
|
|
|
|
|
+ onChange={changeDepartamento}
|
|
|
|
|
+ {...getFieldProps('aredepto')}
|
|
|
|
|
+ error={Boolean(touched.aredepto && errors.aredepto)} >
|
|
|
|
|
+ {
|
|
|
|
|
+ departamentos.map( ( nivel, index ) => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <MenuItem key={nivel} value={index}>{nivel}</MenuItem>
|
|
|
|
|
+ )
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ </Select>
|
|
|
|
|
+ </FormControl>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
<LocalizationProvider
|
|
<LocalizationProvider
|
|
|
dateAdapter={DateFnsUtils}>
|
|
dateAdapter={DateFnsUtils}>
|
|
|
<DesktopDatePicker
|
|
<DesktopDatePicker
|
|
@@ -145,17 +167,13 @@ export default function Manual ( props ) {
|
|
|
type="submit"
|
|
type="submit"
|
|
|
className="registerBtn"
|
|
className="registerBtn"
|
|
|
variant="contained"
|
|
variant="contained"
|
|
|
- sx={{ mt: 1, mr: 1 }}
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ sx={{ mt: 1, mr: 1 }} >
|
|
|
{'Guardar'}
|
|
{'Guardar'}
|
|
|
</Button>
|
|
</Button>
|
|
|
</Modal.Footer>
|
|
</Modal.Footer>
|
|
|
|
|
|
|
|
</Form>
|
|
</Form>
|
|
|
</FormikProvider>
|
|
</FormikProvider>
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
</Modal.Body>
|
|
</Modal.Body>
|
|
|
</Modal>
|
|
</Modal>
|
|
|
)
|
|
)
|