|
@@ -9,12 +9,14 @@ import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
|
9
|
9
|
|
10
|
10
|
import {
|
11
|
11
|
Button, Stack, TextField, MenuItem, FormControl, InputLabel, Select,
|
12
|
|
- Backdrop, CircularProgress
|
|
12
|
+ Backdrop, CircularProgress,Box,Divider,
|
|
13
|
+ Tabs, Tab, FormGroup, Checkbox,FormControlLabel
|
13
|
14
|
} from '@mui/material';
|
14
|
15
|
|
15
|
16
|
import { Service } from '../../Utils/HTTP';
|
16
|
17
|
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
17
|
18
|
import useAuth from '../../Auth/useAuth';
|
|
19
|
+import { TabPanel } from './TabPanel'
|
18
|
20
|
|
19
|
21
|
function Manual(props) {
|
20
|
22
|
|
|
@@ -26,7 +28,13 @@ function Manual(props) {
|
26
|
28
|
return await rest.getQuery(token)
|
27
|
29
|
}
|
28
|
30
|
|
|
31
|
+ const getTest = async () => {
|
|
32
|
+ let rest = new Service("/tests/getAll")
|
|
33
|
+ return await rest.getQuery(token)
|
|
34
|
+ }
|
|
35
|
+
|
29
|
36
|
const { data } = useQuery('categories', getCategories);
|
|
37
|
+ const { data: tests } = useQuery('tests', getTest);
|
30
|
38
|
const queryClient = useQueryClient();
|
31
|
39
|
|
32
|
40
|
const NewPlazaSchema = Yup.object().shape({
|
|
@@ -34,11 +42,14 @@ function Manual(props) {
|
34
|
42
|
puestosuperior: Yup.number("El puesto superior debe ser un número").required("El puesto es requerido"),
|
35
|
43
|
aredepto: Yup.number().required('Escoge alguna área'),
|
36
|
44
|
fecha: Yup.date("Ingresa una fecha válida"),
|
37
|
|
- notas: Yup.string("Ingresa una nota válida").min(5,"Ingresa una nota válida").max(150),
|
|
45
|
+ notas: Yup.string("Ingresa una nota válida").min(5, "Ingresa una nota válida").max(150),
|
38
|
46
|
})
|
39
|
47
|
|
40
|
48
|
const [departamento, setDepartamento] = React.useState('');
|
41
|
49
|
const [open, setOpen] = React.useState(false);
|
|
50
|
+ const [date, setDate] = React.useState(new Date());
|
|
51
|
+ const [tab, setTab] = React.useState(0);
|
|
52
|
+
|
42
|
53
|
const handleClose = () => false
|
43
|
54
|
|
44
|
55
|
const changeDepartamento = (event) => {
|
|
@@ -52,8 +63,6 @@ function Manual(props) {
|
52
|
63
|
|
53
|
64
|
const puestoMutation = useMutation(agregarPuesto)
|
54
|
65
|
|
55
|
|
-
|
56
|
|
- const [date, setDate] = React.useState(new Date());
|
57
|
66
|
let { visible, onClose } = props
|
58
|
67
|
|
59
|
68
|
const formik = useFormik({
|
|
@@ -71,15 +80,15 @@ function Manual(props) {
|
71
|
80
|
fields['areadeptoplz_id'] = 1;
|
72
|
81
|
fields['id'] = -1;
|
73
|
82
|
|
74
|
|
- puestoMutation.mutate(fields,{
|
75
|
|
- onSuccess:() =>{
|
|
83
|
+ puestoMutation.mutate(fields, {
|
|
84
|
+ onSuccess: () => {
|
76
|
85
|
setOpen(false)
|
77
|
86
|
resetForm();
|
78
|
87
|
onClose();
|
79
|
88
|
queryClient.invalidateQueries('puestos')
|
80
|
89
|
toast.success("Puesto Agregado")
|
81
|
90
|
},
|
82
|
|
- onError:() =>{
|
|
91
|
+ onError: () => {
|
83
|
92
|
setOpen(false)
|
84
|
93
|
toast.error("Ups!! Ocurrio un error, inténtalo más tarde")
|
85
|
94
|
}
|
|
@@ -88,99 +97,133 @@ function Manual(props) {
|
88
|
97
|
validationSchema: NewPlazaSchema,
|
89
|
98
|
});
|
90
|
99
|
|
|
100
|
+ const changeTab = (_event, newValue) => {
|
|
101
|
+ setTab(newValue);
|
|
102
|
+ };
|
|
103
|
+
|
91
|
104
|
const { errors, touched, handleSubmit, getFieldProps } = formik;
|
92
|
105
|
|
93
|
106
|
return (
|
94
|
107
|
|
95
|
108
|
<Modal size="lg" aria-labelledby="contained-modal-title-vcenter" centered show={visible} onHide={onClose}>
|
|
109
|
+
|
96
|
110
|
<Modal.Header>
|
97
|
111
|
<button onClick={onClose} type="button" className="close" data-dismiss="modal">×</button>
|
98
|
112
|
<h4 className="modal-title" style={{ color: '#252525' }}>Agregar plaza</h4>
|
99
|
113
|
</Modal.Header>
|
100
|
114
|
<Modal.Body className="modal-body">
|
101
|
115
|
|
102
|
|
- <FormikProvider style={{ padding: 25 }} value={formik}>
|
|
116
|
+ <Tabs value={tab} onChange={changeTab} aria-label="basic tabs example">
|
|
117
|
+ <Tab label="Información" />
|
|
118
|
+ <Tab label="Pruebas" />
|
|
119
|
+ </Tabs>
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+ <FormikProvider style={{ paddingTop: 25 }} value={formik}>
|
103
|
124
|
<Form autoComplete="off" noValidate onSubmit={handleSubmit}>
|
104
|
|
- <Stack spacing={3}>
|
105
|
125
|
|
106
|
|
- <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
126
|
+ <TabPanel value={tab} index={1}>
|
|
127
|
+ <Stack spacing={1}>
|
|
128
|
+ <Box style={{ paddingTop :5, paddingLeft :15 }}>
|
|
129
|
+ <Divider/>
|
|
130
|
+ <h4 style={{paddingTop :10, paddingBottom:10}}>Seleciona los test a realizar</h4>
|
|
131
|
+ <Divider/>
|
|
132
|
+ <FormGroup>
|
|
133
|
+ {
|
|
134
|
+ tests ?
|
|
135
|
+ tests.data.map( test => (
|
|
136
|
+ <FormControlLabel control={<Checkbox defaultChecked />} label={test.nombre} />
|
|
137
|
+ )): null
|
|
138
|
+ }
|
|
139
|
+ </FormGroup>
|
|
140
|
+ </Box>
|
|
141
|
+ </Stack>
|
|
142
|
+ </TabPanel>
|
107
|
143
|
|
108
|
|
- <TextField
|
109
|
|
- label="Nombre"
|
110
|
|
- fullWidth
|
111
|
|
- {...getFieldProps('nombrepuesto')}
|
112
|
|
- error={Boolean(touched.nombrepuesto && errors.nombrepuesto)}
|
113
|
|
- helperText={touched.nombrepuesto && errors.nombrepuesto}
|
114
|
|
- />
|
|
144
|
+ <TabPanel value={tab} index={0}>
|
115
|
145
|
|
116
|
|
- <TextField
|
117
|
|
- label="Puesto Superior"
|
118
|
|
- fullWidth
|
119
|
|
- {...getFieldProps('puestosuperior')}
|
120
|
|
- error={Boolean(touched.puestosuperior && errors.puestosuperior)}
|
121
|
|
- helperText={touched.puestosuperior && errors.puestosuperior}
|
|
146
|
+ <Stack spacing={3}>
|
|
147
|
+ <Stack direction={{ xs: 'column', sm: 'row' }} spacing={4}>
|
|
148
|
+ <TextField
|
|
149
|
+ label="Nombre"
|
|
150
|
+ fullWidth
|
|
151
|
+ {...getFieldProps('nombrepuesto')}
|
|
152
|
+ error={Boolean(touched.nombrepuesto && errors.nombrepuesto)}
|
|
153
|
+ helperText={touched.nombrepuesto && errors.nombrepuesto}
|
122
|
154
|
/>
|
123
|
155
|
|
124
|
|
- </Stack>
|
125
|
|
- <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
126
|
|
- <FormControl fullWidth>
|
127
|
|
- <InputLabel id="demo-simple-select-label">Departamento</InputLabel>
|
128
|
|
- <Select
|
129
|
|
- labelId="demo-simple-select-label"
|
130
|
|
- value={departamento}
|
131
|
|
- label="Departamento"
|
132
|
|
- onChange={changeDepartamento}
|
133
|
|
- {...getFieldProps('aredepto')}
|
134
|
|
- error={Boolean(touched.aredepto && errors.aredepto)} >
|
135
|
|
- {
|
136
|
|
- data ?
|
137
|
|
- data.data.map(cate => {
|
138
|
|
- return (
|
139
|
|
- <MenuItem key={cate.id} value={cate.id}>{cate.nombre}</MenuItem>
|
140
|
|
- )
|
141
|
|
- })
|
142
|
|
- : <MenuItem>Null</MenuItem>
|
143
|
|
- }
|
144
|
|
- </Select>
|
145
|
|
- </FormControl>
|
146
|
|
-
|
147
|
|
-
|
148
|
|
- <LocalizationProvider
|
149
|
|
- dateAdapter={DateFnsUtils}>
|
150
|
|
- <DesktopDatePicker
|
151
|
|
- label="Fecha Creación"
|
|
156
|
+ <TextField
|
|
157
|
+ label="Puesto Superior"
|
152
|
158
|
fullWidth
|
153
|
|
- inputFormat="dd/MM/yyyy"
|
154
|
|
- {...getFieldProps('fecha')}
|
155
|
|
- value={date}
|
156
|
|
- onChange={setDate}
|
157
|
|
- renderInput={(params) =>
|
158
|
|
- <TextField
|
159
|
|
- disabled={true}
|
160
|
|
- label="Fecha Creación"
|
161
|
|
- fullWidth
|
162
|
|
- {...params}
|
|
159
|
+ {...getFieldProps('puestosuperior')}
|
|
160
|
+ error={Boolean(touched.puestosuperior && errors.puestosuperior)}
|
|
161
|
+ helperText={touched.puestosuperior && errors.puestosuperior}
|
|
162
|
+ />
|
|
163
|
+ </Stack>
|
|
164
|
+
|
|
165
|
+ <Stack direction={{ xs: 'column', sm: 'row' }} spacing={4}>
|
|
166
|
+
|
|
167
|
+ <FormControl fullWidth>
|
|
168
|
+ <InputLabel id="demo-simple-select-label">Departamento</InputLabel>
|
|
169
|
+ <Select
|
|
170
|
+ labelId="demo-simple-select-label"
|
|
171
|
+ value={departamento}
|
|
172
|
+ label="Departamento"
|
|
173
|
+ onChange={changeDepartamento}
|
|
174
|
+ {...getFieldProps('aredepto')}
|
|
175
|
+ error={Boolean(touched.aredepto && errors.aredepto)} >
|
|
176
|
+ {
|
|
177
|
+ data ?
|
|
178
|
+ data.data.map(cate => {
|
|
179
|
+ return (
|
|
180
|
+ <MenuItem key={cate.id} value={cate.id}>{cate.nombre}</MenuItem>
|
|
181
|
+ )
|
|
182
|
+ })
|
|
183
|
+ : <MenuItem>Null</MenuItem>
|
|
184
|
+ }
|
|
185
|
+ </Select>
|
|
186
|
+ </FormControl>
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+ <LocalizationProvider
|
|
190
|
+ dateAdapter={DateFnsUtils}>
|
|
191
|
+ <DesktopDatePicker
|
|
192
|
+ label="Fecha Creación"
|
|
193
|
+ fullWidth
|
|
194
|
+ inputFormat="dd/MM/yyyy"
|
|
195
|
+ {...getFieldProps('fecha')}
|
|
196
|
+ value={date}
|
|
197
|
+ onChange={setDate}
|
|
198
|
+ renderInput={(params) =>
|
|
199
|
+ <TextField
|
|
200
|
+ disabled={true}
|
|
201
|
+ label="Fecha Creación"
|
|
202
|
+ fullWidth
|
|
203
|
+ {...params}
|
163
|
204
|
/>}
|
164
|
205
|
/>
|
165
|
|
- </LocalizationProvider>
|
|
206
|
+ </LocalizationProvider>
|
166
|
207
|
|
167
|
|
- </Stack>
|
|
208
|
+ </Stack>
|
168
|
209
|
|
169
|
|
- <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>
|
170
|
|
- <TextField
|
171
|
|
- id="filled-multiline-static"
|
172
|
|
- multiline
|
173
|
|
- rows={4}
|
174
|
|
- variant="filled"
|
175
|
|
- label="Notas"
|
176
|
|
- fullWidth
|
177
|
|
- type="text"
|
178
|
|
- {...getFieldProps('notas')}
|
179
|
|
- error={Boolean(touched.notas && errors.notas)}
|
180
|
|
- helperText={touched.notas && errors.notas}
|
|
210
|
+ <Stack direction={{ xs: 'column', sm: 'row' }} spacing={4}>
|
|
211
|
+ <TextField
|
|
212
|
+ id="filled-multiline-static"
|
|
213
|
+ multiline
|
|
214
|
+ rows={4}
|
|
215
|
+ variant="filled"
|
|
216
|
+ label="Notas"
|
|
217
|
+ fullWidth
|
|
218
|
+ type="text"
|
|
219
|
+ {...getFieldProps('notas')}
|
|
220
|
+ error={Boolean(touched.notas && errors.notas)}
|
|
221
|
+ helperText={touched.notas && errors.notas}
|
181
|
222
|
/>
|
|
223
|
+ </Stack>
|
182
|
224
|
</Stack>
|
183
|
|
- </Stack>
|
|
225
|
+
|
|
226
|
+ </TabPanel>
|
184
|
227
|
|
185
|
228
|
|
186
|
229
|
<Modal.Footer>
|