fix error de estado despues de registrar

This commit is contained in:
Mariela 2022-08-02 00:13:09 -06:00
parent fa4dc9f410
commit ac0984d5af
2 changed files with 25 additions and 24 deletions

View File

@ -261,6 +261,7 @@ export class AppService {
hourMax: hourMax, hourMax: hourMax,
bookable: bookable, bookable: bookable,
community_id: community_id, community_id: community_id,
status: '1'
}; };
return this.clientCommonAreaApp return this.clientCommonAreaApp
.send<string>(pattern, payload) .send<string>(pattern, payload)

View File

@ -21,7 +21,6 @@ const AreasComunes = () => {
let emptyCommonArea = { let emptyCommonArea = {
_id: null, _id: null,
dni: '',
name: '', name: '',
hourMin: '', hourMin: '',
hourMax: '', hourMax: '',
@ -106,41 +105,42 @@ const AreasComunes = () => {
else return response.json(); else return response.json();
}) })
.then((data) => { .then((data) => {
if (data) { if (data) {
data.map(item => { if (_common_area.bookable == '1') {
if (item.bookable == '1') { _common_area.bookable_text = 'Necesaria';
item.bookable_text = 'Necesaria'; } else {
} else { _common_area.bookable_text = 'No es necesaria';
item.bookable_text = 'No es necesarioa'; }
}
if (item.status == '1') { if (_common_area.status == '1') {
item.status_text = 'Activo'; _common_area.status_text = 'Activo';
} else if (item.status == '0') { } else if (_common_area.status == '0') {
item.status_text = 'Inactivo'; _common_area.status_text = 'Inactivo';
} else { } else {
item.status_text = 'Eliminado'; _common_area.status_text = 'Eliminado';
} }
})
} }
_common_area = data.filter(
(val) => val.status != -1,
)
_common_areas.push(_common_area); _common_areas.push(_common_area);
toast.current.show({ toast.current.show({
severity: 'success', severity: 'success',
summary: 'Registro exitoso', summary: 'Registro exitoso',
detail: 'Área Común Creada', detail: 'Área Común Creada',
life: 3000, life: 3000,
}); });
setCommonAreaList(_common_areas); setCommonAreaList(_common_areas);
setCommonArea(emptyCommonArea); setCommonArea(emptyCommonArea);
}) })
.catch((err) => console.log('Ocurrió un error con el fetch', err)); .catch((err) => {
console.log('Ocurrió un error con el fetch', err);
toast.current.show({
severity: 'danger',
summary: 'Error',
detail: 'No se pudo registrar el área común',
life: 3000
});
});
} else { } else {
setSubmitted(true); setSubmitted(true);
} }