|
@@ -3,36 +3,56 @@ import * as Yup from 'yup';
|
3
|
3
|
import { useFormik, Form, FormikProvider } from 'formik';
|
4
|
4
|
import { Modal } from 'react-bootstrap'
|
5
|
5
|
|
6
|
|
-import {
|
7
|
|
- Box, Button,
|
8
|
|
- Stack, TextField,
|
9
|
|
- InputLabel,MenuItem,FormControl,Select
|
10
|
|
-} from '@mui/material';
|
|
6
|
+import DateFnsUtils from '@date-io/date-fns';
|
|
7
|
+import { DesktopDatePicker,LocalizationProvider } from '@mui/lab';
|
|
8
|
+import { Button, Stack, TextField, } from '@mui/material';
|
11
|
9
|
|
|
10
|
+import { Service } from '../../Utils/HTTP';
|
|
11
|
+import useAuth from '../../Auth/useAuth';
|
12
|
12
|
|
13
|
13
|
|
14
|
14
|
export default function Manual ( props ) {
|
15
|
15
|
|
16
|
16
|
const NewPlazaSchema = Yup.object().shape({
|
17
|
17
|
nombrepuesto : Yup.string().required('El nombre es requerido').min(5).max(100),
|
18
|
|
- puestosuperior : Yup.number("El puesto superior debe ser un numero"),
|
19
|
|
- areadepto : Yup.number().required('Escoge alguna area'),
|
20
|
|
- fecha : Yup.date("Ingresa una fecha válida").required('Ingresa una fecha válida'),
|
21
|
|
- notas : Yup.string().required('Ingresa una fecha válida'),
|
|
18
|
+ puestosuperior : Yup.number("El puesto superior debe ser un número"),
|
|
19
|
+ aredepto : Yup.number().required('Escoge alguna área'),
|
|
20
|
+ fecha : Yup.date("Ingresa una fecha válida"),
|
|
21
|
+ notas : Yup.string("Ingresa una nota válida").min(5).max(150),
|
22
|
22
|
})
|
23
|
23
|
|
|
24
|
+ const [date, setDate] = React.useState(new Date());
|
|
25
|
+ const auth = useAuth();
|
|
26
|
+ const token = auth.getToken();
|
|
27
|
+
|
24
|
28
|
let { visible, onClose, success } = props
|
25
|
29
|
|
26
|
30
|
const formik = useFormik({
|
27
|
31
|
initialValues: {
|
28
|
|
- nombrepuesto: "",
|
29
|
|
- puestosuperior: "",
|
30
|
|
- areadepto: "",
|
31
|
|
- fecha: "",
|
32
|
|
- notas: "",
|
|
32
|
+ nombrepuesto: "QA ENGINIER",
|
|
33
|
+ puestosuperior: 3,
|
|
34
|
+ aredepto: 1,
|
|
35
|
+ fecha: date,
|
|
36
|
+ notas: "alguna nota ",
|
33
|
37
|
},
|
34
|
38
|
onSubmit: (fields) => {
|
35
|
|
- console.log(fields)
|
|
39
|
+ fields['fecha'] = "2023-06-11T00:22:15.211"//new Date(fields.fecha).toString() //getDate(fields.fecha);
|
|
40
|
+ fields['areadeptoplz_id'] = 1;
|
|
41
|
+ fields['id'] = -1;
|
|
42
|
+
|
|
43
|
+ console.log(fields);
|
|
44
|
+
|
|
45
|
+ let Rest = new Service('/plaza/save');
|
|
46
|
+
|
|
47
|
+ Rest
|
|
48
|
+ .post( fields, token )
|
|
49
|
+ .then(data => {
|
|
50
|
+ console.log('data ', data)
|
|
51
|
+ })
|
|
52
|
+ .catch(err => {
|
|
53
|
+ console.error(err)
|
|
54
|
+ })
|
|
55
|
+
|
36
|
56
|
},
|
37
|
57
|
validationSchema: NewPlazaSchema,
|
38
|
58
|
});
|
|
@@ -54,7 +74,7 @@ export default function Manual ( props ) {
|
54
|
74
|
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
55
|
75
|
|
56
|
76
|
<TextField
|
57
|
|
- label="Nombre: "
|
|
77
|
+ label="Nombre"
|
58
|
78
|
fullWidth
|
59
|
79
|
{...getFieldProps('nombrepuesto')}
|
60
|
80
|
error={Boolean(touched.nombrepuesto && errors.nombrepuesto)}
|
|
@@ -62,7 +82,7 @@ export default function Manual ( props ) {
|
62
|
82
|
/>
|
63
|
83
|
|
64
|
84
|
<TextField
|
65
|
|
- label="Puesto Superior: "
|
|
85
|
+ label="Puesto Superior"
|
66
|
86
|
fullWidth
|
67
|
87
|
{...getFieldProps('puestosuperior')}
|
68
|
88
|
error={Boolean(touched.puestosuperior && errors.puestosuperior)}
|
|
@@ -75,19 +95,32 @@ export default function Manual ( props ) {
|
75
|
95
|
label="Departamento"
|
76
|
96
|
fullWidth
|
77
|
97
|
type="text"
|
78
|
|
- {...getFieldProps('puestosuperior')}
|
79
|
|
- error={Boolean(touched.areadepto && errors.areadepto)}
|
80
|
|
- helperText={touched.areadepto && errors.areadepto}
|
81
|
|
- />
|
82
|
|
- <TextField
|
83
|
|
- label="Fecha Creacion"
|
84
|
|
- fullWidth
|
85
|
|
- type="text"
|
86
|
|
- {...getFieldProps('fecha')}
|
87
|
|
- error={Boolean(touched.fecha && errors.fecha)}
|
88
|
|
- helperText={touched.fecha && errors.fecha}
|
|
98
|
+ {...getFieldProps('aredepto')}
|
|
99
|
+ error={Boolean(touched.aredepto && errors.aredepto)}
|
|
100
|
+ helperText={touched.aredepto && errors.aredepto}
|
89
|
101
|
/>
|
|
102
|
+
|
|
103
|
+ <LocalizationProvider
|
|
104
|
+ dateAdapter={DateFnsUtils}>
|
|
105
|
+ <DesktopDatePicker
|
|
106
|
+ label="Fecha Creación"
|
|
107
|
+ fullWidth
|
|
108
|
+ inputFormat="dd/MM/yyyy"
|
|
109
|
+ {...getFieldProps('fecha')}
|
|
110
|
+ value={date}
|
|
111
|
+ onChange={setDate}
|
|
112
|
+ renderInput={(params) =>
|
|
113
|
+ <TextField
|
|
114
|
+ disabled={true}
|
|
115
|
+ label="Fecha Creación"
|
|
116
|
+ fullWidth
|
|
117
|
+ {...params}
|
|
118
|
+ />}
|
|
119
|
+ />
|
|
120
|
+ </LocalizationProvider>
|
|
121
|
+
|
90
|
122
|
</Stack>
|
|
123
|
+
|
91
|
124
|
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>
|
92
|
125
|
<TextField
|
93
|
126
|
id="filled-multiline-static"
|
|
@@ -95,19 +128,32 @@ export default function Manual ( props ) {
|
95
|
128
|
rows={4}
|
96
|
129
|
defaultValue="Default Value"
|
97
|
130
|
variant="filled"
|
98
|
|
- label="notas"
|
|
131
|
+ label="Notas"
|
99
|
132
|
fullWidth
|
100
|
133
|
type="text"
|
101
|
134
|
{...getFieldProps('notas')}
|
102
|
135
|
error={Boolean(touched.notas && errors.notas)}
|
103
|
136
|
helperText={touched.notas && errors.notas}
|
104
|
|
- />
|
|
137
|
+ />
|
105
|
138
|
</Stack>
|
106
|
139
|
</Stack>
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+ <Modal.Footer>
|
|
143
|
+ <Button
|
|
144
|
+ type="submit"
|
|
145
|
+ className="registerBtn"
|
|
146
|
+ variant="contained"
|
|
147
|
+ sx={{ mt: 1, mr: 1 }}
|
|
148
|
+ >
|
|
149
|
+ {'Guardar'}
|
|
150
|
+ </Button>
|
|
151
|
+ </Modal.Footer>
|
|
152
|
+
|
107
|
153
|
</Form>
|
108
|
154
|
</FormikProvider>
|
109
|
155
|
|
110
|
|
- <Modal.Footer>OK</Modal.Footer>
|
|
156
|
+
|
111
|
157
|
|
112
|
158
|
</Modal.Body>
|
113
|
159
|
</Modal>
|