From 11ac9b02323b7f48619fe890fa018227ffd99f91 Mon Sep 17 00:00:00 2001 From: Mariela Date: Wed, 31 Aug 2022 01:09:58 -0600 Subject: [PATCH] obtencion de datos correctos --- .../src/components/PerfilAdminComunidad.js | 318 +++++++++++------- 1 file changed, 196 insertions(+), 122 deletions(-) diff --git a/web-ui/web-react/src/components/PerfilAdminComunidad.js b/web-ui/web-react/src/components/PerfilAdminComunidad.js index eee0b252..c0a2a3a2 100644 --- a/web-ui/web-react/src/components/PerfilAdminComunidad.js +++ b/web-ui/web-react/src/components/PerfilAdminComunidad.js @@ -48,8 +48,38 @@ const PerfilAdminComunidad = () => { const [globalFilter, setGlobalFilter] = useState(null); //para el perfil de la comunidad const [tenants, setTenants] = useState([]); + const [commonAreaList, setCommonAreaList] = useState([]); + const [provincesList, setProvincesList] = useState([]); + const [cantonsList, setCantonsList] = useState([]); + const [districtsList, setDistrictsList] = useState([]); + async function getProvinces() { + const response = await fetch('assets/demo/data/provincias.json', { + method: 'GET', + }); + return await response.json(); + } + + + async function getCantons() { + const response = await fetch('assets/demo/data/cantones.json', { + method: 'GET', + }); + return await response.json(); + } + + + async function getDistricts() { + const response = await fetch('assets/demo/data/distritos.json', { + method: 'GET', + }); + return await response.json(); + } + + + + async function getAdmin() { await fetch('http://localhost:4000/user/findUserById/' + cookies.id, { method: 'GET' }) .then((response) => response.json()) @@ -71,11 +101,16 @@ const PerfilAdminComunidad = () => { }, []) async function getCommunity() { - - fetch(`http://localhost:4000/community/findCommunityName/${cookies.community_id}`, { method: 'GET' }) + let pList = await getProvinces(); + let cList = await getCantons(); + let dList = await getDistricts(); + await fetch(`http://localhost:4000/community/findCommunityName/${cookies.community_id}`, { method: 'GET' }) .then((response2) => response2.json()) .then(data => data.message) .then(data => { + data.province = pList.find((p) => p.code === data.province).name; + data.canton = cList.find((p) => p.code === data.canton).name; + data.district = dList.find((p) => p.code === data.district).name; setCommunity(data) }) } @@ -100,6 +135,8 @@ const PerfilAdminComunidad = () => { tenantsList(community._id); }, []) + + function findNameTenant(tenant_id) { let name = ''; if (tenant_id == '') { @@ -147,138 +184,175 @@ const PerfilAdminComunidad = () => { } return ( -
-
-
-
-
-

{admin.name}

+ <> +
+ +
+
+
+
+
+

Información Básica

+
+
+ +

Nombre Completo

+
+
+

{admin.name + ' ' + admin.last_name}

+
+
+
+
+ +

Identificación

+
+
+

{admin.dni}

+
+
+
+
+
+
+

Contacto

+
+
+ +

Correo Electrónico

+
+
+

{admin.email}

+
+
+
+
+ +

Número de teléfono

+
+
+

{admin.phone}

+
+
+
+
+
+
+ {community && ( +
+
+
+
+

Comunidad Asignada

+
+
+ +

Nombre

+
+
+

{community.name}

+
+
+
+
+ +

Teléfono Administrativo

+ +
+
+

{community.phone}

+
+ +
+
+
+ + +

Ubicación

+
+
+

{community.province}, {community.canton}, {community.district}

+
+ +
+
+
+ +
+
+

Viviendas de la Comunidad

+
+
+ + +

Cantidad de Viviendas

+
+
+

{community.num_houses}

+
+
+
+
+ +
+
+ )} +
+
- {community && ( -
-
-
-
-

Información Básica

-
-
- -

Nombre

-
-
-

{community.name}

-
-
-
-
- -

Teléfono Administrativo

+
+ +
+ {community && ( +
+
+ +
+
-
-
-

{community.phone}

-
-
-
-
-
-
-

Ubicación

-
-
- - -

Provincia

-
-
-

{community.province}

-
- -
-
-
- - -

Cantón

-
-
-

{community.canton}

-
- -
-
-
- - -

Distrito

-
-
-

{community.district}

-
- -
-
-
-
-
-

Viviendas de la Comunidad

-
-
- - -

Cantidad de Viviendas

-
-
-

{community.num_houses}

+

Viviendas

+
+
+ + + + +
+
-
-
- - -

Viviendas

-
-
- - - - -
-
-
-
-
+ )}
- )} -
+
+ )