|
@@ -13,7 +13,9 @@ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
|
import {
|
|
import {
|
|
|
Button, Stack, TextField, MenuItem, FormControl, InputLabel, Select,
|
|
Button, Stack, TextField, MenuItem, FormControl, InputLabel, Select,
|
|
|
Backdrop, CircularProgress,
|
|
Backdrop, CircularProgress,
|
|
|
- Tabs, Tab, Box, Divider, FormGroup, FormControlLabel, Checkbox
|
|
|
|
|
|
|
+ Tabs, Tab, Box, Divider, FormGroup, FormControlLabel, Checkbox,
|
|
|
|
|
+ Dialog, DialogContent, DialogTitle, DialogActions,
|
|
|
|
|
+ DialogContentText,
|
|
|
} from '@mui/material';
|
|
} from '@mui/material';
|
|
|
|
|
|
|
|
import toast, { Toaster } from 'react-hot-toast';
|
|
import toast, { Toaster } from 'react-hot-toast';
|
|
@@ -28,7 +30,6 @@ async function getPuestoSuperior(puesto, auth) {
|
|
|
if (puesto.length < 2) return []
|
|
if (puesto.length < 2) return []
|
|
|
let rest = new Service(`/plaza/keypuestosup?keyword=${puesto}`)
|
|
let rest = new Service(`/plaza/keypuestosup?keyword=${puesto}`)
|
|
|
let result = await rest.get(auth.token)
|
|
let result = await rest.get(auth.token)
|
|
|
- // console.log(result)
|
|
|
|
|
if (result?.data?.length > 0) {
|
|
if (result?.data?.length > 0) {
|
|
|
result = result.data.map((item) => ({ 'title': item.nombre, id: item.id }))
|
|
result = result.data.map((item) => ({ 'title': item.nombre, id: item.id }))
|
|
|
return result;
|
|
return result;
|
|
@@ -36,6 +37,23 @@ async function getPuestoSuperior(puesto, auth) {
|
|
|
return [];
|
|
return [];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+async function savePuestoSuperior(input, auth) {
|
|
|
|
|
+ let rest = new Service("/plaza/puestosuperior")
|
|
|
|
|
+ let body = {
|
|
|
|
|
+ "active": 1,
|
|
|
|
|
+ "nombre": input.title,
|
|
|
|
|
+ "decription": input.id,
|
|
|
|
|
+ "modifyday": "2023-02-12T23:55:26.007",
|
|
|
|
|
+ "createday": "2023-02-12T23:55:26.007",
|
|
|
|
|
+ "id": null,
|
|
|
|
|
+ "descripction": input.id,
|
|
|
|
|
+ "modify_day": "2023-02-12T23:55:26.007",
|
|
|
|
|
+ }
|
|
|
|
|
+ let result = await rest.post(body, auth.token);
|
|
|
|
|
+ let { id, nombre } = result;
|
|
|
|
|
+ return { id, nombre }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
const plazeSchema = Yup.object({
|
|
const plazeSchema = Yup.object({
|
|
|
id: Yup.number(),
|
|
id: Yup.number(),
|
|
@@ -104,9 +122,31 @@ function Edit(props) {
|
|
|
id: '',
|
|
id: '',
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const handleCloseDialog = () => {
|
|
|
|
|
+ toggleOpenDialog(false);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleSubmitDialog = async (event) => {
|
|
|
|
|
+ event.preventDefault();
|
|
|
|
|
+ let { id, nombre } = await savePuestoSuperior(dialogValue, auth)
|
|
|
|
|
+ if (id) {
|
|
|
|
|
+ let to_set = {
|
|
|
|
|
+ title: nombre,
|
|
|
|
|
+ id: id,
|
|
|
|
|
+ }
|
|
|
|
|
+ if (to_set.id) {
|
|
|
|
|
+ setDialogValue(to_set);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ handleCloseDialog();
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
let setDialogValue = (value) => {
|
|
let setDialogValue = (value) => {
|
|
|
- // console.log('llamada', value)
|
|
|
|
|
- // setValues({...values, puestosuperior: value?.title })
|
|
|
|
|
|
|
+ if (value?.id !== undefined && isNaN(value?.id) === false) {
|
|
|
|
|
+ // setValues({ ...values, puestosuperior: value?.id })
|
|
|
|
|
+ setValue('puestosuperior', value?.id)
|
|
|
|
|
+ }
|
|
|
setDialogValueHook(value)
|
|
setDialogValueHook(value)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -179,12 +219,18 @@ function Edit(props) {
|
|
|
let { areadeptoplz_id, fecha, tests, puestosuperior } = response.data;
|
|
let { areadeptoplz_id, fecha, tests, puestosuperior } = response.data;
|
|
|
let temp_test = tests.map(t => ({ id: t.id }))
|
|
let temp_test = tests.map(t => ({ id: t.id }))
|
|
|
setChecklist(temp_test.map(t => t.id))
|
|
setChecklist(temp_test.map(t => t.id))
|
|
|
- console.log('puesto sup',puestosuperior)
|
|
|
|
|
- reset({
|
|
|
|
|
- ...response.data,
|
|
|
|
|
- aredepto: areadeptoplz_id,
|
|
|
|
|
- fecha: new Date(fecha),
|
|
|
|
|
- tests: temp_test,
|
|
|
|
|
|
|
+ console.log('puesto sup', puestosuperior)
|
|
|
|
|
+
|
|
|
|
|
+ let temp_puesto = {
|
|
|
|
|
+ title: puestosuperior.nombre,
|
|
|
|
|
+ id: puestosuperior.id
|
|
|
|
|
+ }
|
|
|
|
|
+ // setDialogValue(temp_puesto)
|
|
|
|
|
+ reset({
|
|
|
|
|
+ ...response.data,
|
|
|
|
|
+ aredepto: areadeptoplz_id,
|
|
|
|
|
+ fecha: new Date(fecha),
|
|
|
|
|
+ tests: temp_test,
|
|
|
puestosuperior: puestosuperior.id
|
|
puestosuperior: puestosuperior.id
|
|
|
})
|
|
})
|
|
|
// setDialogValue({ title: puestosuperior.nombre, id: puestosuperior.id })
|
|
// setDialogValue({ title: puestosuperior.nombre, id: puestosuperior.id })
|
|
@@ -228,6 +274,55 @@ function Edit(props) {
|
|
|
<Tab label="Pruebas" />
|
|
<Tab label="Pruebas" />
|
|
|
</Tabs>
|
|
</Tabs>
|
|
|
|
|
|
|
|
|
|
+ <Dialog open={openDialog} onClose={handleCloseDialog}>
|
|
|
|
|
+ <form onSubmit={handleSubmitDialog}>
|
|
|
|
|
+ <DialogTitle>Agrega un nuevo Puesto</DialogTitle>
|
|
|
|
|
+ <DialogContent>
|
|
|
|
|
+ <DialogContentText>
|
|
|
|
|
+ Agrega la descripcion del puesto
|
|
|
|
|
+ </DialogContentText>
|
|
|
|
|
+
|
|
|
|
|
+ <TextField
|
|
|
|
|
+ autoFocus
|
|
|
|
|
+ margin="dense"
|
|
|
|
|
+ id="name"
|
|
|
|
|
+ value={dialogValue?.title}
|
|
|
|
|
+ onChange={(event) =>
|
|
|
|
|
+ setDialogValue({
|
|
|
|
|
+ ...dialogValue,
|
|
|
|
|
+ title: event.target.value,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ label="Puesto"
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ variant="standard"
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
|
|
+ <TextField
|
|
|
|
|
+ margin="dense"
|
|
|
|
|
+ id="name"
|
|
|
|
|
+ value={dialogValue?.id}
|
|
|
|
|
+ onChange={(event) =>
|
|
|
|
|
+ setDialogValue({
|
|
|
|
|
+ ...dialogValue,
|
|
|
|
|
+ id: event.target.value,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ label="Descripción"
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ variant="standard"
|
|
|
|
|
+ />
|
|
|
|
|
+ </DialogContent>
|
|
|
|
|
+ <DialogActions>
|
|
|
|
|
+ <Button onClick={handleCloseDialog}>Cancelar</Button>
|
|
|
|
|
+ <Button type="submit">Agregar</Button>
|
|
|
|
|
+ </DialogActions>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ </Dialog>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
<form onSubmit={handleSubmit(onSubmit)}>
|
|
<form onSubmit={handleSubmit(onSubmit)}>
|
|
|
<TabPanel value={tab} index={1}>
|
|
<TabPanel value={tab} index={1}>
|
|
|
<Stack spacing={1}>
|
|
<Stack spacing={1}>
|
|
@@ -350,35 +445,6 @@ function Edit(props) {
|
|
|
</Controller>
|
|
</Controller>
|
|
|
</FormControl>
|
|
</FormControl>
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- {
|
|
|
|
|
- /* <FormControl fullWidth>
|
|
|
|
|
- <InputLabel id="demo-simple-select-label">Puesto Superior</InputLabel>
|
|
|
|
|
- <Controller
|
|
|
|
|
- helperText={errors.puestosuperior?.message}
|
|
|
|
|
- error={Boolean(errors?.puestosuperior)}
|
|
|
|
|
- name="puestosuperior"
|
|
|
|
|
- control={control}
|
|
|
|
|
- render={({field}) =>
|
|
|
|
|
- <Select {...field}>
|
|
|
|
|
- {
|
|
|
|
|
- categories ?
|
|
|
|
|
- categories.data.map(cate => {
|
|
|
|
|
- return (
|
|
|
|
|
- <MenuItem key={cate.id} value={cate.id}>{cate.nombre}</MenuItem>
|
|
|
|
|
- )
|
|
|
|
|
- })
|
|
|
|
|
- : <MenuItem>Null</MenuItem>
|
|
|
|
|
- }
|
|
|
|
|
- </Select>
|
|
|
|
|
- }
|
|
|
|
|
- >
|
|
|
|
|
-
|
|
|
|
|
- </Controller>
|
|
|
|
|
- </FormControl> */
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
</Stack>
|
|
</Stack>
|
|
|
|
|
|
|
|
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|