From ac0984d5af24f5ddb46bf0d61d0f670c86620bf9 Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 2 Aug 2022 00:13:09 -0600 Subject: [PATCH] fix error de estado despues de registrar --- api-gateway/src/app.service.ts | 1 + .../web-react/src/components/AreasComunes.js | 48 +++++++++---------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 52c79492..1ac8513c 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -261,6 +261,7 @@ export class AppService { hourMax: hourMax, bookable: bookable, community_id: community_id, + status: '1' }; return this.clientCommonAreaApp .send(pattern, payload) diff --git a/web-ui/web-react/src/components/AreasComunes.js b/web-ui/web-react/src/components/AreasComunes.js index 6eff36e4..3b40a941 100644 --- a/web-ui/web-react/src/components/AreasComunes.js +++ b/web-ui/web-react/src/components/AreasComunes.js @@ -21,7 +21,6 @@ const AreasComunes = () => { let emptyCommonArea = { _id: null, - dni: '', name: '', hourMin: '', hourMax: '', @@ -106,41 +105,42 @@ const AreasComunes = () => { else return response.json(); }) .then((data) => { - if (data) { - data.map(item => { - if (item.bookable == '1') { - item.bookable_text = 'Necesaria'; - } else { - item.bookable_text = 'No es necesarioa'; - } - - if (item.status == '1') { - item.status_text = 'Activo'; - } else if (item.status == '0') { - item.status_text = 'Inactivo'; - } else { - item.status_text = 'Eliminado'; - } - }) - } - - _common_area = data.filter( - (val) => val.status != -1, - ) + if (_common_area.bookable == '1') { + _common_area.bookable_text = 'Necesaria'; + } else { + _common_area.bookable_text = 'No es necesaria'; + } + if (_common_area.status == '1') { + _common_area.status_text = 'Activo'; + } else if (_common_area.status == '0') { + _common_area.status_text = 'Inactivo'; + } else { + _common_area.status_text = 'Eliminado'; + } + } _common_areas.push(_common_area); + toast.current.show({ severity: 'success', summary: 'Registro exitoso', detail: 'Área Común Creada', life: 3000, }); - setCommonAreaList(_common_areas); 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 { setSubmitted(true); }