From 72a2c29c1fa3a37230615e29e771d48c244a823a Mon Sep 17 00:00:00 2001 From: Traym17 <51390112+Traym17@users.noreply.github.com> Date: Mon, 22 Aug 2022 22:44:55 -0600 Subject: [PATCH] Listar de invitados Inquilino MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modificación tanto del frontend y backend --- api-gateway/src/app.controller.ts | 10 ++ api-gateway/src/app.service.ts | 13 +- mobile-ui/components/Invitados.js | 115 ++++++++++++++++-- mobile-ui/package.json | 1 + .../src/guests/guests.controller.ts | 5 +- .../src/guests/guests.service.ts | 4 + 6 files changed, 135 insertions(+), 13 deletions(-) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index 5ebc741f..8b89f3ce 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -319,6 +319,8 @@ export class AppController { @Body('number_plate') number_plate: string, @Body('phone') phone: number, @Body('status') status: string, + @Body('tenant_id') tenant_id: string, + @Body('community_id') community_id: string, @Body('date_entry') date_entry: Date, ) { return this.appService.createGuest( @@ -328,6 +330,8 @@ export class AppController { number_plate, phone, status, + tenant_id, + community_id, date_entry, ); } @@ -342,6 +346,12 @@ export class AppController { return this.appService.findGuest(paramGuestDNI); } + @Get('guest/findGuestUser/:id') + findGuestUser(@Param('id') paramGuestId: string) { + return this.appService.findGuestUser(paramGuestId); + } + + // #==== API Payment @Post('payment/createPayment') diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 9307433c..66b9d89c 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -416,12 +416,14 @@ export class AppService { number_plate: string, phone: number, status: string, + tenant_id: string, + community_id: string, date_entry: Date, ) { const pattern = { cmd: 'createGuest' }; const payload = { name: name, last_name: last_name, dni: dni, number_plate: number_plate, phone: phone, - status: status, date_entry: date_entry + status: status,tenant_id:tenant_id, community_id:community_id,date_entry: date_entry }; return this.clientGuestApp .send(pattern, payload) @@ -444,7 +446,14 @@ export class AppService { .send(pattern, payload) .pipe(map((message: string) => ({ message }))); } - + //GET parameter from API + findGuestUser(paramGuestId: string) { + const pattern = { cmd: 'findGuestUser' }; + const payload = { di: paramGuestId }; + return this.clientGuestApp + .send(pattern, payload) + .pipe(map((message: string) => ({ message }))); + } // ====================== PAYMENTS =============================== //POST parameter from API diff --git a/mobile-ui/components/Invitados.js b/mobile-ui/components/Invitados.js index e8834337..0d69bd31 100644 --- a/mobile-ui/components/Invitados.js +++ b/mobile-ui/components/Invitados.js @@ -1,20 +1,115 @@ -import React from "react"; - +import React, { useContext, useEffect, useState } from "react"; +import { MaterialCommunityIcons } from '@expo/vector-icons'; +import { UserContext } from "../context/UserContext"; +import { API } from "../environment/api"; import { - - Center, - + Box, Button, + Center, FormControl, Heading, ScrollView, VStack,FlatList, HStack,Avatar,Spacer,Text } from "native-base"; - export default function Invitados({navigation}) { + const [isRequesting, setIsRequesting] = useState(false); + const [invitados, setInvitados] = useState([]); + const id = "62ff074949eb1e993a9d0fda"; + + + useEffect(() => { + + const onRequestCommentsData = async () => { + setIsRequesting(true); + + try { + const jsonResponse = await fetch(`${API.BASE_URL}/guest/findGuestUser/`+`${id}`, { + method: "GET", + headers: { + 'Content-Type': 'application/json' + } + }) + + const response = await jsonResponse.json(); + console.log(response); + setInvitados(response.message); + + } catch (error) { + + } + + setIsRequesting(false) + } + + onRequestCommentsData() + + }) + + + + + const data = [{ + id: "bd7acbea-c1b1-46c2-aed5-3ad53abb28ba", + fullName: "Aafreen Khan", + timeStamp: "12:47 PM", + recentText: "Good Day!" + }, { + id: "3ac68afc-c605-48d3-a4f8-fbd91aa97f63", + fullName: "Sujitha Mathur", + timeStamp: "11:11 PM", + recentText: "Cheer up, there!" + }, { + id: "58694a0f-3da1-471f-bd96-145571e29d72", + fullName: "Anci Barroco", + timeStamp: "6:22 PM", + recentText: "Good Day!" + }, { + id: "68694a0f-3da1-431f-bd56-142371e29d72", + fullName: "Aniket Kumar", + timeStamp: "8:56 PM", + recentText: "All the best" + }, { + id: "28694a0f-3da1-471f-bd96-142456e29d72", + fullName: "Kiara", + timeStamp: "12:47 PM", + recentText: "I will call today." + }]; return ( - -
- + + + Lista de invitados + + + + + + + {item.name+" "+item.last_name} + + + {item.dni} + + + {item.phone} + + + + + {item.number_plate} + + + } keyExtractor={item => item.id} /> + -
); diff --git a/mobile-ui/package.json b/mobile-ui/package.json index b10c1e3c..639e5cb5 100644 --- a/mobile-ui/package.json +++ b/mobile-ui/package.json @@ -35,6 +35,7 @@ "react-native-safe-area-context": "3.3.2", "react-native-screens": "~3.10.1", "react-native-svg": "12.1.1", + "react-native-table-component": "^1.2.2", "react-native-web": "0.17.1", "universal-cookie": "^4.0.4" }, diff --git a/servicio-invitados/src/guests/guests.controller.ts b/servicio-invitados/src/guests/guests.controller.ts index c9b67ad2..17ba36b4 100644 --- a/servicio-invitados/src/guests/guests.controller.ts +++ b/servicio-invitados/src/guests/guests.controller.ts @@ -16,7 +16,10 @@ export class GuestsController { findAll() { return this.guestsService.findAll(); } - + @MessagePattern({ cmd: 'findGuestUser' }) + findGuestUser(@Payload() id: string) { + return this.guestsService.findGuestUser(id); + } @MessagePattern({ cmd: 'findOneGuest' }) findOneById(@Payload() id: string) { let _id = id['_id']; diff --git a/servicio-invitados/src/guests/guests.service.ts b/servicio-invitados/src/guests/guests.service.ts index 02379936..fcd898df 100644 --- a/servicio-invitados/src/guests/guests.service.ts +++ b/servicio-invitados/src/guests/guests.service.ts @@ -17,6 +17,10 @@ export class GuestsService { return this.guestModel.find().setOptions({ sanitizeFilter: true }).exec(); } + async findGuestUser(id: string): Promise { + return this.guestModel.find({_tenant_id:id}).setOptions({ sanitizeFilter: true }).exec(); + } + findOneId(id: string): Promise { return this.guestModel.findOne({ _id: id }).exec(); }