From 162b838e751145219e1657a5cf0e65b711eb89ef Mon Sep 17 00:00:00 2001 From: Mariela Date: Mon, 1 Aug 2022 23:09:43 -0600 Subject: [PATCH] fix listar nombre de los inquilinos de cada vivienda --- .../src/components/ComunidadViviendas.js | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/web-ui/web-react/src/components/ComunidadViviendas.js b/web-ui/web-react/src/components/ComunidadViviendas.js index b29d4196..db3da58b 100644 --- a/web-ui/web-react/src/components/ComunidadViviendas.js +++ b/web-ui/web-react/src/components/ComunidadViviendas.js @@ -176,14 +176,18 @@ const Communities = () => { getCommunites(); }, []); - /*async function tenantsList(id) { + async function tenantsList(id) { await fetch(`http://localhost:4000/user/findTenants/${id}`, { method: 'GET' }) .then((response) => response.json()) .then(data => data.message) .then(data => { setTenants(data) }); - }*/ + } + + useEffect(() => { + tenantsList(community._id); + }, []) const saveCommunity = () => { @@ -300,7 +304,7 @@ const Communities = () => { const infoCommunity = async (community) => { - //await tenantsList(community._id); + await tenantsList(community._id); setCommunity({ ...community }); setCommunityDialog(true); @@ -569,16 +573,22 @@ const Communities = () => {

{' '} {' '} -

Inquilinos +

+ ); const tenantsBodyTemplate = (rowData) => { - /*let tenants = rowData.tenants; + let tenants = rowData.tenants; let name = findNameTenant(tenants.tenant_id); - console.log(name)*/ + console.log(name); + return ( + <> + {name} + + ) }; return ( @@ -652,9 +662,13 @@ const Communities = () => { - + @@ -761,7 +775,7 @@ const Communities = () => { rowsPerPageOptions={[5, 10, 25]} className="datatable-responsive mt-3" paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown" - currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords} comunidades de viviendas" + currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords} viviendas" globalFilter={globalFilter} >