From 17604ace92363616e0f8e17fd0a545f5b755a0bb Mon Sep 17 00:00:00 2001 From: Mariela Date: Mon, 18 Jul 2022 22:33:30 -0600 Subject: [PATCH] listar comunidades de vivienda --- api-gateway/src/main.ts | 8 +++- .../src/schemas/house.schema.ts | 6 +-- servicio-usuarios/src/users/users.service.ts | 2 +- web-ui/web-react/src/App.js | 3 ++ .../src/components/ComunidadViviendas.js | 44 +++++++++++++++++++ 5 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 web-ui/web-react/src/components/ComunidadViviendas.js diff --git a/api-gateway/src/main.ts b/api-gateway/src/main.ts index 3bea0f30..ead48887 100644 --- a/api-gateway/src/main.ts +++ b/api-gateway/src/main.ts @@ -1,9 +1,13 @@ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; -const cors= require('cors'); +const cors = require('cors'); async function bootstrap() { 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); - app.use(cors()); } bootstrap(); diff --git a/servicio-comunidad-viviendas/src/schemas/house.schema.ts b/servicio-comunidad-viviendas/src/schemas/house.schema.ts index 0ee35e1d..f8687b54 100644 --- a/servicio-comunidad-viviendas/src/schemas/house.schema.ts +++ b/servicio-comunidad-viviendas/src/schemas/house.schema.ts @@ -7,10 +7,10 @@ import { Tenant, TenantSchema } from './tenant.schema'; @Schema() export class House extends Document { @Prop({ default: " " }) - number: string; + number_house: string; - @Prop({ default: " " }) - description: string; + @Prop({ default: "desocupada" }) + state: string; @Prop({ type: TenantSchema, default: " " }) tenants: Tenant; diff --git a/servicio-usuarios/src/users/users.service.ts b/servicio-usuarios/src/users/users.service.ts index 63438e01..5e506697 100644 --- a/servicio-usuarios/src/users/users.service.ts +++ b/servicio-usuarios/src/users/users.service.ts @@ -16,7 +16,7 @@ export class UsersService { @Inject('SERVICIO_NOTIFICACIONES') private readonly clientNotificationtApp: ClientProxy, ) { } - private publicKey: string; + private publicKey: string; async create(user: UserDocument): Promise { let passwordEncriptada = Md5.init(user.password); user.password = passwordEncriptada; diff --git a/web-ui/web-react/src/App.js b/web-ui/web-react/src/App.js index 83530986..a98659e9 100644 --- a/web-ui/web-react/src/App.js +++ b/web-ui/web-react/src/App.js @@ -30,6 +30,7 @@ import BlocksDemo from './templates/BlocksDemo'; import IconsDemo from './templates/IconsDemo'; import AdministradoresSistema from './components/AdministradoresSistema'; import AdministradoresComunidad from './components/AdministradoresComunidad'; +import Communities from './components/ComunidadViviendas'; import Crud from './pages/Crud'; import EmptyPage from './pages/EmptyPage'; @@ -165,6 +166,7 @@ const App = () => { {label: 'Dashboard', icon: 'pi pi-fw pi-home', to: '/'}, {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: 'Comunidadades', icon: 'pi pi-fw pi-id-card', to: '/comunidadesViviendas'}, {label: 'Log in', icon: 'pi pi-fw pi-id-card', to: '/logIn'} ] }, @@ -320,6 +322,7 @@ const App = () => { + diff --git a/web-ui/web-react/src/components/ComunidadViviendas.js b/web-ui/web-react/src/components/ComunidadViviendas.js new file mode 100644 index 00000000..c088d151 --- /dev/null +++ b/web-ui/web-react/src/components/ComunidadViviendas.js @@ -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 ( +
+
+
+
Administradores de comunidad
+ + + + + + + +
+
+
+ + +) +} + +export default React.memo(Communities); \ No newline at end of file