|
@@ -27,6 +27,7 @@ import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
|
|
|
const filter = createFilterOptions();
|
|
const filter = createFilterOptions();
|
|
|
|
|
|
|
|
async function getPuestoSuperior(puesto, auth) {
|
|
async function getPuestoSuperior(puesto, auth) {
|
|
|
|
|
+console.log('P:',puesto)
|
|
|
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)
|
|
@@ -128,6 +129,7 @@ function Edit(props) {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleSubmitDialog = async (event) => {
|
|
const handleSubmitDialog = async (event) => {
|
|
|
|
|
+ console.log('handlesubmit',dialogValue)
|
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
|
let { id, nombre } = await savePuestoSuperior(dialogValue, auth)
|
|
let { id, nombre } = await savePuestoSuperior(dialogValue, auth)
|
|
|
if (id) {
|
|
if (id) {
|
|
@@ -137,6 +139,7 @@ function Edit(props) {
|
|
|
}
|
|
}
|
|
|
if (to_set.id) {
|
|
if (to_set.id) {
|
|
|
setDialogValue(to_set);
|
|
setDialogValue(to_set);
|
|
|
|
|
+ reset({ ...getValues(),puestosuperior: to_set.id })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
handleCloseDialog();
|
|
handleCloseDialog();
|
|
@@ -144,24 +147,41 @@ function Edit(props) {
|
|
|
|
|
|
|
|
let setDialogValue = useCallback((value) => {
|
|
let setDialogValue = useCallback((value) => {
|
|
|
console.log('value receivied', value)
|
|
console.log('value receivied', value)
|
|
|
- let id = value.id || 0;
|
|
|
|
|
|
|
+ let id = value?.id || 0;
|
|
|
if (id !== 0) {
|
|
if (id !== 0) {
|
|
|
- // setValues({ ...values, puestosuperior: value?.id })
|
|
|
|
|
- console.log('setting: ', value)
|
|
|
|
|
- setValue('puestosuperior',)
|
|
|
|
|
- console.log('inside', getValues())
|
|
|
|
|
- // return
|
|
|
|
|
|
|
+ reset({ ...getValues(),puestosuperior: id })
|
|
|
|
|
+ setValue('puestosuperior',id)
|
|
|
|
|
+ setDialogValueHook(value)
|
|
|
}
|
|
}
|
|
|
setDialogValueHook(value)
|
|
setDialogValueHook(value)
|
|
|
- },[setValue,getValues])
|
|
|
|
|
|
|
+ },[setValue,reset,getValues])
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // let setDialogValue = useCallback((value) => {
|
|
|
|
|
+ // console.log('value receivied', value)
|
|
|
|
|
+ // let id = value.id || 0;
|
|
|
|
|
+ // if (id !== 0) {
|
|
|
|
|
+ // console.log('setiando valor', value)
|
|
|
|
|
+ // setValue({ puestosuperior: value?.id })
|
|
|
|
|
+ // // setDialogValueHook(value)
|
|
|
|
|
+ // }
|
|
|
|
|
+ // console.log("setiando valor false", value)
|
|
|
|
|
+ // // setDialogValueHook(value)
|
|
|
|
|
+ // }, [setValue])
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
const loading = openSugg && options.length === 0;
|
|
const loading = openSugg && options.length === 0;
|
|
|
|
|
|
|
|
const AutoCompleteChange = (event, newValue) => {
|
|
const AutoCompleteChange = (event, newValue) => {
|
|
|
console.log('newValue', newValue)
|
|
console.log('newValue', newValue)
|
|
|
|
|
+ //this should be change
|
|
|
setValue('puestosuperior', newValue?.id)
|
|
setValue('puestosuperior', newValue?.id)
|
|
|
|
|
|
|
|
if (typeof newValue === 'string') {
|
|
if (typeof newValue === 'string') {
|
|
|
|
|
+ console.log('if1')
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
toggleOpenDialog(true);
|
|
toggleOpenDialog(true);
|
|
|
setDialogValue({
|
|
setDialogValue({
|
|
@@ -170,12 +190,14 @@ function Edit(props) {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
} else if (newValue && newValue.inputValue) {
|
|
} else if (newValue && newValue.inputValue) {
|
|
|
|
|
+ console.log('if2')
|
|
|
toggleOpenDialog(true);
|
|
toggleOpenDialog(true);
|
|
|
setDialogValue({
|
|
setDialogValue({
|
|
|
title: newValue.inputValue,
|
|
title: newValue.inputValue,
|
|
|
id: '',
|
|
id: '',
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ console.log('if3')
|
|
|
setDialogValue(newValue);
|
|
setDialogValue(newValue);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -217,11 +239,12 @@ function Edit(props) {
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
let current_id = getValues('id')
|
|
let current_id = getValues('id')
|
|
|
- console.log({ current_id, visible })
|
|
|
|
|
|
|
+ // console.log({ current_id, visible })
|
|
|
|
|
|
|
|
if (visible == null) return;
|
|
if (visible == null) return;
|
|
|
|
|
|
|
|
if (current_id !== visible) {
|
|
if (current_id !== visible) {
|
|
|
|
|
+ console.log('change with use effect')
|
|
|
|
|
|
|
|
let rest = new Service(`/plaza/getthis/${visible}`)
|
|
let rest = new Service(`/plaza/getthis/${visible}`)
|
|
|
rest
|
|
rest
|
|
@@ -261,12 +284,12 @@ function Edit(props) {
|
|
|
|
|
|
|
|
return () => {
|
|
return () => {
|
|
|
active = false;
|
|
active = false;
|
|
|
- reset()
|
|
|
|
|
|
|
+ // reset()
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- }, [visible, auth, reset, loading, dialogValue, getValues,setDialogValue])
|
|
|
|
|
|
|
+ }, [visible, auth, reset, loading, dialogValue, getValues, setDialogValue])
|
|
|
// console.log('PROPS', props)
|
|
// console.log('PROPS', props)
|
|
|
|
|
|
|
|
|
|
|