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/components/AgregarInvitados.js b/mobile-ui/components/AgregarInvitados.js index 5e4a942f..9a8c354e 100644 --- a/mobile-ui/components/AgregarInvitados.js +++ b/mobile-ui/components/AgregarInvitados.js @@ -29,6 +29,7 @@ export default function AgregarInvitados({ navigation }) { "dni": dni, "phone": phone, "number_plate": number_plate, + "status":"-0", "tenant_id": user.id, "community_id": user.community_id } diff --git a/mobile-ui/components/Invitados.js b/mobile-ui/components/Invitados.js index a839800c..b5309f78 100644 --- a/mobile-ui/components/Invitados.js +++ b/mobile-ui/components/Invitados.js @@ -8,11 +8,14 @@ import { } from "native-base"; export default function Invitados({navigation}) { + + const [isRequesting, setIsRequesting] = useState(false); const [invitados, setInvitados] = useState([]); const { user } = useContext(UserContext); - const id = user._id; - + //const id = user._id; + const id = "62ff074949eb1e993a9d0fda"; + const [invitado, setInvitado] = useState([]); useEffect(() => { @@ -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 {