|
@@ -1,8 +1,7 @@
|
1
|
|
-import React, { memo, useEffect } from 'react';
|
|
1
|
+import React, { memo, useEffect, useCallback, useRef } from 'react';
|
2
|
2
|
import { Modal } from 'react-bootstrap'
|
3
|
|
-import { useForm, Controller } from "react-hook-form";
|
4
|
|
-import { yupResolver } from '@hookform/resolvers/yup';
|
5
|
3
|
import * as Yup from 'yup';
|
|
4
|
+import { useFormik, Form, FormikProvider } from 'formik';
|
6
|
5
|
|
7
|
6
|
|
8
|
7
|
import { TabPanel } from './TabPanel'
|
|
@@ -27,6 +26,7 @@ import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
|
27
|
26
|
const filter = createFilterOptions();
|
28
|
27
|
|
29
|
28
|
async function getPuestoSuperior(puesto, auth) {
|
|
29
|
+ // console.log('P:', puesto)
|
30
|
30
|
if (puesto.length < 2) return []
|
31
|
31
|
let rest = new Service(`/plaza/keypuestosup?keyword=${puesto}`)
|
32
|
32
|
let result = await rest.get(auth.token)
|
|
@@ -54,7 +54,6 @@ async function savePuestoSuperior(input, auth) {
|
54
|
54
|
return { id, nombre }
|
55
|
55
|
}
|
56
|
56
|
|
57
|
|
-
|
58
|
57
|
const plazeSchema = Yup.object({
|
59
|
58
|
id: Yup.number(),
|
60
|
59
|
nombrepuesto:
|
|
@@ -71,23 +70,33 @@ const plazeSchema = Yup.object({
|
71
|
70
|
|
72
|
71
|
function Edit(props) {
|
73
|
72
|
|
74
|
|
- const { setValue, getValues, reset, control, register, handleSubmit, formState: { errors } } = useForm({
|
75
|
|
- resolver: yupResolver(plazeSchema),
|
76
|
|
- defaultValues: {
|
77
|
|
- nombrepuesto: 'mingtest',
|
78
|
|
- puestosuperior: null,
|
79
|
|
- fecha: '01/01/2019',
|
80
|
|
- notas: 'esto es un ejemplod e una nota',
|
|
73
|
+ const [date, setDate] = React.useState(new Date());
|
|
74
|
+
|
|
75
|
+ const formik = useFormik({
|
|
76
|
+ initialValues: {
|
|
77
|
+ id: 0,
|
|
78
|
+ nombrepuesto: "",
|
|
79
|
+ puestosuperior: 0,
|
81
|
80
|
aredepto: 1,
|
|
81
|
+ fecha: date,
|
|
82
|
+ notas: "",
|
82
|
83
|
tests: []
|
83
|
|
- }
|
|
84
|
+ },
|
|
85
|
+ onSubmit: (fields, { resetForm }) => {
|
|
86
|
+ console.log('submit values', fields)
|
|
87
|
+ saveEditPlaza(fields)
|
|
88
|
+ },
|
|
89
|
+ validationSchema: plazeSchema,
|
84
|
90
|
});
|
85
|
91
|
|
86
|
|
- const onSubmit = data => {
|
|
92
|
+
|
|
93
|
+ const { errors, touched, handleSubmit, getFieldProps, values, setValues } = formik;
|
|
94
|
+
|
|
95
|
+ const saveEditPlaza = data => {
|
87
|
96
|
|
88
|
97
|
let body = {
|
89
|
98
|
...data,
|
90
|
|
- fecha: new Date(data.fecha).toISOString()
|
|
99
|
+ fecha: new Date(data.fecha).toISOString(),
|
91
|
100
|
}
|
92
|
101
|
|
93
|
102
|
puestoMutation.mutate(body, {
|
|
@@ -98,8 +107,6 @@ function Edit(props) {
|
98
|
107
|
queryClient.invalidateQueries('puestos')
|
99
|
108
|
},
|
100
|
109
|
onError: () => {
|
101
|
|
- //close();
|
102
|
|
- //setOpen(false)
|
103
|
110
|
toast.error("Lo sentimos ocurrió error inténtalo más tarde")
|
104
|
111
|
}
|
105
|
112
|
})
|
|
@@ -109,9 +116,10 @@ function Edit(props) {
|
109
|
116
|
const auth = useSelector((state) => state.token)
|
110
|
117
|
const queryClient = useQueryClient()
|
111
|
118
|
let { visible, toggle } = props
|
112
|
|
- // const [puestoSup, setPuestoSup] = React.useState('');
|
113
|
119
|
|
114
|
120
|
const [open, setOpen] = React.useState(false);
|
|
121
|
+ const [departamento, setDepartamento] = React.useState('');
|
|
122
|
+ const puestoref = useRef(null);
|
115
|
123
|
const [tab, setTab] = React.useState(0);
|
116
|
124
|
const [checklist, setChecklist] = React.useState([]);
|
117
|
125
|
const [openSugg, setOpenSugg] = React.useState(false);
|
|
@@ -128,6 +136,7 @@ function Edit(props) {
|
128
|
136
|
};
|
129
|
137
|
|
130
|
138
|
const handleSubmitDialog = async (event) => {
|
|
139
|
+ // console.log('handlesubmit', dialogValue)
|
131
|
140
|
event.preventDefault();
|
132
|
141
|
let { id, nombre } = await savePuestoSuperior(dialogValue, auth)
|
133
|
142
|
if (id) {
|
|
@@ -136,27 +145,35 @@ function Edit(props) {
|
136
|
145
|
id: id,
|
137
|
146
|
}
|
138
|
147
|
if (to_set.id) {
|
|
148
|
+ // console.log("TO SET", to_set)
|
139
|
149
|
setDialogValue(to_set);
|
|
150
|
+ setValues({...values, puestosuperior: to_set.id})
|
140
|
151
|
}
|
141
|
152
|
}
|
142
|
153
|
handleCloseDialog();
|
143
|
154
|
};
|
144
|
155
|
|
145
|
|
- let setDialogValue = (value) => {
|
146
|
|
- if (value?.id !== undefined && isNaN(value?.id) === false) {
|
147
|
|
- // setValues({ ...values, puestosuperior: value?.id })
|
148
|
|
- setValue('puestosuperior', value?.id)
|
|
156
|
+ let setDialogValue = useCallback((value) => {
|
|
157
|
+ // console.log('value receivied', value)
|
|
158
|
+ let id = value?.id || 0;
|
|
159
|
+ if (id !== 0) {
|
|
160
|
+ console.log('setting value', id)
|
|
161
|
+
|
149
|
162
|
}
|
150
|
163
|
setDialogValueHook(value)
|
151
|
|
- }
|
|
164
|
+ }, [])
|
|
165
|
+
|
|
166
|
+ const changeDepartamento = (event) => {
|
|
167
|
+ setDepartamento(event.target.value);
|
|
168
|
+ };
|
152
|
169
|
|
153
|
170
|
const loading = openSugg && options.length === 0;
|
154
|
171
|
|
155
|
172
|
const AutoCompleteChange = (event, newValue) => {
|
156
|
|
- console.log('newValue', newValue)
|
157
|
|
- setValue('puestosuperior', newValue?.id)
|
|
173
|
+ setValues({ ...values, puestosuperior: newValue?.id })
|
158
|
174
|
|
159
|
175
|
if (typeof newValue === 'string') {
|
|
176
|
+ // console.log('if1')
|
160
|
177
|
setTimeout(() => {
|
161
|
178
|
toggleOpenDialog(true);
|
162
|
179
|
setDialogValue({
|
|
@@ -165,19 +182,20 @@ function Edit(props) {
|
165
|
182
|
});
|
166
|
183
|
});
|
167
|
184
|
} else if (newValue && newValue.inputValue) {
|
|
185
|
+ // console.log('if2')
|
168
|
186
|
toggleOpenDialog(true);
|
169
|
187
|
setDialogValue({
|
170
|
188
|
title: newValue.inputValue,
|
171
|
189
|
id: '',
|
172
|
190
|
});
|
173
|
191
|
} else {
|
|
192
|
+ // console.log('if3')
|
174
|
193
|
setDialogValue(newValue);
|
175
|
194
|
}
|
176
|
195
|
}
|
177
|
196
|
|
178
|
197
|
const addPrueba = (check, id) => {
|
179
|
|
- let tests = getValues("tests")
|
180
|
|
- console.log(tests)
|
|
198
|
+ let { tests } = values
|
181
|
199
|
let temp;
|
182
|
200
|
if (check) {
|
183
|
201
|
temp = [...tests, { id }]
|
|
@@ -185,7 +203,8 @@ function Edit(props) {
|
185
|
203
|
temp = tests.filter(test => test.id !== id);
|
186
|
204
|
}
|
187
|
205
|
setChecklist(temp.map(test => test.id))
|
188
|
|
- setValue('tests', temp)
|
|
206
|
+ // setValue('tests', temp)
|
|
207
|
+ setValues({ ...values, tests: temp })
|
189
|
208
|
};
|
190
|
209
|
|
191
|
210
|
const getCategories = async () => {
|
|
@@ -211,32 +230,36 @@ function Edit(props) {
|
211
|
230
|
|
212
|
231
|
useEffect(() => {
|
213
|
232
|
|
|
233
|
+ let current_id = values.id; // getValues('id')
|
|
234
|
+
|
214
|
235
|
if (visible == null) return;
|
215
|
|
- let rest = new Service(`/plaza/getthis/${visible}`)
|
216
|
|
- rest
|
217
|
|
- .getQuery(auth.token)
|
218
|
|
- .then(response => {
|
219
|
|
- let { areadeptoplz_id, fecha, tests, puestosuperior } = response.data;
|
220
|
|
- let temp_test = tests.map(t => ({ id: t.id }))
|
221
|
|
- setChecklist(temp_test.map(t => t.id))
|
222
|
|
- console.log('puesto sup', puestosuperior)
|
223
|
|
-
|
224
|
|
- let temp_puesto = {
|
225
|
|
- title: puestosuperior.nombre,
|
226
|
|
- id: puestosuperior.id
|
227
|
|
- }
|
228
|
|
- // setDialogValue(temp_puesto)
|
229
|
|
- reset({
|
230
|
|
- ...response.data,
|
231
|
|
- aredepto: areadeptoplz_id,
|
232
|
|
- fecha: new Date(fecha),
|
233
|
|
- tests: temp_test,
|
234
|
|
- puestosuperior: puestosuperior.id
|
|
236
|
+
|
|
237
|
+ if (current_id !== visible) {
|
|
238
|
+ let rest = new Service(`/plaza/getthis/${visible}`)
|
|
239
|
+ rest
|
|
240
|
+ .getQuery(auth.token)
|
|
241
|
+ .then(response => {
|
|
242
|
+ console.log('plz to edit: ', response.data)
|
|
243
|
+ let { areadeptoplz_id, fecha, tests, puestosuperior } = response.data;
|
|
244
|
+ let temp_test = tests.map(t => ({ id: t.id }))
|
|
245
|
+ setChecklist(temp_test.map(t => t.id))
|
|
246
|
+ // console.log('puesto sup', puestosuperior)
|
|
247
|
+ setDialogValue({
|
|
248
|
+ title: puestosuperior.nombre,
|
|
249
|
+ id: puestosuperior.id
|
|
250
|
+ })
|
|
251
|
+ setValues({
|
|
252
|
+ ...response.data,
|
|
253
|
+ aredepto: areadeptoplz_id,
|
|
254
|
+ fecha: new Date(fecha),
|
|
255
|
+ tests: temp_test,
|
|
256
|
+ puestosuperior: puestosuperior.id
|
|
257
|
+ })
|
|
258
|
+ // console.log("INITIAL:", getValues())
|
235
|
259
|
})
|
236
|
|
- // setDialogValue({ title: puestosuperior.nombre, id: puestosuperior.id })
|
237
|
|
- })
|
238
|
|
- .catch(e => console.log(e))
|
|
260
|
+ .catch(e => console.log(e))
|
239
|
261
|
|
|
262
|
+ }
|
240
|
263
|
|
241
|
264
|
let active = true;
|
242
|
265
|
if (!loading) {
|
|
@@ -254,9 +277,7 @@ function Edit(props) {
|
254
|
277
|
active = false;
|
255
|
278
|
};
|
256
|
279
|
|
257
|
|
-
|
258
|
|
-
|
259
|
|
- }, [visible, auth, reset, loading, dialogValue])
|
|
280
|
+ }, [visible, auth, loading, dialogValue, setDialogValue,setValues,values.id])
|
260
|
281
|
|
261
|
282
|
const changeTab = (_event, newValue) => setTab(newValue);
|
262
|
283
|
|
|
@@ -287,12 +308,14 @@ function Edit(props) {
|
287
|
308
|
margin="dense"
|
288
|
309
|
id="name"
|
289
|
310
|
value={dialogValue?.title}
|
290
|
|
- onChange={(event) =>
|
|
311
|
+ onChange={(event) => {
|
|
312
|
+ // console.log('aa', event.target.value)
|
291
|
313
|
setDialogValue({
|
292
|
314
|
...dialogValue,
|
293
|
315
|
title: event.target.value,
|
294
|
316
|
})
|
295
|
317
|
}
|
|
318
|
+ }
|
296
|
319
|
label="Puesto"
|
297
|
320
|
type="text"
|
298
|
321
|
variant="standard"
|
|
@@ -302,12 +325,14 @@ function Edit(props) {
|
302
|
325
|
margin="dense"
|
303
|
326
|
id="name"
|
304
|
327
|
value={dialogValue?.id}
|
305
|
|
- onChange={(event) =>
|
|
328
|
+ onChange={(event) => {
|
|
329
|
+ // console.log('ev', event.target.value)
|
306
|
330
|
setDialogValue({
|
307
|
331
|
...dialogValue,
|
308
|
332
|
id: event.target.value,
|
309
|
333
|
})
|
310
|
334
|
}
|
|
335
|
+ }
|
311
|
336
|
label="Descripción"
|
312
|
337
|
type="text"
|
313
|
338
|
variant="standard"
|
|
@@ -320,203 +345,193 @@ function Edit(props) {
|
320
|
345
|
</form>
|
321
|
346
|
</Dialog>
|
322
|
347
|
|
323
|
|
-
|
324
|
|
-
|
325
|
|
-
|
326
|
|
- <form onSubmit={handleSubmit(onSubmit)}>
|
327
|
|
- <TabPanel value={tab} index={1}>
|
328
|
|
- <Stack spacing={1}>
|
329
|
|
- <Box style={{ paddingTop: 5, paddingLeft: 15 }}>
|
330
|
|
- <Divider />
|
331
|
|
- <h4 style={{ paddingTop: 10, paddingBottom: 10 }}>Seleciona los test a realizar</h4>
|
332
|
|
- <Divider />
|
333
|
|
- <FormGroup>
|
334
|
|
- {
|
335
|
|
- testsCatalog ?
|
336
|
|
- testsCatalog.data.map(test => (
|
337
|
|
- <FormControlLabel
|
338
|
|
- label={test.nombre}
|
339
|
|
- key={test.id}
|
340
|
|
- control={
|
341
|
|
- <Checkbox
|
342
|
|
- checked={checklist.includes((test.id))}
|
343
|
|
- onChange={(event) => addPrueba(event.target.checked, test.id)} />}
|
344
|
|
- />
|
345
|
|
- )) : null
|
346
|
|
- }
|
347
|
|
- </FormGroup>
|
348
|
|
- </Box>
|
349
|
|
- </Stack>
|
350
|
|
- </TabPanel>
|
351
|
|
-
|
352
|
|
- <TabPanel value={tab} index={0} >
|
353
|
|
- <Stack spacing={3}>
|
354
|
|
-
|
355
|
|
- <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
356
|
|
-
|
357
|
|
- <TextField
|
358
|
|
- name="nombrepuesto"
|
359
|
|
- label="Nombre"
|
360
|
|
- fullWidth
|
361
|
|
- helperText={errors.nombrepuesto?.message}
|
362
|
|
- error={Boolean(errors?.nombrepuesto)}
|
363
|
|
- {...register("nombrepuesto")} />
|
364
|
|
-
|
365
|
|
-
|
366
|
|
- <FormControl fullWidth>
|
367
|
|
- <Controller
|
368
|
|
- helperText={errors.puestosuperior?.message}
|
369
|
|
- error={errors?.puestosuperior}
|
370
|
|
- name="puestosuperior"
|
371
|
|
- control={control}
|
372
|
|
- render={({ field }) =>
|
373
|
|
- <Autocomplete
|
374
|
|
- fullWidth
|
375
|
|
- value={dialogValue}
|
376
|
|
- onChange={AutoCompleteChange}
|
377
|
|
- open={openSugg}
|
378
|
|
- onOpen={() => {
|
379
|
|
- setOpenSugg(true);
|
380
|
|
- }}
|
381
|
|
- onClose={() => {
|
382
|
|
- setOpenSugg(false);
|
383
|
|
- }}
|
384
|
|
- isOptionEqualToValue={(option, value) => option.title === value.title}
|
385
|
|
- filterOptions={(options, params) => {
|
386
|
|
- const filtered = filter(options, params);
|
387
|
|
-
|
388
|
|
- if (params.inputValue !== '') {
|
389
|
|
- filtered.push({
|
390
|
|
- inputValue: params.inputValue,
|
391
|
|
- title: `Add "${params.inputValue}"`,
|
392
|
|
- });
|
393
|
|
- }
|
394
|
|
-
|
395
|
|
- return filtered;
|
396
|
|
- }}
|
397
|
|
- id="puesto_superior_autocomplete"
|
398
|
|
- options={options}
|
399
|
|
- loading={loading}
|
400
|
|
- getOptionLabel={(option) => {
|
401
|
|
- if (typeof option === 'string') {
|
402
|
|
- return option;
|
403
|
|
- }
|
404
|
|
- if (option.inputValue) {
|
405
|
|
- return option.inputValue;
|
406
|
|
- }
|
407
|
|
- return option.title;
|
408
|
|
- }}
|
409
|
|
- selectOnFocus
|
410
|
|
- clearOnBlur
|
411
|
|
- handleHomeEndKeys
|
412
|
|
- renderOption={(props, option) => <li {...props}>{option.title}</li>}
|
413
|
|
- freeSolo
|
414
|
|
- renderInput={(params) => (
|
415
|
|
- <TextField
|
416
|
|
- {...params}
|
417
|
|
- {...register('puestosuperior')}
|
418
|
|
- error={Boolean(errors.puestosuperior)}
|
419
|
|
- label="Puesto Superior"
|
420
|
|
- InputProps={{
|
421
|
|
- ...params.InputProps,
|
422
|
|
- onChange: (event) => {
|
423
|
|
- // let title = event.target.value;
|
424
|
|
- // console.log('titulo',title)
|
425
|
|
- setOptions([]);
|
426
|
|
- setDialogValue({
|
427
|
|
- title: event.target.value,
|
428
|
|
- id: '',
|
429
|
|
- });
|
430
|
|
- },
|
431
|
|
- endAdornment: (
|
432
|
|
- <React.Fragment>
|
433
|
|
- {loading ? <CircularProgress color="inherit" size={20} /> : null}
|
434
|
|
- {params.InputProps.endAdornment}
|
435
|
|
- </React.Fragment>
|
436
|
|
- ),
|
437
|
|
- }}
|
|
348
|
+ <FormikProvider style={{ paddingTop: 25 }} value={formik}>
|
|
349
|
+ <Form onSubmit={handleSubmit}>
|
|
350
|
+ <TabPanel value={tab} index={1}>
|
|
351
|
+ <Stack spacing={1}>
|
|
352
|
+ <Box style={{ paddingTop: 5, paddingLeft: 15 }}>
|
|
353
|
+ <Divider />
|
|
354
|
+ <h4 style={{ paddingTop: 10, paddingBottom: 10 }}>Seleciona los test a realizar</h4>
|
|
355
|
+ <Divider />
|
|
356
|
+ <FormGroup>
|
|
357
|
+ {
|
|
358
|
+ testsCatalog ?
|
|
359
|
+ testsCatalog.data.map(test => (
|
|
360
|
+ <FormControlLabel
|
|
361
|
+ label={test.nombre}
|
|
362
|
+ key={test.id}
|
|
363
|
+ control={
|
|
364
|
+ <Checkbox
|
|
365
|
+ checked={checklist.includes((test.id))}
|
|
366
|
+ onChange={(event) => addPrueba(event.target.checked, test.id)} />}
|
438
|
367
|
/>
|
439
|
|
- )}
|
440
|
|
-
|
441
|
|
- />
|
442
|
|
-
|
|
368
|
+ )) : null
|
443
|
369
|
}
|
444
|
|
- >
|
445
|
|
- </Controller>
|
446
|
|
- </FormControl>
|
447
|
|
-
|
|
370
|
+ </FormGroup>
|
|
371
|
+ </Box>
|
448
|
372
|
</Stack>
|
449
|
|
-
|
450
|
|
- <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
451
|
|
-
|
452
|
|
- <FormControl fullWidth>
|
453
|
|
- <InputLabel id="demo-simple-select-label2">Departamento</InputLabel>
|
454
|
|
- <Controller
|
455
|
|
- helperText={errors.aredepto?.message}
|
456
|
|
- error={Boolean(errors?.aredepto)}
|
457
|
|
- name="aredepto"
|
458
|
|
- control={control}
|
459
|
|
- render={({ field }) =>
|
460
|
|
- <Select {...field}>
|
461
|
|
- {
|
462
|
|
- categories ?
|
463
|
|
- categories.data.map(cate => {
|
464
|
|
- return (
|
465
|
|
- <MenuItem key={cate.id} value={cate.id}>{cate.nombre}</MenuItem>
|
466
|
|
- )
|
467
|
|
- })
|
468
|
|
- : <MenuItem value={1}>hola</MenuItem>
|
|
373
|
+ </TabPanel>
|
|
374
|
+
|
|
375
|
+ <TabPanel value={tab} index={0} >
|
|
376
|
+ <Stack spacing={3}>
|
|
377
|
+
|
|
378
|
+ <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
379
|
+
|
|
380
|
+ <TextField
|
|
381
|
+ name="nombrepuesto"
|
|
382
|
+ label="Nombre"
|
|
383
|
+ fullWidth
|
|
384
|
+ helperText={errors.nombrepuesto?.message}
|
|
385
|
+ error={Boolean(errors?.nombrepuesto)}
|
|
386
|
+ {...getFieldProps("nombrepuesto")} />
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+ <FormControl fullWidth>
|
|
390
|
+ <Autocomplete
|
|
391
|
+ fullWidth
|
|
392
|
+ value={dialogValue}
|
|
393
|
+ onChange={AutoCompleteChange}
|
|
394
|
+ open={openSugg}
|
|
395
|
+ onOpen={() => {
|
|
396
|
+ setOpenSugg(true);
|
|
397
|
+ }}
|
|
398
|
+ onClose={() => {
|
|
399
|
+ setOpenSugg(false);
|
|
400
|
+ }}
|
|
401
|
+ isOptionEqualToValue={(option, value) => option.title === value.title}
|
|
402
|
+ filterOptions={(options, params) => {
|
|
403
|
+ const filtered = filter(options, params);
|
|
404
|
+
|
|
405
|
+ if (params.inputValue !== '') {
|
|
406
|
+ filtered.push({
|
|
407
|
+ inputValue: params.inputValue,
|
|
408
|
+ title: `Agregar "${params.inputValue}"`,
|
|
409
|
+ });
|
469
|
410
|
}
|
470
|
|
- </Select>
|
471
|
|
- }>
|
472
|
|
- </Controller>
|
473
|
|
- </FormControl>
|
474
|
|
-
|
475
|
|
- <LocalizationProvider dateAdapter={DateFnsUtils}>
|
476
|
|
- <Controller
|
477
|
|
- name="fecha"
|
478
|
|
- control={control}
|
479
|
|
- render={({ field }) =>
|
480
|
|
- <DesktopDatePicker
|
481
|
|
- {...field}
|
482
|
|
- helperText={errors.fecha?.message}
|
483
|
|
- error={Boolean(errors?.fecha)}
|
484
|
|
- label="Fecha Creación"
|
485
|
|
- fullWidth
|
486
|
|
- inputFormat="dd/MM/yyyy"
|
487
|
|
- renderInput={(params) => <TextField {...params} helperText={errors.fecha?.message} />} />}
|
488
|
|
- >
|
489
|
|
- </Controller>
|
490
|
|
- </LocalizationProvider>
|
491
|
|
- </Stack>
|
492
|
411
|
|
493
|
|
- <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>
|
494
|
|
- <TextField
|
495
|
|
- helperText={errors.notas?.message}
|
496
|
|
- error={Boolean(errors?.notas)}
|
497
|
|
- name="notas"
|
498
|
|
- multiline
|
499
|
|
- rows={4}
|
500
|
|
- label="Notas"
|
501
|
|
- fullWidth
|
502
|
|
- type="text"
|
503
|
|
- {...register("notas")}
|
504
|
|
- />
|
|
412
|
+ return filtered;
|
|
413
|
+ }}
|
|
414
|
+ id="puesto_superior_autocomplete"
|
|
415
|
+ options={options}
|
|
416
|
+ loading={loading}
|
|
417
|
+ getOptionLabel={(option) => {
|
|
418
|
+ if (typeof option === 'string') {
|
|
419
|
+ return option;
|
|
420
|
+ }
|
|
421
|
+ if (option.inputValue) {
|
|
422
|
+ return option.inputValue;
|
|
423
|
+ }
|
|
424
|
+ return option.title;
|
|
425
|
+ }}
|
|
426
|
+ selectOnFocus
|
|
427
|
+ // clearOnBlur
|
|
428
|
+ // handleHomeEndKeys
|
|
429
|
+ renderOption={(props, option) => <li key={option.id} {...props}>{option.title}</li>}
|
|
430
|
+ freeSolo
|
|
431
|
+ renderInput={(params) => (
|
|
432
|
+ <TextField
|
|
433
|
+ {...params}
|
|
434
|
+ {...getFieldProps('puestosuperior')}
|
|
435
|
+ error={Boolean(errors.puestosuperior)}
|
|
436
|
+ label="Puesto Superior"
|
|
437
|
+ InputProps={{
|
|
438
|
+ ...params.InputProps,
|
|
439
|
+ onChange: (event) => {
|
|
440
|
+ let title = event.target.value;
|
|
441
|
+ // console.log('titulo', title)
|
|
442
|
+ setOptions([]);
|
|
443
|
+ setDialogValue({
|
|
444
|
+ title: title,
|
|
445
|
+ id: '',
|
|
446
|
+ });
|
|
447
|
+ },
|
|
448
|
+ endAdornment: (
|
|
449
|
+ <React.Fragment>
|
|
450
|
+ {loading ? <CircularProgress color="inherit" size={20} /> : null}
|
|
451
|
+ {params.InputProps.endAdornment}
|
|
452
|
+ </React.Fragment>
|
|
453
|
+ ),
|
|
454
|
+ }}
|
|
455
|
+ />
|
|
456
|
+ )}
|
|
457
|
+
|
|
458
|
+ />
|
|
459
|
+ </FormControl>
|
|
460
|
+
|
|
461
|
+ </Stack>
|
|
462
|
+
|
|
463
|
+ <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
464
|
+
|
|
465
|
+ <FormControl fullWidth>
|
|
466
|
+ <InputLabel id="demo-simple-select-label2">Departamento</InputLabel>
|
|
467
|
+ <Select
|
|
468
|
+ value={departamento}
|
|
469
|
+ label="Departamento"
|
|
470
|
+ onChange={changeDepartamento}
|
|
471
|
+ {...getFieldProps('aredepto')}
|
|
472
|
+ error={Boolean(touched.aredepto && errors.aredepto)}>
|
|
473
|
+ {
|
|
474
|
+ categories ?
|
|
475
|
+ categories.data.map(cate => {
|
|
476
|
+ return (
|
|
477
|
+ <MenuItem key={cate.id} value={cate.id}>{cate.nombre}</MenuItem>
|
|
478
|
+ )
|
|
479
|
+ })
|
|
480
|
+ : <MenuItem value={1}>hola</MenuItem>
|
|
481
|
+ }
|
|
482
|
+ </Select>
|
|
483
|
+ </FormControl>
|
|
484
|
+
|
|
485
|
+ <LocalizationProvider dateAdapter={DateFnsUtils}>
|
|
486
|
+ <DesktopDatePicker
|
|
487
|
+ {...getFieldProps('fecha')}
|
|
488
|
+ helperText={errors.fecha?.message}
|
|
489
|
+ error={Boolean(errors?.fecha)}
|
|
490
|
+ label="Fecha Creación"
|
|
491
|
+ fullWidth
|
|
492
|
+ value={date}
|
|
493
|
+ onChange={setDate}
|
|
494
|
+ inputFormat="dd/MM/yyyy"
|
|
495
|
+ renderInput={ (params) =>
|
|
496
|
+ <TextField
|
|
497
|
+ disabled={true}
|
|
498
|
+ {...params}
|
|
499
|
+ helperText={errors.fecha?.message}
|
|
500
|
+ />
|
|
501
|
+ }
|
|
502
|
+ />
|
|
503
|
+ </LocalizationProvider>
|
|
504
|
+ </Stack>
|
|
505
|
+
|
|
506
|
+ <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>
|
|
507
|
+ <TextField
|
|
508
|
+ helperText={errors.notas?.message}
|
|
509
|
+ error={Boolean(errors?.notas)}
|
|
510
|
+ name="notas"
|
|
511
|
+ multiline
|
|
512
|
+ rows={4}
|
|
513
|
+ label="Notas"
|
|
514
|
+ fullWidth
|
|
515
|
+ type="text"
|
|
516
|
+ {...getFieldProps("notas")}
|
|
517
|
+ />
|
|
518
|
+ </Stack>
|
505
|
519
|
</Stack>
|
506
|
|
- </Stack>
|
507
|
|
- </TabPanel>
|
508
|
|
-
|
509
|
|
- <Modal.Footer>
|
510
|
|
- <Button
|
511
|
|
- type="submit"
|
512
|
|
- className="registerBtn"
|
513
|
|
- variant="contained"
|
514
|
|
- sx={{ mt: 1, mr: 1 }} >
|
515
|
|
- {'Actualizar'}
|
516
|
|
- </Button>
|
517
|
|
- </Modal.Footer>
|
518
|
|
-
|
519
|
|
- </form>
|
|
520
|
+ </TabPanel>
|
|
521
|
+
|
|
522
|
+ <Modal.Footer>
|
|
523
|
+ <Button
|
|
524
|
+ ref={puestoref}
|
|
525
|
+ type="submit"
|
|
526
|
+ className="registerBtn"
|
|
527
|
+ variant="contained"
|
|
528
|
+ sx={{ mt: 1, mr: 1 }} >
|
|
529
|
+ {'Actualizar'}
|
|
530
|
+ </Button>
|
|
531
|
+ </Modal.Footer>
|
|
532
|
+
|
|
533
|
+ </Form>
|
|
534
|
+ </FormikProvider>
|
520
|
535
|
|
521
|
536
|
</Modal.Body>
|
522
|
537
|
<Backdrop
|