listar comunidades de vivienda

This commit is contained in:
Mariela 2022-07-18 22:33:30 -06:00
parent d4be2ae969
commit 17604ace92
5 changed files with 57 additions and 6 deletions

View File

@ -1,9 +1,13 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
const cors= require('cors'); const cors = require('cors');
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
app.enableCors({
origin: 'http://localhost:3000',
methods: 'GET, PUT, POST, DELETE',
allowedHeaders: 'Content-Type, Authorization',
});
await app.listen(4000); await app.listen(4000);
app.use(cors());
} }
bootstrap(); bootstrap();

View File

@ -7,10 +7,10 @@ import { Tenant, TenantSchema } from './tenant.schema';
@Schema() @Schema()
export class House extends Document { export class House extends Document {
@Prop({ default: " " }) @Prop({ default: " " })
number: string; number_house: string;
@Prop({ default: " " }) @Prop({ default: "desocupada" })
description: string; state: string;
@Prop({ type: TenantSchema, default: " " }) @Prop({ type: TenantSchema, default: " " })
tenants: Tenant; tenants: Tenant;

View File

@ -30,6 +30,7 @@ import BlocksDemo from './templates/BlocksDemo';
import IconsDemo from './templates/IconsDemo'; import IconsDemo from './templates/IconsDemo';
import AdministradoresSistema from './components/AdministradoresSistema'; import AdministradoresSistema from './components/AdministradoresSistema';
import AdministradoresComunidad from './components/AdministradoresComunidad'; import AdministradoresComunidad from './components/AdministradoresComunidad';
import Communities from './components/ComunidadViviendas';
import Crud from './pages/Crud'; import Crud from './pages/Crud';
import EmptyPage from './pages/EmptyPage'; import EmptyPage from './pages/EmptyPage';
@ -165,6 +166,7 @@ const App = () => {
{label: 'Dashboard', icon: 'pi pi-fw pi-home', to: '/'}, {label: 'Dashboard', icon: 'pi pi-fw pi-home', to: '/'},
{label: 'Administradores del sistema', icon: 'pi pi-fw pi-id-card', to: '/administradoresSistema'}, {label: 'Administradores del sistema', icon: 'pi pi-fw pi-id-card', to: '/administradoresSistema'},
{label: 'Administradores de comunidad', icon: 'pi pi-fw pi-id-card', to: '/administradoresComunidad'}, {label: 'Administradores de comunidad', icon: 'pi pi-fw pi-id-card', to: '/administradoresComunidad'},
{label: 'Comunidadades', icon: 'pi pi-fw pi-id-card', to: '/comunidadesViviendas'},
{label: 'Log in', icon: 'pi pi-fw pi-id-card', to: '/logIn'} {label: 'Log in', icon: 'pi pi-fw pi-id-card', to: '/logIn'}
] ]
}, },
@ -320,6 +322,7 @@ const App = () => {
<Route path="/documentation" component={Documentation} /> <Route path="/documentation" component={Documentation} />
<Route path="/administradoresSistema" component={AdministradoresSistema} /> <Route path="/administradoresSistema" component={AdministradoresSistema} />
<Route path="/administradoresComunidad" component={AdministradoresComunidad} /> <Route path="/administradoresComunidad" component={AdministradoresComunidad} />
<Route path="/comunidadesViviendas" component={Communities} />
<Route path="/logIn" component={LogIn} /> <Route path="/logIn" component={LogIn} />
</div> </div>

View File

@ -0,0 +1,44 @@
import React, { useEffect, useState } from 'react';
import { InputText } from 'primereact/inputtext';
import { Button } from 'primereact/button';
import { DataTable } from 'primereact/datatable';
import { Column } from 'primereact/column';
const Communities = () => {
const [communitiesList, setCommunitiesList] = useState([]);
const [housesList, setHousesList] = useState([]);
async function getCommunites() {
let response = await fetch('http://localhost:4000/community/allCommunities', { method: 'GET' });
let list = await response.json();
setCommunitiesList(list.message);
}
useEffect(() => {
getCommunites();
}, [])
return (
<div className="grid">
<div className="col-12">
<div className="card">
<h5>Administradores de comunidad</h5>
<DataTable value={communitiesList} scrollable scrollHeight="400px" scrollDirection="both" className="mt-3">
<Column field="name" header="Nombre" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
<Column field="last_name" header="Provincia" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
<Column field="dni" header="Cantón" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
<Column field="email" header="Distrito" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
<Column field="phone" header="Telefóno" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
</DataTable>
</div>
</div>
</div>
)
}
export default React.memo(Communities);