From a77782acaa834dd3c036a017a361a1458d68df5c Mon Sep 17 00:00:00 2001 From: Mariela Date: Thu, 21 Jul 2022 04:51:47 -0600 Subject: [PATCH] fixes textos --- .../public/assets/demo/data/distritos.json | 12 ++-- .../src/components/ComunidadViviendas.js | 58 ++++++++++--------- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/web-ui/web-react/public/assets/demo/data/distritos.json b/web-ui/web-react/public/assets/demo/data/distritos.json index f82239a0..584e14bd 100644 --- a/web-ui/web-react/public/assets/demo/data/distritos.json +++ b/web-ui/web-react/public/assets/demo/data/distritos.json @@ -55,7 +55,7 @@ "parentCode": "101" }, { - "name": "Escazú", + "name": "Escazú", "code": "10201", "parentCode": "102" }, @@ -355,7 +355,7 @@ "parentCode": "111" }, { - "name": "Dulce Name de Jesús", + "name": "Dulce Name de Jesús", "code": "11103", "parentCode": "111" }, @@ -555,7 +555,7 @@ "parentCode": "119" }, { - "name": "Barú", + "name": "Barú", "code": "11909", "parentCode": "119" }, @@ -785,7 +785,7 @@ "parentCode": "204" }, { - "name": "Jesús María", + "name": "Jesús María", "code": "20403", "parentCode": "204" }, @@ -795,7 +795,7 @@ "parentCode": "205" }, { - "name": "Jesús", + "name": "Jesús", "code": "20502", "parentCode": "205" }, @@ -1510,7 +1510,7 @@ "parentCode": "404" }, { - "name": "Jesús", + "name": "Jesús", "code": "40404", "parentCode": "404" }, diff --git a/web-ui/web-react/src/components/ComunidadViviendas.js b/web-ui/web-react/src/components/ComunidadViviendas.js index b436bbbf..3eaaa4a2 100644 --- a/web-ui/web-react/src/components/ComunidadViviendas.js +++ b/web-ui/web-react/src/components/ComunidadViviendas.js @@ -105,10 +105,10 @@ const Communities = () => { async function fillDistricts() { const resJson = await getDistricts(); - const cantones = await resJson.filter(function (i, n) { - return i.parentCode === provinciaId; + const districts = await resJson.filter(function (i, n) { + return i.parentCode === cantonId; }); - setCantonsList(await cantones); + setDistrictsList(await districts); } const handleProvinces = (event) => { @@ -149,6 +149,7 @@ const Communities = () => { const saveCommunity = () => { setSubmitted(true); + if (community.name.trim()) { let _communities = [...communitiesList]; let _community = { ...community }; @@ -164,20 +165,6 @@ const Communities = () => { description: "es esta descripcion", }) } - - - _communities.push(_community); - toast.current.show({ severity: 'success', summary: 'Successful', detail: 'Community Created', life: 3000 }); - - setCommunitiesList(_communities); - - setProvinciaId(''); - setCantonId(''); - setDistrictId(''); - setCommunity(emptyCommunity); - - - // console.log(houses) fetch('http://localhost:4000/community/createCommunity', { cache: 'no-cache', @@ -195,9 +182,28 @@ const Communities = () => { 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 + + _communities.push(_community); + toast.current.show({ severity: 'success', summary: 'Registro exitoso', detail: 'Comunidad de vivienda Creada', life: 3000 }); + + setCommunitiesList(_communities); + + + setProvinciaId(''); + setCantonId(''); + setDistrictId(''); + setCommunity(emptyCommunity); + }) .catch( err => console.log('Ocurrió un error con el fetch', err) ); + + } } @@ -241,9 +247,9 @@ const Communities = () => { - onInputChange(e, 'name')} required autoFocus className={classNames({ 'p-invalid': submitted && !community.name } )} /> + onInputChange(e, 'name')} required autoFocus className={classNames({ 'p-invalid': submitted && community.name==='' } )} /> - {submitted && community.name==='' && Nombre es requirido.} + {submitted && community.name==='' && Nombre es requirido.}
@@ -253,9 +259,9 @@ const Communities = () => { - +
- {submitted && !community.province && Provincia es requirido.} + {submitted && (!community.province || community.province === '') && Provincia es requirido.}
@@ -267,7 +273,7 @@ const Communities = () => {
- {submitted && !community.canton && Cantón es requirido.} + {submitted && !community.canton && Cantón es requirido.}
@@ -279,7 +285,7 @@ const Communities = () => {
- {submitted && !community.district && Distrito es requirido.} + {submitted && !community.district && Distrito es requirido.}
@@ -289,9 +295,9 @@ const Communities = () => { - onInputChange(e, 'phone')} required autoFocus className={classNames({ 'p-invalid': submitted && !community.phone } )} /> + onInputChange(e, 'phone')} required autoFocus className={classNames({ 'p-invalid': submitted && community.phone==='' } )} />
- {submitted && community.phone==='' && Número de teléfono es requirido.} + {submitted && community.phone==='' && Número de teléfono es requirido.}
@@ -303,7 +309,7 @@ const Communities = () => { onInputChange(e, 'num_houses')} required autoFocus className={classNames({ 'p-invalid': submitted && community.num_houses < 1 } )} />
- {submitted && community.num_houses < 1 && Número de viviendas es requirido y debe ser mayor que 0.} + {submitted && community.num_houses < 1 && Número de viviendas es requirido y debe ser mayor que 0.}