From 30e559daaf3425d76abd5e89497e086be33d5483 Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 30 Aug 2022 23:11:34 -0600 Subject: [PATCH] actualizar area comun completo --- api-gateway/src/app.controller.ts | 17 ++++++++++++++ api-gateway/src/app.service.ts | 22 ++++++++++++++++++- .../src/common_areas/common_areas.service.ts | 1 + .../web-react/src/components/AreasComunes.js | 2 +- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index 56c1252c..dbcd8b85 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -425,6 +425,23 @@ export class AppController { return this.appService.changeStatusCommonArea(pId, pStatus); } + @Post('commonArea/updateCommonArea') + updateCommonArea( + @Body('_id') id: string, + @Body('name') name: string, + @Body('hourMin') hourMin: string, + @Body('hourMax') hourMax: string, + @Body('bookable') bookable: number, + @Body('community_id') community_id: string, + ) { + return this.appService.updateCommonArea( + id, + name, + hourMin, + hourMax, + bookable, + community_id,); + } // #==== API GUEST //#API userService - create user @Post('guest/createGuest') diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 7677f6ba..56eb67e6 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -522,7 +522,27 @@ export class AppService { .pipe(map((message: string) => ({ message }))); } - + updateCommonArea( + id: string, + name: string, + hourMin: string, + hourMax: string, + bookable: number, + community_id: string, + ) { + const pattern = { cmd: 'updateCommonArea' }; + const payload = { + id: id, + name: name, + hourMin: hourMin, + hourMax: hourMax, + bookable: bookable, + community_id: community_id, + }; + return this.clientCommonAreaApp + .send(pattern, payload) + .pipe(map((message: string) => ({ message }))); + } // ====================== GUESTS =============================== //POST parameter from API diff --git a/servicio-areas-comunes/src/common_areas/common_areas.service.ts b/servicio-areas-comunes/src/common_areas/common_areas.service.ts index 877bd011..b25a9d5f 100644 --- a/servicio-areas-comunes/src/common_areas/common_areas.service.ts +++ b/servicio-areas-comunes/src/common_areas/common_areas.service.ts @@ -26,6 +26,7 @@ export class CommonAreasService { } update(id: string, commonArea: CommonAreaDocument) { + console.log(commonArea); return this.commonAreaModel.findOneAndUpdate({ _id: id }, commonArea, { new: true, }); diff --git a/web-ui/web-react/src/components/AreasComunes.js b/web-ui/web-react/src/components/AreasComunes.js index 6da1739d..b8c2b0f9 100644 --- a/web-ui/web-react/src/components/AreasComunes.js +++ b/web-ui/web-react/src/components/AreasComunes.js @@ -166,7 +166,7 @@ const AreasComunes = () => { }, }) .then(function (response) { - if (response.status != 201) + if (response.status != 201 && response.status != 200) console.log('OcurriĆ³ un error con el servicio: ' + response.status); else return response.json(); })