obtencion de datos correctos

This commit is contained in:
Mariela 2022-08-31 01:09:58 -06:00
parent 6668d70cfb
commit 11ac9b0232
1 changed files with 196 additions and 122 deletions

View File

@ -48,6 +48,36 @@ const PerfilAdminComunidad = () => {
const [globalFilter, setGlobalFilter] = useState(null); const [globalFilter, setGlobalFilter] = useState(null);
//para el perfil de la comunidad //para el perfil de la comunidad
const [tenants, setTenants] = useState([]); 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() { async function getAdmin() {
@ -71,11 +101,16 @@ const PerfilAdminComunidad = () => {
}, []) }, [])
async function getCommunity() { async function getCommunity() {
let pList = await getProvinces();
fetch(`http://localhost:4000/community/findCommunityName/${cookies.community_id}`, { method: 'GET' }) 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((response2) => response2.json())
.then(data => data.message) .then(data => data.message)
.then(data => { .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) setCommunity(data)
}) })
} }
@ -100,6 +135,8 @@ const PerfilAdminComunidad = () => {
tenantsList(community._id); tenantsList(community._id);
}, []) }, [])
function findNameTenant(tenant_id) { function findNameTenant(tenant_id) {
let name = ''; let name = '';
if (tenant_id == '') { if (tenant_id == '') {
@ -147,18 +184,10 @@ const PerfilAdminComunidad = () => {
} }
return ( return (
<div className="grid"> <>
<div className="card"> <div className="grid justify-content-center">
<div className='container text-center'>
<div className="p-fluid formgrid grid">
<div className="field col-12 md:col-12">
<p id='name'>{admin.name}</p>
</div>
</div>
</div>
</div> <div className="col-6" >
{community && (
<div className="card"> <div className="card">
<div className='container text-center'> <div className='container text-center'>
<div className='row my-4'> <div className='row my-4'>
@ -166,6 +195,60 @@ const PerfilAdminComunidad = () => {
<h3>Información Básica</h3> <h3>Información Básica</h3>
</div> </div>
<div className=" col-6 md:col-6"> <div className=" col-6 md:col-6">
<i className="pi pi-home icon-khaki"></i>
<p><strong>Nombre Completo</strong></p>
<div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}>
<div className="p-inputgroup justify-content-evenly">
<p>{admin.name + ' ' + admin.last_name}</p>
</div>
</div>
</div>
<div className=" col-6 md:col-6">
<i className="pi pi-id-card icon-khaki"></i>
<p><strong>Identificación</strong></p>
<div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}>
<div className="p-inputgroup justify-content-evenly">
<p>{admin.dni}</p>
</div>
</div>
</div>
</div>
<div className='row my-4'>
<div className=" col-12 md:col-12">
<h3>Contacto</h3>
</div>
<div className=" col-6 md:col-6">
<i className="pi pi-at icon-khaki"></i>
<p><strong>Correo Electrónico</strong></p>
<div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}>
<div className="p-inputgroup justify-content-evenly">
<p>{admin.email}</p>
</div>
</div>
</div>
<div className=" col-6 md:col-6">
<i className="pi pi-phone icon-khaki"></i>
<p><strong>Número de teléfono</strong></p>
<div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}>
<div className="p-inputgroup justify-content-evenly">
<p>{admin.phone}</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div className='col-6'>
{community && (
<div className="card">
<div className='container text-center'>
<div className='row my-4'>
<div className=" col-12 md:col-12">
<h3>Comunidad Asignada</h3>
</div>
<div className=" col-4 md:col-4">
<i className="pi pi-home icon-khaki"></i> <i className="pi pi-home icon-khaki"></i>
<p><strong>Nombre</strong></p> <p><strong>Nombre</strong></p>
<div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}> <div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}>
@ -174,7 +257,7 @@ const PerfilAdminComunidad = () => {
</div> </div>
</div> </div>
</div> </div>
<div className="col-6 md:col-6"> <div className="col-4 md:col-4">
<i className="pi pi-phone icon-khaki"></i> <i className="pi pi-phone icon-khaki"></i>
<p><strong>Teléfono Administrativo</strong></p> <p><strong>Teléfono Administrativo</strong></p>
@ -185,45 +268,19 @@ const PerfilAdminComunidad = () => {
</div> </div>
</div> </div>
</div>
<div className='row my-5'>
<div className=" col-12 md:col-12">
<h3>Ubicación</h3>
</div>
<div className=" col-4 col-md-4 md:col-4"> <div className=" col-4 col-md-4 md:col-4">
<i className="pi pi-map-marker icon-khaki"></i> <i className="pi pi-map-marker icon-khaki"></i>
<p><strong>Provincia</strong></p> <p><strong>Ubicación</strong></p>
<div className="p-0 col-10 md:col-10"> <div className="p-0 col-10 md:col-10">
<div className="p-inputgroup align-items-center justify-content-evenly"> <div className="p-inputgroup align-items-center justify-content-evenly">
<p>{community.province}</p> <p>{community.province}, {community.canton}, {community.district}</p>
</div>
</div>
</div>
<div className=" col-4 md:col-4">
<i className="pi pi-map-marker icon-khaki"></i>
<p><strong>Cantón</strong></p>
<div className="p-0 col-10 md:col-10">
<div className="p-inputgroup align-items-center justify-content-evenly">
<p>{community.canton}</p>
</div>
</div>
</div>
<div className=" col-4 md:col-4">
<i className="pi pi-map-marker icon-khaki"></i>
<p><strong>Distrito</strong></p>
<div className="p-0 col-10 md:col-10">
<div className="p-inputgroup align-items-center justify-content-evenly">
<p>{community.district}</p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div className='row my-5'> <div className='row my-5'>
<div className=" col-12 md:col-12"> <div className=" col-12 md:col-12">
<h3>Viviendas de la Comunidad</h3> <h3>Viviendas de la Comunidad</h3>
@ -239,11 +296,26 @@ const PerfilAdminComunidad = () => {
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
)}
</div>
</div>
<div className='grid justify-content-center'>
<div className='col-6'>
{community && (
<div className="card">
<div className='container text-center'>
<div className='row my-5'> <div className='row my-5'>
<div className=" col-12 md:col-12"> <div className=" col-12 md:col-12">
<p> <i className="pi pi-home icon-khaki"></i> Viviendas</p> <h3> Viviendas</h3>
<div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}> <div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}>
<div className="p-inputgroup justify-content-evenly"> <div className="p-inputgroup justify-content-evenly">
<DataTable <DataTable
@ -279,6 +351,8 @@ const PerfilAdminComunidad = () => {
</div> </div>
)} )}
</div> </div>
</div>
</>
) )