From 8ed2a70eeee289a0c21f832a3b8155ba8d6ee223 Mon Sep 17 00:00:00 2001 From: Traym17 <51390112+Traym17@users.noreply.github.com> Date: Wed, 24 Aug 2022 22:36:13 -0600 Subject: [PATCH 1/2] Eliminar invitado --- api-gateway/src/app.controller.ts | 6 ++- api-gateway/src/app.service.ts | 14 ++++- mobile-ui/App.js | 2 +- mobile-ui/components/AgregarInvitados.js | 1 + mobile-ui/components/Invitados.js | 51 +++++++++++++++---- .../src/guests/guests.controller.ts | 2 +- .../src/guests/guests.service.ts | 3 +- 7 files changed, 65 insertions(+), 14 deletions(-) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index e53d3fb4..821808d9 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -431,7 +431,11 @@ export class AppController { findGuestUser(@Param('id') paramGuestId: string) { return this.appService.findGuestUser(paramGuestId); } - + @Post('guest/updateGuest') + updateGuest( + @Body('_id') _id: string){ + return this.appService.updateGuest(_id); + } // #==== API Payment diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 7aa40f38..c9b1aa6a 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -322,6 +322,7 @@ export class AppService { .pipe(map((message: string) => ({ message }))); } + //GET parameter from API findCommunityAdmin(community_id: string) { const pattern = { cmd: 'findCommunityAdmin' }; @@ -541,11 +542,22 @@ export class AppService { //GET parameter from API findGuestUser(paramGuestId: string) { const pattern = { cmd: 'findGuestUser' }; - const payload = { di: paramGuestId }; + const payload = { id: paramGuestId }; return this.clientGuestApp .send(pattern, payload) .pipe(map((message: string) => ({ message }))); } + + updateGuest(_id: string + ) { + const pattern = { cmd: 'removeGuest' }; + const payload = { + _id: _id + }; + return this.clientGuestApp + .send(pattern, payload) + .pipe(map((message: string) => ({ message }))) + } // ====================== PAYMENTS =============================== //POST parameter from API diff --git a/mobile-ui/App.js b/mobile-ui/App.js index f7b25e24..08c2a79d 100644 --- a/mobile-ui/App.js +++ b/mobile-ui/App.js @@ -72,7 +72,7 @@ export default function App() { - { @@ -42,6 +45,34 @@ export default function Invitados({navigation}) { }) + const deleteInvitado = async(pid) => { + const data = { + "_id": pid + } + + try { + + await fetch("http://localhost:4000/guest/updateGuest", { + + cache: 'no-cache', + method: 'POST', + body: JSON.stringify(data), + headers: { + 'Content-Type': 'application/json' + } + }) + .then(response => { + if (response.status != 201){ + console.log('ocurrio un error '); + }else{ + return response.json(); + } + }) + + } catch (error) { + console.log("ERROR: " + error); + } + } return ( @@ -67,20 +98,22 @@ export default function Invitados({navigation}) { - {item.dni} + {"Identificación: "+item.dni} - (506) {item.phone} + {"Teléfono: "+item.phone} + + {"Número Placa: "+item.number_plate} + + - - {item.number_plate} - + {deleteInvitado(item._id)}} /> } keyExtractor={item => item.id} /> diff --git a/servicio-invitados/src/guests/guests.controller.ts b/servicio-invitados/src/guests/guests.controller.ts index 17ba36b4..3e306f6e 100644 --- a/servicio-invitados/src/guests/guests.controller.ts +++ b/servicio-invitados/src/guests/guests.controller.ts @@ -39,7 +39,7 @@ export class GuestsController { @MessagePattern({ cmd: 'removeGuest' }) remove(@Payload() id: string) { - let dni = id['dni']; + let dni = id['_id']; return this.guestsService.remove(dni); } } diff --git a/servicio-invitados/src/guests/guests.service.ts b/servicio-invitados/src/guests/guests.service.ts index fcd898df..e0ea9807 100644 --- a/servicio-invitados/src/guests/guests.service.ts +++ b/servicio-invitados/src/guests/guests.service.ts @@ -18,7 +18,8 @@ export class GuestsService { } async findGuestUser(id: string): Promise { - return this.guestModel.find({_tenant_id:id}).setOptions({ sanitizeFilter: true }).exec(); + console.log(id); + return this.guestModel.find({_tenant_id:id, status:"-0"}).setOptions({ sanitizeFilter: true }).exec(); } findOneId(id: string): Promise { From da98c3ab2621e7bbd777a2a194bd594e1fcf1ff4 Mon Sep 17 00:00:00 2001 From: Traym17 <51390112+Traym17@users.noreply.github.com> Date: Wed, 24 Aug 2022 22:36:55 -0600 Subject: [PATCH 2/2] Correcciones --- mobile-ui/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile-ui/App.js b/mobile-ui/App.js index 08c2a79d..f7b25e24 100644 --- a/mobile-ui/App.js +++ b/mobile-ui/App.js @@ -72,7 +72,7 @@ export default function App() { -