From 72ea9d203304cb64e0ef8ff81b97c6d0b4efad5a Mon Sep 17 00:00:00 2001 From: Mariela Date: Sat, 23 Jul 2022 23:54:05 -0600 Subject: [PATCH 1/7] obtener inquilinos api --- api-gateway/src/app.controller.ts | 6 ++++++ api-gateway/src/app.service.ts | 11 +++++++++++ servicio-usuarios/src/users/users.controller.ts | 12 ++++++++++++ servicio-usuarios/src/users/users.service.ts | 11 +++++++++++ 4 files changed, 40 insertions(+) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index 2d02bfe4..205c4339 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -77,6 +77,7 @@ export class AppController { allUsersAdminComunidad() { return this.appService.allUsersAdminComunidad(); } + @Get('user/findGuards/:community') findGuardsCommunity( @Param('community_id') community_id: string @@ -84,6 +85,11 @@ export class AppController { return this.appService.findGuardsCommunity(community_id); } + @Get('user/findTenants') + allUsersTenants() { + return this.appService.allUsersTenants(); + } + @Get('user/find/:dni') findUser( @Param('dni') paramUserDNI: string diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 65ebd4f8..541d7907 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -95,6 +95,17 @@ export class AppService { ); } + allUsersTenants() { + const pattern = { cmd: 'findTenants' }; + const payload = {}; + return this.clientUserApp + .send(pattern, payload) + .pipe( + map((message: string) => ({ message })), + ); + } + + //GET parameter from API findUser(paramUserDNI: string) { const pattern = { cmd: 'findUserDNI' }; diff --git a/servicio-usuarios/src/users/users.controller.ts b/servicio-usuarios/src/users/users.controller.ts index ea3c70a9..03fb4fcd 100644 --- a/servicio-usuarios/src/users/users.controller.ts +++ b/servicio-usuarios/src/users/users.controller.ts @@ -41,6 +41,18 @@ export class UsersController { } + @MessagePattern({ cmd: 'findTenantsCommunity' }) + findTenantsCommunity(@Payload() community_id: string) { + let pcommunity_id = community_id['community_id']; + return this.userService.findTenantsCommunity(pcommunity_id); + } + + @MessagePattern({ cmd: 'findTenants' }) + findTenants() { + return this.userService.findTenants(); + } + + @MessagePattern({ cmd: 'updateUser' }) update(@Payload() user: UserDocument) { return this.userService.update(user.id, user); diff --git a/servicio-usuarios/src/users/users.service.ts b/servicio-usuarios/src/users/users.service.ts index edaf2ed0..e282108c 100644 --- a/servicio-usuarios/src/users/users.service.ts +++ b/servicio-usuarios/src/users/users.service.ts @@ -87,6 +87,17 @@ export class UsersService { return this.userModel.find({ user_type: 2 }).exec(); } + + //find inquilinos + async findTenants(): Promise { + return this.userModel.find({ user_type: 3 }).exec(); + } + + + //find inquilinos + async findTenantsCommunity(pcommunity_id: string): Promise { + return this.userModel.find({ community_id: pcommunity_id, user_type: 4 }).exec(); + } async testSendMail(user: UserDocument) { let passwordEncriptada = Md5.init(user.password); From 305a343936dddfdc7af6cd86b2b584ad3bc744c6 Mon Sep 17 00:00:00 2001 From: Mariela Date: Sat, 23 Jul 2022 23:54:26 -0600 Subject: [PATCH 2/7] set list inquilinos --- web-ui/web-react/src/components/Inquilinos.js | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/web-ui/web-react/src/components/Inquilinos.js b/web-ui/web-react/src/components/Inquilinos.js index 608a0a6b..661af956 100644 --- a/web-ui/web-react/src/components/Inquilinos.js +++ b/web-ui/web-react/src/components/Inquilinos.js @@ -1,10 +1,40 @@ import { Button } from 'primereact/button'; import { Dropdown } from 'primereact/dropdown'; import { InputText } from 'primereact/inputtext' -import React, { useEffect, useState } from 'react' +import React, { useEffect, useState, useRef } from 'react' +import { DataTable } from 'primereact/datatable'; +import { Column } from 'primereact/column'; +import { Dropdown } from 'primereact/dropdown'; +import { Toast } from 'primereact/toast'; +import classNames from 'classnames'; const Inquilinos = () => { const [communitiesList, setCommunitiesList] = useState([]); + const [tenants, setTenants] = useState([]); + + const [tenant, setTenant] = useState(emptyTenant); + + let emptyTenant = { + _id: null, + dni: '', + name: '', + last_name: '', + email: '', + phone: '', + password: '', + user_type: '1', + community_id: '', + community_name: '', + number_house: '', + status: '' + }; + + + async function getTenants() { + + } + + const communityIdList = communitiesList.map(community => community.id); async function getCommunites() { let response = await fetch('http://localhost:4000/community/allCommunities', { method: 'GET' }); @@ -53,7 +83,7 @@ const Inquilinos = () => { -