From b704597d54ccc1f054572e8f77cc2e782417a17c Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Thu, 1 Sep 2022 16:02:50 -0600 Subject: [PATCH] fix communities UI --- .../src/components/ComunidadViviendas.js | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/web-ui/web-react/src/components/ComunidadViviendas.js b/web-ui/web-react/src/components/ComunidadViviendas.js index 94b70bdd..4311dbe7 100644 --- a/web-ui/web-react/src/components/ComunidadViviendas.js +++ b/web-ui/web-react/src/components/ComunidadViviendas.js @@ -257,6 +257,7 @@ const Communities = () => { }) .catch((err) => console.log('Ocurrió un error con el fetch', err)); } else { + let _communities = [...communitiesList]; let _community = { ...community }; _community.province = provinciaId; _community.canton = cantonId; @@ -275,36 +276,37 @@ const Communities = () => { console.log('Ocurrió un error con el servicio: ' + response.status); else return response.json(); }) - .then(() => { - _community.province = provincesList.find( - (p) => p.code === _community.province, - ).name; - _community.canton = cantonsList.find( - (p) => p.code === _community.canton, - ).name; - _community.district = districtsList.find( - (p) => p.code === _community.district, - ).name; + .then(() => { + _community.province = provincesList.find( + (p) => p.code === _community.province, + ).name; + _community.canton = cantonsList.find( + (p) => p.code === _community.canton, + ).name; + _community.district = districtsList.find( + (p) => p.code === _community.district, + ).name; - _communities.push(_community); - toast.current.show({ - severity: 'success', - summary: 'Registro exitoso', - detail: 'Comunidad de vivienda Creada', - life: 3000, - }); + _communities.push(_community); + toast.current.show({ + severity: 'success', + summary: 'Registro exitoso', + detail: 'Comunidad de vivienda Creada', + life: 3000, + }); - setCommunitiesList(_communities); + setCommunitiesList(_communities); - setProvinciaId(''); - setCantonId(''); - setDistrictId(''); - setCodeHouses(''); - setFormCommunityDialog(false); + setProvinciaId(''); + setCantonId(''); + setDistrictId(''); + setCodeHouses(''); + setFormCommunityDialog(false); - setCommunity(emptyCommunity); - }) - .catch((err) => console.log('Ocurrió un error con el fetch', err)); + setCommunity(emptyCommunity); + }) + .catch((err) => console.log('Ocurrió un error con el fetch', err)); + } } else { setSubmitted(true); } @@ -1271,7 +1273,7 @@ const Communities = () => { )} - +