|
|
@@ -3,36 +3,56 @@ import * as Yup from 'yup';
|
|
|
import { useFormik, Form, FormikProvider } from 'formik';
|
|
|
import { Modal } from 'react-bootstrap'
|
|
|
|
|
|
-import {
|
|
|
- Box, Button,
|
|
|
- Stack, TextField,
|
|
|
- InputLabel,MenuItem,FormControl,Select
|
|
|
-} from '@mui/material';
|
|
|
+import DateFnsUtils from '@date-io/date-fns';
|
|
|
+import { DesktopDatePicker,LocalizationProvider } from '@mui/lab';
|
|
|
+import { Button, Stack, TextField, } from '@mui/material';
|
|
|
|
|
|
+import { Service } from '../../Utils/HTTP';
|
|
|
+import useAuth from '../../Auth/useAuth';
|
|
|
|
|
|
|
|
|
export default function Manual ( props ) {
|
|
|
|
|
|
const NewPlazaSchema = Yup.object().shape({
|
|
|
nombrepuesto : Yup.string().required('El nombre es requerido').min(5).max(100),
|
|
|
- puestosuperior : Yup.number("El puesto superior debe ser un numero"),
|
|
|
- areadepto : Yup.number().required('Escoge alguna area'),
|
|
|
- fecha : Yup.date("Ingresa una fecha válida").required('Ingresa una fecha válida'),
|
|
|
- notas : Yup.string().required('Ingresa una fecha válida'),
|
|
|
+ puestosuperior : Yup.number("El puesto superior debe ser un número"),
|
|
|
+ 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),
|
|
|
})
|
|
|
|
|
|
+ const [date, setDate] = React.useState(new Date());
|
|
|
+ const auth = useAuth();
|
|
|
+ const token = auth.getToken();
|
|
|
+
|
|
|
let { visible, onClose, success } = props
|
|
|
|
|
|
const formik = useFormik({
|
|
|
initialValues: {
|
|
|
- nombrepuesto: "",
|
|
|
- puestosuperior: "",
|
|
|
- areadepto: "",
|
|
|
- fecha: "",
|
|
|
- notas: "",
|
|
|
+ nombrepuesto: "QA ENGINIER",
|
|
|
+ puestosuperior: 3,
|
|
|
+ aredepto: 1,
|
|
|
+ fecha: date,
|
|
|
+ notas: "alguna nota ",
|
|
|
},
|
|
|
onSubmit: (fields) => {
|
|
|
- console.log(fields)
|
|
|
+ fields['fecha'] = "2023-06-11T00:22:15.211"//new Date(fields.fecha).toString() //getDate(fields.fecha);
|
|
|
+ fields['areadeptoplz_id'] = 1;
|
|
|
+ fields['id'] = -1;
|
|
|
+
|
|
|
+ console.log(fields);
|
|
|
+
|
|
|
+ let Rest = new Service('/plaza/save');
|
|
|
+
|
|
|
+ Rest
|
|
|
+ .post( fields, token )
|
|
|
+ .then(data => {
|
|
|
+ console.log('data ', data)
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err)
|
|
|
+ })
|
|
|
+
|
|
|
},
|
|
|
validationSchema: NewPlazaSchema,
|
|
|
});
|
|
|
@@ -54,7 +74,7 @@ export default function Manual ( props ) {
|
|
|
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
|
|
|
|
<TextField
|
|
|
- label="Nombre: "
|
|
|
+ label="Nombre"
|
|
|
fullWidth
|
|
|
{...getFieldProps('nombrepuesto')}
|
|
|
error={Boolean(touched.nombrepuesto && errors.nombrepuesto)}
|
|
|
@@ -62,7 +82,7 @@ export default function Manual ( props ) {
|
|
|
/>
|
|
|
|
|
|
<TextField
|
|
|
- label="Puesto Superior: "
|
|
|
+ label="Puesto Superior"
|
|
|
fullWidth
|
|
|
{...getFieldProps('puestosuperior')}
|
|
|
error={Boolean(touched.puestosuperior && errors.puestosuperior)}
|
|
|
@@ -75,19 +95,32 @@ export default function Manual ( props ) {
|
|
|
label="Departamento"
|
|
|
fullWidth
|
|
|
type="text"
|
|
|
- {...getFieldProps('puestosuperior')}
|
|
|
- error={Boolean(touched.areadepto && errors.areadepto)}
|
|
|
- helperText={touched.areadepto && errors.areadepto}
|
|
|
- />
|
|
|
- <TextField
|
|
|
- label="Fecha Creacion"
|
|
|
- fullWidth
|
|
|
- type="text"
|
|
|
- {...getFieldProps('fecha')}
|
|
|
- error={Boolean(touched.fecha && errors.fecha)}
|
|
|
- helperText={touched.fecha && errors.fecha}
|
|
|
+ {...getFieldProps('aredepto')}
|
|
|
+ error={Boolean(touched.aredepto && errors.aredepto)}
|
|
|
+ helperText={touched.aredepto && errors.aredepto}
|
|
|
/>
|
|
|
+
|
|
|
+ <LocalizationProvider
|
|
|
+ dateAdapter={DateFnsUtils}>
|
|
|
+ <DesktopDatePicker
|
|
|
+ label="Fecha Creación"
|
|
|
+ fullWidth
|
|
|
+ inputFormat="dd/MM/yyyy"
|
|
|
+ {...getFieldProps('fecha')}
|
|
|
+ value={date}
|
|
|
+ onChange={setDate}
|
|
|
+ renderInput={(params) =>
|
|
|
+ <TextField
|
|
|
+ disabled={true}
|
|
|
+ label="Fecha Creación"
|
|
|
+ fullWidth
|
|
|
+ {...params}
|
|
|
+ />}
|
|
|
+ />
|
|
|
+ </LocalizationProvider>
|
|
|
+
|
|
|
</Stack>
|
|
|
+
|
|
|
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>
|
|
|
<TextField
|
|
|
id="filled-multiline-static"
|
|
|
@@ -95,19 +128,32 @@ export default function Manual ( props ) {
|
|
|
rows={4}
|
|
|
defaultValue="Default Value"
|
|
|
variant="filled"
|
|
|
- label="notas"
|
|
|
+ label="Notas"
|
|
|
fullWidth
|
|
|
type="text"
|
|
|
{...getFieldProps('notas')}
|
|
|
error={Boolean(touched.notas && errors.notas)}
|
|
|
helperText={touched.notas && errors.notas}
|
|
|
- />
|
|
|
+ />
|
|
|
</Stack>
|
|
|
</Stack>
|
|
|
+
|
|
|
+
|
|
|
+ <Modal.Footer>
|
|
|
+ <Button
|
|
|
+ type="submit"
|
|
|
+ className="registerBtn"
|
|
|
+ variant="contained"
|
|
|
+ sx={{ mt: 1, mr: 1 }}
|
|
|
+ >
|
|
|
+ {'Guardar'}
|
|
|
+ </Button>
|
|
|
+ </Modal.Footer>
|
|
|
+
|
|
|
</Form>
|
|
|
</FormikProvider>
|
|
|
|
|
|
- <Modal.Footer>OK</Modal.Footer>
|
|
|
+
|
|
|
|
|
|
</Modal.Body>
|
|
|
</Modal>
|