From 49cb71e767831e9017c2665212dcd012b364a819 Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 23 Aug 2022 00:32:13 -0600 Subject: [PATCH 01/55] eliminar y eliminar id comunidad de administradores --- api-gateway/src/app.controller.ts | 5 ++ api-gateway/src/app.service.ts | 9 +++ .../src/communities/communities.controller.ts | 30 ++++----- .../src/communities/communities.service.ts | 13 ++++ .../src/users/users.controller.ts | 7 ++ servicio-usuarios/src/users/users.service.ts | 6 ++ .../src/components/ComunidadViviendas.js | 66 +++++++++---------- 7 files changed, 86 insertions(+), 50 deletions(-) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index 3753431b..4def7296 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -323,6 +323,11 @@ export class AppController { ) { return this.appService.saveTenant(community_id, number_house, tenant_id); } + + @Delete('community/deleteCommunity/:id') + deleteCommunity(@Param('id') paramCommunityId: string) { + return this.appService.deleteCommunity(paramCommunityId); + } // #==== API Common Areas @Post('commonArea/createCommonArea') createCommonArea( diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 1e173a1c..fbe5a423 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -407,6 +407,15 @@ export class AppService { .pipe(map((message: string) => ({ message }))); } + deleteCommunity(id: string) { + const pattern = { cmd: 'removeCommunity' }; + const payload = { _id: id }; + return this.clientCommunityApp + .send(pattern, payload) + .pipe(map((message: string) => ({ message }))); + } + + // ====================== COMMON AREAS =============================== //POST parameter from API createCommonArea( diff --git a/servicio-comunidad-viviendas/src/communities/communities.controller.ts b/servicio-comunidad-viviendas/src/communities/communities.controller.ts index a0fa2672..f71e2524 100644 --- a/servicio-comunidad-viviendas/src/communities/communities.controller.ts +++ b/servicio-comunidad-viviendas/src/communities/communities.controller.ts @@ -5,7 +5,7 @@ import { Community, CommunityDocument } from 'src/schemas/community.schema'; @Controller() export class CommunitiesController { - constructor(private readonly communitiesService: CommunitiesService) {} + constructor(private readonly communitiesService: CommunitiesService) { } @MessagePattern({ cmd: 'createCommunity' }) create(@Payload() community: CommunityDocument) { @@ -46,17 +46,17 @@ export class CommunitiesController { return this.communitiesService.remove(_id); } - //cambiar de estado - @MessagePattern({ cmd: 'changeStatus' }) - changeStatus(@Payload() body: string) { - let pid = body['id']; - let pstatus = body['status']; - return this.communitiesService.changeStatus(pid,pstatus); - } + //cambiar de estado + @MessagePattern({ cmd: 'changeStatus' }) + changeStatus(@Payload() body: string) { + let pid = body['id']; + let pstatus = body['status']; + return this.communitiesService.changeStatus(pid, pstatus); + } - @MessagePattern({ cmd: 'saveTenant' }) - saveTenant(@Payload() body: string) { + @MessagePattern({ cmd: 'saveTenant' }) + saveTenant(@Payload() body: string) { let id = body['_id']; let tenant_id = body['tenant_id']; @@ -66,9 +66,9 @@ export class CommunitiesController { @MessagePattern({ cmd: 'deleteTenant' }) deleteTenant(@Payload() body: string) { - let id = body['_id']; - let tenant_id = body['tenant_id']; - let number_house = body['number_house']; - return this.communitiesService.deleteTenant(id, number_house, tenant_id); - } + let id = body['_id']; + let tenant_id = body['tenant_id']; + let number_house = body['number_house']; + return this.communitiesService.deleteTenant(id, number_house, tenant_id); + } } diff --git a/servicio-comunidad-viviendas/src/communities/communities.service.ts b/servicio-comunidad-viviendas/src/communities/communities.service.ts index dc3773e7..93f7cbe2 100644 --- a/servicio-comunidad-viviendas/src/communities/communities.service.ts +++ b/servicio-comunidad-viviendas/src/communities/communities.service.ts @@ -57,6 +57,7 @@ export class CommunitiesService { } async remove(id: string) { + await this.removeIdCommunity(id); return this.communityModel.findOneAndUpdate({ _id: id }, { status: '-1' }, { new: true, }); @@ -119,4 +120,16 @@ export class CommunitiesService { new: true, }); } + + async removeIdCommunity(community: string) { + const pattern = { cmd: 'removeIdCommunity' }; + const payload = { community_id: community}; + + let callback = await this.clientUserApp + .send(pattern, payload) + .pipe(map((response: string) => ({ response }))); + + const finalValue = await lastValueFrom(callback); + return finalValue['response']; + } } diff --git a/servicio-usuarios/src/users/users.controller.ts b/servicio-usuarios/src/users/users.controller.ts index be7deb01..53f32074 100644 --- a/servicio-usuarios/src/users/users.controller.ts +++ b/servicio-usuarios/src/users/users.controller.ts @@ -142,6 +142,13 @@ export class UsersController { user['number_house']); } + @MessagePattern({ cmd: 'removeIdCommunity' }) + removeIdCommunity(@Payload() user: any) { + let community_id = user['community_id']; + return this.userService.removeIdCommunity(community_id); + } + + @MessagePattern({ cmd: 'changeStatus' }) changeStatus(@Payload() body: string) { let pid = body['id']; diff --git a/servicio-usuarios/src/users/users.service.ts b/servicio-usuarios/src/users/users.service.ts index 1393b2bd..bc8ea288 100644 --- a/servicio-usuarios/src/users/users.service.ts +++ b/servicio-usuarios/src/users/users.service.ts @@ -295,5 +295,11 @@ export class UsersService { map((response: string) => ({ response })) ) } + + async removeIdCommunity(community_id: string){ + return this.userModel.updateMany({community_id: community_id, user_type:'2' }, {"$set":{"community_id": ''}}); + /*await this.userModel.updateMany({community_id: community_id, user_type:'3' }, {"$set":{"community_id": ''}, {"status": '-1'}}); + return this.userModel.updateMany({community_id: community_id, user_type:'4' }, {"$set":{"community_id": ''}, {"status": '-1'}});*/ + } } diff --git a/web-ui/web-react/src/components/ComunidadViviendas.js b/web-ui/web-react/src/components/ComunidadViviendas.js index 2821bd20..68378ab7 100644 --- a/web-ui/web-react/src/components/ComunidadViviendas.js +++ b/web-ui/web-react/src/components/ComunidadViviendas.js @@ -315,10 +315,8 @@ const Communities = () => { setDeleteCommunitiesDialog(true); }; - const infoCommunity = async (community) => { await tenantsList(community._id); - setCommunity({ ...community }); setCommunityDialog(true); }; @@ -383,40 +381,38 @@ const Communities = () => { ); } - const deleteCommunity = () => { - /* fetch('http://localhost:4000/community/deleteCommunity/' + community._id, { - cache: 'no-cache', - method: 'DELETE', - headers: { - 'Content-Type': 'application/json' - } - }) - .then( - function (response) { - if (response.status != 201) - console.log('Ocurrió un error con el servicio: ' + response.status); - else - return response.json(); - } - ) - .then( - function (response) { - - let _community = communities.filter(val => val._id !== community._id); - setCommunities(_community); - setDeleteCommunityDialog(false); - setCommunity(emptyCommunity); - toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Comunidad de Viviendas Eliminada', life: 3000 }); - } - ) - .catch( - err => { - console.log('Ocurrió un error con el fetch', err) - toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Comunidad de Viviendas no se pudo eliminar', life: 3000 }); - } - ); - */ + fetch('http://localhost:4000/community/deleteCommunity/' + community._id, { + cache: 'no-cache', + method: 'DELETE', + headers: { + 'Content-Type': 'application/json' + } + }) + .then( + function (response) { + if (response.status != 201) + console.log('Ocurrió un error con el servicio: ' + response.status); + else + return response.json(); + } + ) + .then( + function (response) { + + let _community = communities.filter(val => val._id !== community._id); + setCommunities(_community); + setDeleteCommunityDialog(false); + setCommunity(emptyCommunity); + toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Comunidad de Viviendas Eliminada', life: 3000 }); + } + ) + .catch( + err => { + console.log('Ocurrió un error con el fetch', err) + toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Comunidad de Viviendas no se pudo eliminar', life: 3000 }); + } + ); let _communities = communitiesList.filter((val) => val._id !== community._id); _communities = _communities.filter( (val) => val.status != -1, From 9da33006d9664dbf97ed0467177845d012c9140d Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 23 Aug 2022 01:08:55 -0600 Subject: [PATCH 02/55] eliminar usuarios, reservaciones y areas --- .../common_areas/common_areas.controller.ts | 22 ++++++---- .../src/common_areas/common_areas.service.ts | 4 ++ .../src/communities/communities.module.ts | 20 +++++++++ .../src/communities/communities.service.ts | 25 +++++++---- .../reservations/reservations.controller.ts | 6 +++ .../src/reservations/reservations.service.ts | 4 ++ .../src/schemas/reservation.schema.ts | 3 ++ servicio-usuarios/src/users/users.service.ts | 6 +-- .../components/AdministradoresComunidad.js | 42 ++++++++++--------- .../src/components/ComunidadViviendas.js | 4 +- 10 files changed, 95 insertions(+), 41 deletions(-) diff --git a/servicio-areas-comunes/src/common_areas/common_areas.controller.ts b/servicio-areas-comunes/src/common_areas/common_areas.controller.ts index 28b5ce7e..b3bdad69 100644 --- a/servicio-areas-comunes/src/common_areas/common_areas.controller.ts +++ b/servicio-areas-comunes/src/common_areas/common_areas.controller.ts @@ -5,7 +5,7 @@ import { CommonAreasService } from './common_areas.service'; @Controller() export class CommonAreasController { - constructor(private readonly commonAreasService: CommonAreasService) {} + constructor(private readonly commonAreasService: CommonAreasService) { } @MessagePattern({ cmd: 'createCommonArea' }) create(@Payload() commonArea: CommonAreaDocument) { @@ -40,11 +40,17 @@ export class CommonAreasController { return this.commonAreasService.findByCommunity(_community_id); } - //cambiar de estado - @MessagePattern({ cmd: 'changeStatus' }) - changeStatus(@Payload() body: string) { - let pid = body['id']; - let pstatus = body['status']; - return this.commonAreasService.changeStatus(pid,pstatus); - } + //cambiar de estado + @MessagePattern({ cmd: 'changeStatus' }) + changeStatus(@Payload() body: string) { + let pid = body['id']; + let pstatus = body['status']; + return this.commonAreasService.changeStatus(pid, pstatus); + } + + @MessagePattern({ cmd: 'removeIdCommunity' }) + removeIdCommunity(@Payload() area: any) { + let community_id = area['community_id']; + return this.commonAreasService.removeIdCommunity(community_id); + } } 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 e617df0c..877bd011 100644 --- a/servicio-areas-comunes/src/common_areas/common_areas.service.ts +++ b/servicio-areas-comunes/src/common_areas/common_areas.service.ts @@ -47,4 +47,8 @@ export class CommonAreasService { }); } + + async removeIdCommunity(community_id: string){ + await this.commonAreaModel.updateMany({community_id: community_id}, {"$set":{"status": '-1'}}); + } } diff --git a/servicio-comunidad-viviendas/src/communities/communities.module.ts b/servicio-comunidad-viviendas/src/communities/communities.module.ts index 8b24e5e1..4e6a9095 100644 --- a/servicio-comunidad-viviendas/src/communities/communities.module.ts +++ b/servicio-comunidad-viviendas/src/communities/communities.module.ts @@ -18,6 +18,26 @@ import { Community, CommunitySchema } from '../schemas/community.schema'; }, }, ]), + ClientsModule.register([ + { + name: 'SERVICIO_AREAS_COMUNES', + transport: Transport.TCP, + options: { + host: '127.0.0.1', + port: 3003, + }, + }, + ]), + ClientsModule.register([ + { + name: 'SERVICIO_RESERVACIONES', + transport: Transport.TCP, + options: { + host: '127.0.0.1', + port: 3006, + }, + }, + ]), MongooseModule.forFeature([ { name: Community.name, schema: CommunitySchema }, ]), diff --git a/servicio-comunidad-viviendas/src/communities/communities.service.ts b/servicio-comunidad-viviendas/src/communities/communities.service.ts index 93f7cbe2..212eeda7 100644 --- a/servicio-comunidad-viviendas/src/communities/communities.service.ts +++ b/servicio-comunidad-viviendas/src/communities/communities.service.ts @@ -14,6 +14,8 @@ export class CommunitiesService { @InjectModel(Community.name) private readonly communityModel: Model, @Inject('SERVICIO_USUARIOS') private readonly clientUserApp: ClientProxy, + @Inject('SERVICIO_AREAS_COMUNES') private readonly clientAreaApp: ClientProxy, + @Inject('SERVICIO_RESERVACIONES') private readonly clientReservationApp: ClientProxy, ) { } async create(community: CommunityDocument): Promise { @@ -81,7 +83,6 @@ export class CommunitiesService { return finalValue['response']; } - async saveTenant(id: string, number_house: string, ptenant_id: string) { let community = await this.findOne(id); await community.houses.map(house => { @@ -98,13 +99,11 @@ export class CommunitiesService { } return house; }) - return await this.communityModel.findOneAndUpdate({ _id: id }, community, { new: true, }); } - async deleteTenant(id: string, number_house: string, tenant_id: string) { let community = await this.findOne(id); @@ -115,7 +114,6 @@ export class CommunitiesService { } return house; }) - return await this.communityModel.findOneAndUpdate({ _id: id }, community, { new: true, }); @@ -123,13 +121,24 @@ export class CommunitiesService { async removeIdCommunity(community: string) { const pattern = { cmd: 'removeIdCommunity' }; - const payload = { community_id: community}; + const payload = { community_id: community }; - let callback = await this.clientUserApp + await this.clientUserApp .send(pattern, payload) .pipe(map((response: string) => ({ response }))); - const finalValue = await lastValueFrom(callback); - return finalValue['response']; + const pattern2 = { cmd: 'removeIdCommunity' }; + const payload2 = { community_id: community }; + + await this.clientAreaApp + .send(pattern2, payload2) + .pipe(map((response: string) => ({ response }))); + + const pattern3 = { cmd: 'removeIdCommunity' }; + const payload3 = { community_id: community }; + + await this.clientReservationApp + .send(pattern3, payload3) + .pipe(map((response: string) => ({ response }))); } } diff --git a/servicio-reservaciones/src/reservations/reservations.controller.ts b/servicio-reservaciones/src/reservations/reservations.controller.ts index 49621768..ea6a2553 100644 --- a/servicio-reservaciones/src/reservations/reservations.controller.ts +++ b/servicio-reservaciones/src/reservations/reservations.controller.ts @@ -38,4 +38,10 @@ export class ReservationsController { let _id = id['id']; return this.reservationsService.remove(_id); } + + @MessagePattern({ cmd: 'removeIdCommunity' }) + removeIdCommunity(@Payload() reservation: any) { + let community_id = reservation['community_id']; + return this.reservationsService.removeIdCommunity(community_id); + } } diff --git a/servicio-reservaciones/src/reservations/reservations.service.ts b/servicio-reservaciones/src/reservations/reservations.service.ts index 45382f50..c56174f1 100644 --- a/servicio-reservaciones/src/reservations/reservations.service.ts +++ b/servicio-reservaciones/src/reservations/reservations.service.ts @@ -45,4 +45,8 @@ export class ReservationsService { new: true, }); } + + async removeIdCommunity(community_id: string){ + await this.reservationModel.updateMany({community_id: community_id}, {"$set":{"status": '-1'}}); + } } diff --git a/servicio-reservaciones/src/schemas/reservation.schema.ts b/servicio-reservaciones/src/schemas/reservation.schema.ts index 542eb422..34536ff6 100644 --- a/servicio-reservaciones/src/schemas/reservation.schema.ts +++ b/servicio-reservaciones/src/schemas/reservation.schema.ts @@ -22,6 +22,9 @@ export class Reservation { @Prop() user_id: string; + + @Prop() + community_id: string; } export const ReservationSchema = SchemaFactory.createForClass(Reservation); diff --git a/servicio-usuarios/src/users/users.service.ts b/servicio-usuarios/src/users/users.service.ts index bc8ea288..6247e26c 100644 --- a/servicio-usuarios/src/users/users.service.ts +++ b/servicio-usuarios/src/users/users.service.ts @@ -297,9 +297,9 @@ export class UsersService { } async removeIdCommunity(community_id: string){ - return this.userModel.updateMany({community_id: community_id, user_type:'2' }, {"$set":{"community_id": ''}}); - /*await this.userModel.updateMany({community_id: community_id, user_type:'3' }, {"$set":{"community_id": ''}, {"status": '-1'}}); - return this.userModel.updateMany({community_id: community_id, user_type:'4' }, {"$set":{"community_id": ''}, {"status": '-1'}});*/ + await this.userModel.updateMany({community_id: community_id, user_type:'2' }, {"$set":{"community_id": ''}}); + await this.userModel.updateMany({community_id: community_id, user_type:'3' }, {"$set":{"community_id": '', "status": '-1'}}); + return this.userModel.updateMany({community_id: community_id, user_type:'4' }, {"$set":{"community_id": '', "status": '-1'}}); } } diff --git a/web-ui/web-react/src/components/AdministradoresComunidad.js b/web-ui/web-react/src/components/AdministradoresComunidad.js index 0ec73891..e58be62a 100644 --- a/web-ui/web-react/src/components/AdministradoresComunidad.js +++ b/web-ui/web-react/src/components/AdministradoresComunidad.js @@ -66,13 +66,18 @@ const AdministradoresComunidad = () => { item.status_text = 'Eliminado'; } //item.full_name returns the repositorie name - return fetch(`http://localhost:4000/community/findCommunityName/${item.community_id}`, { method: 'GET' }) - .then((response2) => response2.json()) - .then(data => data.message) - .then(data => { - item.community_name = data['name'] - return item - }) + if (item.community_id || item.community_id != '') { + return fetch(`http://localhost:4000/community/findCommunityName/${item.community_id}`, { method: 'GET' }) + .then((response2) => response2.json()) + .then(data => data.message) + .then(data => { + item.community_name = data['name'] + return item + }) + } else { + item.community_name = "Sin Comunidad Asignada"; + return item; + } })); }) .then(data => { @@ -86,9 +91,6 @@ const AdministradoresComunidad = () => { } - - - async function getCommunites() { let response = await fetch('http://localhost:4000/community/allCommunities', { method: 'GET' }) .then((response) => response.json()) @@ -151,22 +153,22 @@ const AdministradoresComunidad = () => { } ); - + }; const deleteSelectedAdminsCommunity = () => { let _admins = listaAdmins.filter( (val) => !selectedAdminsCommunities.includes(val), ); - selectedAdminsCommunities.map((item) => { - fetch('http://localhost:4000/user/deleteAdminCommunity/' + item._id, { - cache: 'no-cache', - method: 'DELETE', - headers: { - 'Content-Type': 'application/json' - } - }) - }) + selectedAdminsCommunities.map((item) => { + fetch('http://localhost:4000/user/deleteAdminCommunity/' + item._id, { + cache: 'no-cache', + method: 'DELETE', + headers: { + 'Content-Type': 'application/json' + } + }) + }) setListaAdmins(_admins); setDeleteAdminsCommunitiesDialog(false); setSelectedAdminsCommunities(null); diff --git a/web-ui/web-react/src/components/ComunidadViviendas.js b/web-ui/web-react/src/components/ComunidadViviendas.js index 68378ab7..a401fd17 100644 --- a/web-ui/web-react/src/components/ComunidadViviendas.js +++ b/web-ui/web-react/src/components/ComunidadViviendas.js @@ -400,8 +400,8 @@ const Communities = () => { .then( function (response) { - let _community = communities.filter(val => val._id !== community._id); - setCommunities(_community); + let _community = communitiesList.filter(val => val._id !== community._id); + setCommunitiesList(_community); setDeleteCommunityDialog(false); setCommunity(emptyCommunity); toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Comunidad de Viviendas Eliminada', life: 3000 }); From 2c2e54bd1977c98a2095797e3a254db108b37bcb Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 23 Aug 2022 02:37:06 -0600 Subject: [PATCH 03/55] add initial component --- .../src/components/InvitadosComunidad.js | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 web-ui/web-react/src/components/InvitadosComunidad.js diff --git a/web-ui/web-react/src/components/InvitadosComunidad.js b/web-ui/web-react/src/components/InvitadosComunidad.js new file mode 100644 index 00000000..c0cec4e2 --- /dev/null +++ b/web-ui/web-react/src/components/InvitadosComunidad.js @@ -0,0 +1,69 @@ +import { useCookies } from 'react-cookie'; +import { useState, useRef } from 'react'; + +const InvitadosComunidad = () => { + const [cookies] = useCookies(); + const [globalFilter, setGlobalFilter] = useState(null); + const [invitados, setInvitados] = useState([]); + const [selectedInvitados, setSelectedInvitados] = useState([]); + const tableRef = useRef(null); + const toast = useRef(null); + + const headerTemplate = ( +
+
Invitados
+ + + setGlobalFilter(e.target.value)} + placeholder='Buscar...' + /> + +
+ ); + + return ( +
+
+ +
+ + setSelectedInvitados(e.value)} + scrollable + scrollHeight='500px' + scrollWidth='100%' + scrollDirection='both' + header={headerTemplate} + rowsPerPageOptions={[10, 20, 30]} + className='datatable-responsive mt-3' + paginatorTemplate='FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown' + currentPageReportTemplate='{currentPage} de {totalPages}' + globalFilter={globalFilter} + emptyMessageTemplate='No se encontraron invitados' + > + + + + + + + + + +
+
+
+ ) +} From 84c2aff9119fae907949f3fe64bf0abd50470161 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 23 Aug 2022 02:56:51 -0600 Subject: [PATCH 04/55] agregar invitados a menu --- web-ui/web-react/src/App.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web-ui/web-react/src/App.js b/web-ui/web-react/src/App.js index 1551381d..08f0e13c 100644 --- a/web-ui/web-react/src/App.js +++ b/web-ui/web-react/src/App.js @@ -34,6 +34,7 @@ import GuardasSeguridad from './components/GuardasSeguridad'; import Communities from './components/ComunidadViviendas'; import Inquilinos from './components/Inquilinos'; import RegistroComunicado from './components/RegistroComunicado'; +import InvitadosComunidad from './components/InvitadosComunidad'; import "../node_modules/bootstrap/dist/css/bootstrap.min.css"; import Crud from './pages/Crud'; @@ -203,6 +204,7 @@ const App = () => { }, { label: 'Comunicados', icon: PrimeIcons.COMMENTS, to: '/registroComunicado'}, + { label: 'Invitados', icon: PrimeIcons.USERS, to: '/invitadosComunidad' }, ] }, From 1adaa5bec71be5328d882f3aa679e42ecd99b6de Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 23 Aug 2022 02:57:01 -0600 Subject: [PATCH 05/55] agregar imports --- web-ui/web-react/src/components/InvitadosComunidad.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web-ui/web-react/src/components/InvitadosComunidad.js b/web-ui/web-react/src/components/InvitadosComunidad.js index c0cec4e2..f55dfb64 100644 --- a/web-ui/web-react/src/components/InvitadosComunidad.js +++ b/web-ui/web-react/src/components/InvitadosComunidad.js @@ -1,3 +1,7 @@ +import { Column } from 'primereact/column' +import { DataTable } from 'primereact/datatable' +import { Toast } from 'primereact/toast' +import { Toolbar } from 'primereact/toolbar' import { useCookies } from 'react-cookie'; import { useState, useRef } from 'react'; From 7a192d9a682640eedb802b679e2b4dbc16ce920f Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 23 Aug 2022 03:18:32 -0600 Subject: [PATCH 06/55] use correct imports --- web-ui/web-react/src/components/InvitadosComunidad.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web-ui/web-react/src/components/InvitadosComunidad.js b/web-ui/web-react/src/components/InvitadosComunidad.js index f55dfb64..7bd820b8 100644 --- a/web-ui/web-react/src/components/InvitadosComunidad.js +++ b/web-ui/web-react/src/components/InvitadosComunidad.js @@ -1,9 +1,11 @@ +import React, { useState, useEffect, useRef } from 'react'; +import { Button } from 'primereact/button' +import { InputText } from 'primereact/inputtext' import { Column } from 'primereact/column' import { DataTable } from 'primereact/datatable' import { Toast } from 'primereact/toast' import { Toolbar } from 'primereact/toolbar' import { useCookies } from 'react-cookie'; -import { useState, useRef } from 'react'; const InvitadosComunidad = () => { const [cookies] = useCookies(); @@ -11,7 +13,8 @@ const InvitadosComunidad = () => { const [invitados, setInvitados] = useState([]); const [selectedInvitados, setSelectedInvitados] = useState([]); const tableRef = useRef(null); - const toast = useRef(null); + const toastRef = useRef(null); + const headerTemplate = (
From 90fae98adb5995e2fa43bc9354494fdb3b60fa85 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 23 Aug 2022 03:18:49 -0600 Subject: [PATCH 07/55] add initial fetch for invitados --- .../src/components/InvitadosComunidad.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/web-ui/web-react/src/components/InvitadosComunidad.js b/web-ui/web-react/src/components/InvitadosComunidad.js index 7bd820b8..451fb268 100644 --- a/web-ui/web-react/src/components/InvitadosComunidad.js +++ b/web-ui/web-react/src/components/InvitadosComunidad.js @@ -15,7 +15,24 @@ const InvitadosComunidad = () => { const tableRef = useRef(null); const toastRef = useRef(null); + const getInvitados = async () => { + console.log(`${process.env.REACT_APP_API_URL}`); + await fetch(`${process.env.REACT_APP_API_URL}/guest/allGuests`, { + method: 'GET', + }) + .then(response => response.json()) + .then(data => data.message) + .then(data => { + data = data.filter(invitado => + invitado.community === cookies.community_id); + setInvitados(data); + }) + } + useEffect(() => { + getInvitados(); + }, [invitados]); + const headerTemplate = (
Invitados
From ec452b0a7ed654706c93fd7492478d3e6b9e97a7 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 23 Aug 2022 03:19:36 -0600 Subject: [PATCH 08/55] add toolbar templates --- .../src/components/InvitadosComunidad.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/web-ui/web-react/src/components/InvitadosComunidad.js b/web-ui/web-react/src/components/InvitadosComunidad.js index 451fb268..a27fe730 100644 --- a/web-ui/web-react/src/components/InvitadosComunidad.js +++ b/web-ui/web-react/src/components/InvitadosComunidad.js @@ -33,6 +33,28 @@ const InvitadosComunidad = () => { getInvitados(); }, [invitados]); + const leftToolbarTemplate = () => { + return ( + +
+

Boton Eliminar aqui

+
+
+ ) + } + + const rightToolbarTemplate = () => { + return ( + +
From 64f9216b5f0c3cf66e44187e09ba2febbb5b4c54 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 23 Aug 2022 03:40:54 -0600 Subject: [PATCH 12/55] format --- .../src/components/InvitadosComunidad.js | 151 +++++++++++------- 1 file changed, 92 insertions(+), 59 deletions(-) diff --git a/web-ui/web-react/src/components/InvitadosComunidad.js b/web-ui/web-react/src/components/InvitadosComunidad.js index 81a74005..9e24b3b6 100644 --- a/web-ui/web-react/src/components/InvitadosComunidad.js +++ b/web-ui/web-react/src/components/InvitadosComunidad.js @@ -6,13 +6,13 @@ import { Column } from 'primereact/column'; import { Toast } from 'primereact/toast'; import { Dialog } from 'primereact/dialog'; import { Toolbar } from 'primereact/toolbar'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faUserAlt } from '@fortawesome/free-solid-svg-icons'; import { faPhoneAlt } from '@fortawesome/free-solid-svg-icons'; import { faAt } from '@fortawesome/free-solid-svg-icons'; import { faIdCardAlt } from '@fortawesome/free-solid-svg-icons'; import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons'; -import { useCookies } from "react-cookie"; +import { useCookies } from 'react-cookie'; import classNames from 'classnames'; const InvitadosComunidad = () => { @@ -28,14 +28,15 @@ const InvitadosComunidad = () => { await fetch(`${process.env.REACT_APP_API_URL}/guest/allGuests`, { method: 'GET', }) - .then(response => response.json()) - .then(data => data.message) - .then(data => { - data = data.filter(invitado => - invitado.community === cookies.community_id); + .then((response) => response.json()) + .then((data) => data.message) + .then((data) => { + data = data.filter( + (invitado) => invitado.community === cookies.community_id, + ); setInvitados(data); - }) - } + }); + }; useEffect(() => { getInvitados(); @@ -44,59 +45,61 @@ const InvitadosComunidad = () => { const leftToolbarTemplate = () => { return ( -
+

Boton Eliminar aqui

- ) - } + ); + }; const rightToolbarTemplate = () => { return (
+ ); + }; + + + + const confirmDeleteReservation = (reservation) => { + setReservation(reservation); + setDeleteReservationDialog(true); + }; + + const confirmDeleteSelected = () => { + setDeleteReservationsDialog(true); + }; + + const leftToolbarTemplate = () => { + return ( + +
+
+
+ ); + }; + + const rightToolbarTemplate = () => { + return ( + +
+ + + From ac2f644334417e3b19e0d3afc9a574871378853d Mon Sep 17 00:00:00 2001 From: Mariela Date: Wed, 24 Aug 2022 16:35:20 -0600 Subject: [PATCH 25/55] =?UTF-8?q?a=C3=B1adir=20input=20inquilino?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web-react/src/components/Reservaciones.js | 68 ++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/web-ui/web-react/src/components/Reservaciones.js b/web-ui/web-react/src/components/Reservaciones.js index 70cf6275..fc51f6b4 100644 --- a/web-ui/web-react/src/components/Reservaciones.js +++ b/web-ui/web-react/src/components/Reservaciones.js @@ -43,6 +43,7 @@ const Reservations = () => { const [areas, setAreas] = useState([]); const [areaId, setAreaId] = useState(); const [tenants, setTenants] = useState([]); + const [tenantId, setTenantId] = useState(); const [saveButtonTitle, setSaveButtonTitle] = useState("Registrar") async function tenantsList(id) { @@ -264,16 +265,34 @@ const Reservations = () => { ); }; + const onInputChange = (e, name) => { + const val = (e.target && e.target.value) || ''; + let _reservation = { ...reservation }; + _reservation[`${name}`] = val; + + setReservation(_reservation); + }; + const handleAreas = (e) => { const getAreaId = e.target.value; setAreaId(getAreaId); } + const handleTenants = (e) => { + const getTenantId = e.target.value; + setAreaId(getTenantId); + } + const aList = areas.map((item) => ({ label: item.name, value: item._id, })); + const tList = tenants.map((item) => ({ + label: item.name, + value: item._id, + })); + return (
@@ -371,8 +390,53 @@ const Reservations = () => {
Reservar Área para Inquilino
- -
+
+ +
+
+ + + + onInputChange(e, 'name')} + required + autoFocus + className={classNames({ + 'p-invalid': submitted && reservation.start_time === '', + })} + /> +
+ {submitted && reservation.start_time === '' && ( + Nombre es requirido. + )} +
+
+
+ +
+
+ + + + +
+ {submitted + && !tenantId + && Inquilino es requerido.} +
+
+
From 0a7cc3c1db3ce932edfcf19b990a92e1766c2a26 Mon Sep 17 00:00:00 2001 From: Mariela Date: Thu, 25 Aug 2022 00:03:19 -0600 Subject: [PATCH 26/55] funciones reservaciones --- .../web-react/src/components/Reservaciones.js | 162 ++++++++++++------ 1 file changed, 114 insertions(+), 48 deletions(-) diff --git a/web-ui/web-react/src/components/Reservaciones.js b/web-ui/web-react/src/components/Reservaciones.js index fc51f6b4..90792960 100644 --- a/web-ui/web-react/src/components/Reservaciones.js +++ b/web-ui/web-react/src/components/Reservaciones.js @@ -41,6 +41,7 @@ const Reservations = () => { const dt = useRef(null); const [cookies, setCookies] = useCookies() const [areas, setAreas] = useState([]); + const [area, setArea] = useState(); const [areaId, setAreaId] = useState(); const [tenants, setTenants] = useState([]); const [tenantId, setTenantId] = useState(); @@ -269,13 +270,15 @@ const Reservations = () => { const val = (e.target && e.target.value) || ''; let _reservation = { ...reservation }; _reservation[`${name}`] = val; - + setReservation(_reservation); - }; + }; const handleAreas = (e) => { const getAreaId = e.target.value; setAreaId(getAreaId); + let area = areas.find(item => item._id == getAreaId); + setArea(area) } const handleTenants = (e) => { @@ -293,6 +296,35 @@ const Reservations = () => { value: item._id, })); + function convertToISO(timeString) { + const [hour12, ampm] = timeString.split(/(?=[ap]m$)/i) + const hour = hour12 % 12 + (ampm.toLowerCase() === 'pm' ? 12 : 0) + const date = new Date() + // Set time, adjusted for time zone + date.setHours(hour, -date.getTimezoneOffset(), 0, 0) + return date.toISOString() + } + + function validateTime(timeStart, timeFinish) { + if ((timeFinish - timeStart) == 1) { + return ( + <> + La hora de inicio debe ser la hora . + + ) + } + } + + function convertToTime(timeString) { + const [hour, minute] = timeString.split(':'); + const date = new Date() + date.setHours(hour); + date.setMinutes(minute); + console.log(date.toTimeString()); + return date.toString() + } + + return (
@@ -390,52 +422,6 @@ const Reservations = () => {
Reservar Área para Inquilino
-
- -
-
- - - - onInputChange(e, 'name')} - required - autoFocus - className={classNames({ - 'p-invalid': submitted && reservation.start_time === '', - })} - /> -
- {submitted && reservation.start_time === '' && ( - Nombre es requirido. - )} -
-
-
- -
-
- - - - -
- {submitted - && !tenantId - && Inquilino es requerido.} -
-
@@ -459,6 +445,86 @@ const Reservations = () => { && Área Común es requerida.}
+ {area && + <> +
+ +
+
+ + + + onInputChange(e, 'start_time')} + required + autoFocus + min={area.hourMin} + max={area.hourMax} + type="time" + lang='es' + value={reservation.start_time} + className={classNames({ + 'p-invalid': submitted && reservation.start_time === '', + })} + /> +
+ {submitted && reservation.start_time === '' && ( + Nombre es requirido. + )} +
+
+ +
+ +
+
+ + + + onInputChange(e, 'finish_time')} + required + autoFocus + type="time" + className={classNames({ + 'p-invalid': submitted && reservation.finish_time === '', + })} + /> +
+ {submitted && reservation.finish_time === '' && ( + Nombre es requirido. + )} +
+
+ + } +
+ +
+
+ + + + +
+ {submitted + && !tenantId + && Inquilino es requerido.} +
+
+
Date: Thu, 25 Aug 2022 00:06:38 -0600 Subject: [PATCH 27/55] nuevos items --- api-gateway/src/app.controller.ts | 8 ++++---- api-gateway/src/app.service.ts | 4 ++-- servicio-reservaciones/src/schemas/reservation.schema.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index 76e6d442..39e794ae 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -505,8 +505,8 @@ export class AppController { @Post('reservation/createReservation') createReservation( - @Body('start_time') start_time: string, - @Body('finish_time') finish_time: string, + @Body('date') date: string, + @Body('time') time: string, @Body('status') status: string, @Body('date_entry') date_entry: Date, @Body('user_id') user_id: string, @@ -515,8 +515,8 @@ export class AppController { @Body('communty_id') communty_id: string, ) { return this.appService.createReservation( - start_time, - finish_time, + date, + time, status, date_entry, user_id, diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 50beb9f6..2a843756 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -613,12 +613,12 @@ export class AppService { // ====================== RESERVATIONS =============================== //POST parameter from API - createReservation(start_time: string, finish_time: string, status: string, + createReservation(date: string, time: string, status: string, date_entry: Date, user_id: string, common_area_id: string, common_area_name: string, communty_id: string) { const pattern = { cmd: 'createReservation' }; const payload = { - start_time: start_time, finish_time: finish_time, status: status, + date: date, time: time, status: status, date_entry: date_entry, user_id: user_id, common_area_id: common_area_id, common_area_name: common_area_name, communty_id: communty_id }; diff --git a/servicio-reservaciones/src/schemas/reservation.schema.ts b/servicio-reservaciones/src/schemas/reservation.schema.ts index c51bf2d9..c5acc3c4 100644 --- a/servicio-reservaciones/src/schemas/reservation.schema.ts +++ b/servicio-reservaciones/src/schemas/reservation.schema.ts @@ -6,10 +6,10 @@ export type ReservationDocument = Reservation & Document; @Schema({ collection: 'reservations' }) export class Reservation { @Prop() - start_time: string; + date: string; @Prop() - finish_time: string; + time: string; @Prop() status: string; From 2bce41dbc041b7c9251c46b8b124ca8fa488fb5f Mon Sep 17 00:00:00 2001 From: Mariela Date: Fri, 26 Aug 2022 00:02:17 -0600 Subject: [PATCH 28/55] change manejo de fechas --- .../web-react/src/components/Reservaciones.js | 79 +++++++++++-------- 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/web-ui/web-react/src/components/Reservaciones.js b/web-ui/web-react/src/components/Reservaciones.js index 90792960..c2868498 100644 --- a/web-ui/web-react/src/components/Reservaciones.js +++ b/web-ui/web-react/src/components/Reservaciones.js @@ -17,8 +17,8 @@ import { useCookies } from 'react-cookie'; const Reservations = () => { let emptyReservation = { _id: null, - start_time: '', - finish_time: '', + date: '', + time: '', user_id: '', user_name: '', common_area_id: '', @@ -71,8 +71,12 @@ const Reservations = () => { .then(data => data.message) .then(data => { data = data.filter( - (val) => val.status != -1, + (val) => val.status != -1 ) + data = data.filter( + (val) => val.bookable == 1, + ) + setAreas(data) }); } @@ -209,7 +213,7 @@ const Reservations = () => {

{' '} - Hora de Apertura + Fecha de Reserva

); @@ -219,7 +223,7 @@ const Reservations = () => {

{' '} {' '} - Hora de Cierre + Hora de Reserva

); @@ -283,7 +287,7 @@ const Reservations = () => { const handleTenants = (e) => { const getTenantId = e.target.value; - setAreaId(getTenantId); + setTenantId(getTenantId); } const aList = areas.map((item) => ({ @@ -305,14 +309,19 @@ const Reservations = () => { return date.toISOString() } - function validateTime(timeStart, timeFinish) { - if ((timeFinish - timeStart) == 1) { - return ( - <> - La hora de inicio debe ser la hora . - - ) + function validationTime() { + let value = true; + const [hourR, minuteR] = reservation.time.split(':'); + if (hourR != "") { + const [hourMin, minuteMin] = area.hourMin.split(':'); + const [hourMax, minuteMax] = area.hourMax.split(':'); + if ((parseInt(hourR) >= parseInt(hourMin)) && (parseInt(hourR) <= parseInt(hourMax))) { + value = false; + } + } else { + value = false; } + return value; } function convertToTime(timeString) { @@ -448,61 +457,67 @@ const Reservations = () => { {area && <>
- +
onInputChange(e, 'start_time')} + id="date" + onChange={(e) => onInputChange(e, 'date')} required autoFocus - min={area.hourMin} - max={area.hourMax} - type="time" + min={Date()} + type="date" lang='es' - value={reservation.start_time} + value={reservation.date} className={classNames({ - 'p-invalid': submitted && reservation.start_time === '', + 'p-invalid': submitted && reservation.date === '', })} /> +
- {submitted && reservation.start_time === '' && ( - Nombre es requirido. + {submitted && reservation.date === '' && ( + Fecha es requirida. )}
- +
onInputChange(e, 'finish_time')} + id="time" + value={reservation.time} + onChange={(e) => onInputChange(e, 'time')} required autoFocus type="time" + step='3600' className={classNames({ - 'p-invalid': submitted && reservation.finish_time === '', + 'p-invalid': submitted && (reservation.time === '' || validationTime()), })} />
- {submitted && reservation.finish_time === '' && ( - Nombre es requirido. + {submitted && reservation.time === '' && ( + Hora es requirido. )} + {submitted && validationTime() && ( + La hora de inicio debe set mayor de {area.hourMin} y menor de {area.hourMax} . + )} + +
}
- +
@@ -510,7 +525,7 @@ const Reservations = () => { Date: Fri, 26 Aug 2022 00:30:47 -0600 Subject: [PATCH 29/55] =?UTF-8?q?agregar=20dialogo=20para=20agregar=20y=20?= =?UTF-8?q?validaciones=20b=C3=A1sicas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web-react/src/components/Reservaciones.js | 294 +++++++++++------- 1 file changed, 176 insertions(+), 118 deletions(-) diff --git a/web-ui/web-react/src/components/Reservaciones.js b/web-ui/web-react/src/components/Reservaciones.js index c2868498..51c2682f 100644 --- a/web-ui/web-react/src/components/Reservaciones.js +++ b/web-ui/web-react/src/components/Reservaciones.js @@ -46,6 +46,9 @@ const Reservations = () => { const [tenants, setTenants] = useState([]); const [tenantId, setTenantId] = useState(); const [saveButtonTitle, setSaveButtonTitle] = useState("Registrar") + const [reservationDialog, setReservationDialog] = useState(false); + + async function tenantsList(id) { await fetch(`http://localhost:4000/user/findTenants/${id}`, @@ -71,12 +74,12 @@ const Reservations = () => { .then(data => data.message) .then(data => { data = data.filter( - (val) => val.status != -1 + (val) => val.status != -1 ) data = data.filter( (val) => val.bookable == 1, ) - + setAreas(data) }); } @@ -124,8 +127,20 @@ const Reservations = () => { }, []) const saveReservation = () => { - if (reservation.common_area_id) { + let _reservations = [...reservations]; + let _reservation = { ...reservation }; + + if ( _reservation.date && _reservation.time && tenantId && areaId && !validationTime()) { + _reservations.push(_reservation); + setReservations(_reservations) + toast.current.show({ + severity: 'success', + summary: 'Éxito', + detail: 'Administrador del Sistema Actualizado', + life: 3000, + }); + setReservationDialog(false) } else { setSubmitted(true); } @@ -162,12 +177,34 @@ const Reservations = () => { setReservation(emptyReservation); setSaveButtonTitle('Registrar'); setAreaId(''); + setTenantId(''); } + const hideNewReservationDialog = () => { + setSubmitted(false); + setReservationDialog(false); + setReservation(emptyReservation); + setAreaId(''); + setTenantId(''); + }; + + const openNewReservation = () => { + setReservation(emptyReservation); + setReservationDialog(true); + setSubmitted(false); + + }; + const leftToolbarTemplate = () => { return (
+
+
); }; @@ -192,6 +230,19 @@ const Reservations = () => { ); }; + + const reservationDialogFooter = ( + <> +
-
-
-
Reservar Área para Inquilino
-
-
- -
-
- - - - -
- {submitted - && !areaId - && Área Común es requerida.} -
-
- {area && - <> -
- + + {reservation && ( +
+
+
- onInputChange(e, 'date')} - required - autoFocus - min={Date()} - type="date" - lang='es' - value={reservation.date} - className={classNames({ - 'p-invalid': submitted && reservation.date === '', - })} + -
- {submitted && reservation.date === '' && ( - Fecha es requirida. - )} + {submitted + && !areaId + && Área Común es requerida.}
+ {area && + <> +
+ +
+
+ + + + onInputChange(e, 'date')} + required + autoFocus + min={new Date().toJSON().split('T')[0]} + type="date" + lang='es' + value={reservation.date} + className={classNames({ + 'p-invalid': submitted && reservation.date === '', + })} + /> -
- +
+ {submitted && reservation.date === '' && ( + Fecha es requirida. + )} +
+
+ +
+ +
+
+ + + + onInputChange(e, 'time')} + required + autoFocus + type="time" + step='3600' + className={classNames({ + 'p-invalid': submitted && (reservation.time === '' || validationTime()), + })} + /> +
+ {submitted && reservation.time === '' && ( + Hora es requirido. + )} + {submitted && validationTime() && ( + La hora de inicio debe set mayor de {area.hourMin} y menor de {area.hourMax} . + )} + + +
+
+ + } +
+
- onInputChange(e, 'time')} - required - autoFocus - type="time" - step='3600' - className={classNames({ - 'p-invalid': submitted && (reservation.time === '' || validationTime()), - })} +
- {submitted && reservation.time === '' && ( - Hora es requirido. - )} - {submitted && validationTime() && ( - La hora de inicio debe set mayor de {area.hourMin} y menor de {area.hourMax} . - )} - - + {submitted + && !tenantId + && Inquilino es requerido.}
- - } -
- -
-
- - - - -
- {submitted - && !tenantId - && Inquilino es requerido.} -
-
-
-
-
+
+
+
+ )} +
+
+
From 47efe0bbdff0cd3898749569df1d701265f2261c Mon Sep 17 00:00:00 2001 From: Mariela Date: Fri, 26 Aug 2022 11:07:35 -0600 Subject: [PATCH 30/55] registro de reservacion --- api-gateway/src/app.controller.ts | 4 +- api-gateway/src/app.service.ts | 4 +- .../src/schemas/reservation.schema.ts | 2 +- .../components/AdministradoresComunidad.js | 1 - .../web-react/src/components/Reservaciones.js | 80 ++++++++++++++----- 5 files changed, 65 insertions(+), 26 deletions(-) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index 39e794ae..f6bf3ab0 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -512,7 +512,7 @@ export class AppController { @Body('user_id') user_id: string, @Body('common_area_id') common_area_id: string, @Body('common_area_name') common_area_name: string, - @Body('communty_id') communty_id: string, + @Body('community_id') community_id: string, ) { return this.appService.createReservation( date, @@ -522,7 +522,7 @@ export class AppController { user_id, common_area_id, common_area_name, - communty_id, + community_id, ); } diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 2a843756..380e23d1 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -615,12 +615,12 @@ export class AppService { //POST parameter from API createReservation(date: string, time: string, status: string, date_entry: Date, user_id: string, common_area_id: string, - common_area_name: string, communty_id: string) { + common_area_name: string, community_id: string) { const pattern = { cmd: 'createReservation' }; const payload = { date: date, time: time, status: status, date_entry: date_entry, user_id: user_id, common_area_id: common_area_id, - common_area_name: common_area_name, communty_id: communty_id + common_area_name: common_area_name, community_id: community_id }; return this.clientReservationApp .send(pattern, payload) diff --git a/servicio-reservaciones/src/schemas/reservation.schema.ts b/servicio-reservaciones/src/schemas/reservation.schema.ts index c5acc3c4..857868cf 100644 --- a/servicio-reservaciones/src/schemas/reservation.schema.ts +++ b/servicio-reservaciones/src/schemas/reservation.schema.ts @@ -6,7 +6,7 @@ export type ReservationDocument = Reservation & Document; @Schema({ collection: 'reservations' }) export class Reservation { @Prop() - date: string; + date: Date; @Prop() time: string; diff --git a/web-ui/web-react/src/components/AdministradoresComunidad.js b/web-ui/web-react/src/components/AdministradoresComunidad.js index 8d2fdeec..42b24186 100644 --- a/web-ui/web-react/src/components/AdministradoresComunidad.js +++ b/web-ui/web-react/src/components/AdministradoresComunidad.js @@ -316,7 +316,6 @@ const AdministradoresComunidad = () => { detail: 'Administrador de comunidad actualizado', life: 3000, }) - toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador de Comunidad de vivienda Actualizada', life: 3000 }); listaAdmin(); setCommunityId(''); diff --git a/web-ui/web-react/src/components/Reservaciones.js b/web-ui/web-react/src/components/Reservaciones.js index 51c2682f..aba9a3fe 100644 --- a/web-ui/web-react/src/components/Reservaciones.js +++ b/web-ui/web-react/src/components/Reservaciones.js @@ -79,7 +79,6 @@ const Reservations = () => { data = data.filter( (val) => val.bookable == 1, ) - setAreas(data) }); } @@ -94,6 +93,9 @@ const Reservations = () => { (val) => val.status != -1, ) data.map((item) => { + + item.date = formatDateString(item.date) + if (item.status == '1') { item.status_text = 'Activo'; } else if (item.status == '0') { @@ -127,20 +129,52 @@ const Reservations = () => { }, []) const saveReservation = () => { - let _reservations = [...reservations]; - let _reservation = { ...reservation }; - if ( _reservation.date && _reservation.time && tenantId && areaId && !validationTime()) { - _reservations.push(_reservation); - setReservations(_reservations) - toast.current.show({ - severity: 'success', - summary: 'Éxito', - detail: 'Administrador del Sistema Actualizado', - life: 3000, - }); + let _reservations = [...reservations]; + let _reservation = { ...reservation }; - setReservationDialog(false) + if (_reservation.date && _reservation.time && tenantId && areaId && !validationTime()) { + _reservation.common_area_name = areas.find(item => item._id == areaId).name; + let tenant = tenants.find(item => item._id == tenantId); + _reservation.user_name = tenant.name + ' ' + tenant.last_name; + _reservation.user_id = tenantId; + _reservation.common_area_id = areaId; + _reservation.community_id = cookies.community_id; + + if (_reservation.status == '1') { + _reservation.status_text = 'Activo'; + } else if (_reservation.status == '0') { + _reservation.status_text = 'Inactivo'; + } + console.log(_reservation) + fetch('http://localhost:4000/reservation/createReservation/', { + cache: 'no-cache', + method: 'POST', + body: JSON.stringify(_reservation), + headers: { + 'Content-Type': 'application/json' + } + }) + .then((response) => { + if (response.status !== 200 && response.status !== 201 ) + console.log(`Hubo un error en el servicio: ${response.status}`) + else return response.json() + }).then(() => { + _reservations.push(_reservation); + setReservations(_reservations) + toast.current.show({ + severity: 'success', + summary: 'Éxito', + detail: 'Reservación realizada', + life: 3000, + }); + + setReservationDialog(false) + }) + + + + } else { setSubmitted(true); } @@ -259,7 +293,7 @@ const Reservations = () => {
); - const headerStartTime = ( + const headerDate = ( <>

{' '} @@ -269,7 +303,7 @@ const Reservations = () => { ); - const headerEndTime = ( + const headerTime = ( <>

{' '} @@ -384,6 +418,12 @@ const Reservations = () => { return date.toString() } + function formatDateString(dateString) { + const [date, time] = timeString.split('T'); + return date; + } + + return (

@@ -419,9 +459,9 @@ const Reservations = () => { headerStyle={{ width: '3rem' }} > { }} > {
- +
From ac80892afb65e957b8abcbf1638cb817f6ede5cf Mon Sep 17 00:00:00 2001 From: Mariela Date: Fri, 26 Aug 2022 13:42:46 -0600 Subject: [PATCH 31/55] validaciones de fechas y horas repetidas --- .../web-react/src/components/Reservaciones.js | 96 ++++++++++++------- 1 file changed, 62 insertions(+), 34 deletions(-) diff --git a/web-ui/web-react/src/components/Reservaciones.js b/web-ui/web-react/src/components/Reservaciones.js index aba9a3fe..8e5dfb79 100644 --- a/web-ui/web-react/src/components/Reservaciones.js +++ b/web-ui/web-react/src/components/Reservaciones.js @@ -94,7 +94,9 @@ const Reservations = () => { ) data.map((item) => { - item.date = formatDateString(item.date) + if (item.date) { + item.date = formatDateString(item.date) + } if (item.status == '1') { item.status_text = 'Activo'; @@ -129,11 +131,11 @@ const Reservations = () => { }, []) const saveReservation = () => { - + let _reservations = [...reservations]; let _reservation = { ...reservation }; - if (_reservation.date && _reservation.time && tenantId && areaId && !validationTime()) { + if (!validationIsReservation() && _reservation.date && _reservation.time && tenantId && areaId && !validationTime()) { _reservation.common_area_name = areas.find(item => item._id == areaId).name; let tenant = tenants.find(item => item._id == tenantId); _reservation.user_name = tenant.name + ' ' + tenant.last_name; @@ -147,34 +149,35 @@ const Reservations = () => { _reservation.status_text = 'Inactivo'; } console.log(_reservation) - fetch('http://localhost:4000/reservation/createReservation/', { - cache: 'no-cache', - method: 'POST', - body: JSON.stringify(_reservation), - headers: { - 'Content-Type': 'application/json' - } - }) - .then((response) => { - if (response.status !== 200 && response.status !== 201 ) - console.log(`Hubo un error en el servicio: ${response.status}`) - else return response.json() - }).then(() => { - _reservations.push(_reservation); - setReservations(_reservations) - toast.current.show({ - severity: 'success', - summary: 'Éxito', - detail: 'Reservación realizada', - life: 3000, - }); - - setReservationDialog(false) - }) + + /* fetch('http://localhost:4000/reservation/createReservation/', { + cache: 'no-cache', + method: 'POST', + body: JSON.stringify(_reservation), + headers: { + 'Content-Type': 'application/json' + } + }) + .then((response) => { + if (response.status !== 200 && response.status !== 201 ) + console.log(`Hubo un error en el servicio: ${response.status}`) + else return response.json() + }).then(() => {*/ + _reservations.push(_reservation); + setReservations(_reservations) + toast.current.show({ + severity: 'success', + summary: 'Éxito', + detail: 'Reservación realizada', + life: 3000, + }); + + setReservationDialog(false) + /*})*/ + - } else { setSubmitted(true); } @@ -363,6 +366,16 @@ const Reservations = () => { setReservation(_reservation); }; + const onTimeChange = (e) => { + e.target.value.split(':')[1] = "00"; + const val = (e.target && e.target.value.split(':')[0]) || ''; + let _reservation = { ...reservation }; + document.getElementById('time').value = val + ":00"; + _reservation['time'] = val + ":00"; + setReservation(_reservation); + + }; + const handleAreas = (e) => { const getAreaId = e.target.value; setAreaId(getAreaId); @@ -419,11 +432,21 @@ const Reservations = () => { } function formatDateString(dateString) { - const [date, time] = timeString.split('T'); + const [date, time] = dateString.split('T'); return date; } + function validationIsReservation() { + let booked = reservations.filter(item => item.common_area_id == areaId && item.date == reservation.date && item.time == reservation.time); + if (booked.length > 0) { + return true; + + } else { + return false; + } + } + return (
@@ -567,7 +590,8 @@ const Reservations = () => { lang='es' value={reservation.date} className={classNames({ - 'p-invalid': submitted && reservation.date === '', + 'p-invalid': submitted && (reservation.date === '' + || validationIsReservation()), })} /> @@ -575,6 +599,7 @@ const Reservations = () => { {submitted && reservation.date === '' && ( Fecha es requirida. )} +
@@ -588,13 +613,14 @@ const Reservations = () => { onInputChange(e, 'time')} + onChange={(e) => onTimeChange(e)} required autoFocus type="time" step='3600' className={classNames({ - 'p-invalid': submitted && (reservation.time === '' || validationTime()), + 'p-invalid': submitted && (reservation.time === '' + || validationTime() || validationIsReservation()), })} />
@@ -602,9 +628,11 @@ const Reservations = () => { Hora es requirido. )} {submitted && validationTime() && ( - La hora de inicio debe set mayor de {area.hourMin} y menor de {area.hourMax} . + La hora de inicio debe ser mayor de {area.hourMin} y menor de {area.hourMax} . + )} + {submitted && validationIsReservation() && ( + Ya hay una reservación en la fecha y hora ingresada. )} -
From 5a2f0846d8764be3b2a0327c6411adcca69f558d Mon Sep 17 00:00:00 2001 From: Mariela Date: Fri, 26 Aug 2022 13:44:00 -0600 Subject: [PATCH 32/55] descomentar fetch de registro --- .../web-react/src/components/Reservaciones.js | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/web-ui/web-react/src/components/Reservaciones.js b/web-ui/web-react/src/components/Reservaciones.js index 8e5dfb79..5c284385 100644 --- a/web-ui/web-react/src/components/Reservaciones.js +++ b/web-ui/web-react/src/components/Reservaciones.js @@ -150,30 +150,30 @@ const Reservations = () => { } console.log(_reservation) - /* fetch('http://localhost:4000/reservation/createReservation/', { - cache: 'no-cache', - method: 'POST', - body: JSON.stringify(_reservation), - headers: { - 'Content-Type': 'application/json' - } - }) - .then((response) => { - if (response.status !== 200 && response.status !== 201 ) - console.log(`Hubo un error en el servicio: ${response.status}`) - else return response.json() - }).then(() => {*/ - _reservations.push(_reservation); - setReservations(_reservations) - toast.current.show({ - severity: 'success', - summary: 'Éxito', - detail: 'Reservación realizada', - life: 3000, - }); + fetch('http://localhost:4000/reservation/createReservation/', { + cache: 'no-cache', + method: 'POST', + body: JSON.stringify(_reservation), + headers: { + 'Content-Type': 'application/json' + } + }) + .then((response) => { + if (response.status !== 200 && response.status !== 201) + console.log(`Hubo un error en el servicio: ${response.status}`) + else return response.json() + }).then(() => { + _reservations.push(_reservation); + setReservations(_reservations) + toast.current.show({ + severity: 'success', + summary: 'Éxito', + detail: 'Reservación realizada', + life: 3000, + }); - setReservationDialog(false) - /*})*/ + setReservationDialog(false) + }) @@ -440,13 +440,13 @@ const Reservations = () => { let booked = reservations.filter(item => item.common_area_id == areaId && item.date == reservation.date && item.time == reservation.time); if (booked.length > 0) { return true; - + } else { return false; } } - + return (
@@ -590,8 +590,8 @@ const Reservations = () => { lang='es' value={reservation.date} className={classNames({ - 'p-invalid': submitted && (reservation.date === '' - || validationIsReservation()), + 'p-invalid': submitted && (reservation.date === '' + || validationIsReservation()), })} /> @@ -599,7 +599,7 @@ const Reservations = () => { {submitted && reservation.date === '' && ( Fecha es requirida. )} - +
@@ -619,8 +619,8 @@ const Reservations = () => { type="time" step='3600' className={classNames({ - 'p-invalid': submitted && (reservation.time === '' - || validationTime() || validationIsReservation()), + 'p-invalid': submitted && (reservation.time === '' + || validationTime() || validationIsReservation()), })} />
From 1b99458b7dd26bc789c084182fded662c6936e0b Mon Sep 17 00:00:00 2001 From: Mariela Date: Fri, 26 Aug 2022 17:13:18 -0600 Subject: [PATCH 33/55] formateo de fechas y eliminar impresiones innecesarias --- .../src/reservations/reservations.service.ts | 2 -- web-ui/web-react/public/index.html | 2 +- web-ui/web-react/src/AppFooter.js | 4 ++-- .../web-react/src/components/Reservaciones.js | 19 +++---------------- 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/servicio-reservaciones/src/reservations/reservations.service.ts b/servicio-reservaciones/src/reservations/reservations.service.ts index ce338270..a7ab73d2 100644 --- a/servicio-reservaciones/src/reservations/reservations.service.ts +++ b/servicio-reservaciones/src/reservations/reservations.service.ts @@ -14,8 +14,6 @@ export class ReservationsService { ) {} create(reservation: ReservationDocument) { - console.log(reservation); - return this.reservationModel.create(reservation); } diff --git a/web-ui/web-react/public/index.html b/web-ui/web-react/public/index.html index 72e2d161..69324c7a 100644 --- a/web-ui/web-react/public/index.html +++ b/web-ui/web-react/public/index.html @@ -1,5 +1,5 @@ - + Katoikia diff --git a/web-ui/web-react/src/AppFooter.js b/web-ui/web-react/src/AppFooter.js index fb9f6951..71548902 100644 --- a/web-ui/web-react/src/AppFooter.js +++ b/web-ui/web-react/src/AppFooter.js @@ -13,8 +13,8 @@ export const AppFooter = (props) => { height="20" className="mr-2" /> - by - PrimeReact + por + Deimos
); }; diff --git a/web-ui/web-react/src/components/Reservaciones.js b/web-ui/web-react/src/components/Reservaciones.js index 5c284385..e002be63 100644 --- a/web-ui/web-react/src/components/Reservaciones.js +++ b/web-ui/web-react/src/components/Reservaciones.js @@ -49,7 +49,6 @@ const Reservations = () => { const [reservationDialog, setReservationDialog] = useState(false); - async function tenantsList(id) { await fetch(`http://localhost:4000/user/findTenants/${id}`, { method: 'GET' }) @@ -148,8 +147,6 @@ const Reservations = () => { } else if (_reservation.status == '0') { _reservation.status_text = 'Inactivo'; } - console.log(_reservation) - fetch('http://localhost:4000/reservation/createReservation/', { cache: 'no-cache', method: 'POST', @@ -174,19 +171,12 @@ const Reservations = () => { setReservationDialog(false) }) - - - - } else { setSubmitted(true); } } - - + const actionsReservation = (rowData) => { - - return (
From 2ff3db6615445360a445c68400340a9717c31d8e Mon Sep 17 00:00:00 2001 From: Mariela Date: Sun, 28 Aug 2022 01:58:57 -0600 Subject: [PATCH 35/55] dialogos y funciones eliminar reserva --- .../web-react/src/components/Reservaciones.js | 180 ++++++++++++++++-- 1 file changed, 165 insertions(+), 15 deletions(-) diff --git a/web-ui/web-react/src/components/Reservaciones.js b/web-ui/web-react/src/components/Reservaciones.js index 8b570531..05b4aa21 100644 --- a/web-ui/web-react/src/components/Reservaciones.js +++ b/web-ui/web-react/src/components/Reservaciones.js @@ -94,7 +94,7 @@ const Reservations = () => { ) data.map((item) => { - item.date = formatDateString(item.date) + item.date = formatDateString(item.date) if (item.status == '1') { item.status_text = 'Activo'; @@ -134,7 +134,7 @@ const Reservations = () => { let _reservation = { ...reservation }; if (_reservation.date && _reservation.time && tenantId && areaId - && !validationTime() + && !validationTime() && !validationIsSameUser() && !validationIsReservation()) { _reservation.common_area_name = areas.find(item => item._id == areaId).name; let tenant = tenants.find(item => item._id == tenantId); @@ -175,7 +175,7 @@ const Reservations = () => { setAreaId('') setTenantId('') }) - + } else { setSubmitted(true); } @@ -222,7 +222,83 @@ const Reservations = () => { setReservation(emptyReservation); setReservationDialog(true); setSubmitted(false); + }; + + + const hideDeleteReservationDialog = () => { + setDeleteReservationDialog(false); + }; + + const hideDeleteReservationsDialog = () => { + setDeleteReservationsDialog(false); + }; + + + const deleteReservation = () => { + fetch('http://localhost:4000/reservation/deleteReservation' + reservation._id, { + cache: 'no-cache', + method: 'DELETE', + headers: { + 'Content-Type': 'application/json', + }, + }) + .then(function (response) { + if (response.status != 201) + console.log('Ocurrió un error con el servicio: ' + response.status); + else return response.json(); + }) + .then(function (response) { + let _reservation = reservations.filter( + (val) => (val._id !== reservation._id || val.status != -1), + ); + + setReservations(_reservation); + setDeleteReservationDialog(false); + setReservation(emptyReservation); + toast.current.show({ + severity: 'success', + summary: 'Éxito', + detail: 'Reservación Eliminada', + life: 3000, + }); + }) + .catch((err) => { + console.log('Ocurrió un error con el fetch', err); + toast.current.show({ + severity: 'danger', + summary: 'Error', + detail: 'Reservación no se pudo Eliminar', + life: 3000, + }); + }); + }; + + const deleteSelectedReservations = () => { + let _reservations = reservations.filter( + (val) => (!selectedReservations.includes(val)), + ); + selectedReservations.map((item) => { + fetch('http://localhost:4000/reservation/deleteReservation/' + item._id, { + cache: 'no-cache', + method: 'DELETE', + headers: { + 'Content-Type': 'application/json', + }, + }); + }); + _reservations = _reservations.filter( + (val) => val.status != -1, + ) + setReservations(_reservations); + setDeleteReservationsDialog(false); + setSelectedReservations(null); + toast.current.show({ + severity: 'success', + summary: 'Éxito', + detail: 'Reservaciones Eliminadas', + life: 3000, + }); }; const leftToolbarTemplate = () => { @@ -272,6 +348,40 @@ const Reservations = () => { ); + const deleteReservationDialogFooter = ( + <> +
From c619cc396ad5c4a188118a77eb2a4ba85a2fc34b Mon Sep 17 00:00:00 2001 From: Mariela Date: Sun, 28 Aug 2022 02:02:02 -0600 Subject: [PATCH 36/55] fix api --- api-gateway/src/app.controller.ts | 39 +++++------------------- api-gateway/src/app.service.ts | 49 +++++++------------------------ 2 files changed, 17 insertions(+), 71 deletions(-) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index f6bf3ab0..5066563a 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -468,38 +468,7 @@ export class AppController { } - // #==== API Payment - - @Post('payment/createPayment') - createPayment( - @Body('date_payment') date_payment: Date, - @Body('mount') mount: number, - @Body('description') description: string, - @Body('period') period: string, - @Body('status') status: string, - @Body('user_id') user_id: string, - @Body('communty_id') communty_id: string, - ) { - return this.appService.createPayment( - date_payment, - mount, - description, - period, - status, - user_id, - communty_id, - ); - } - - @Get('payment/allPayments') - allPayments() { - return this.appService.allPayments(); - } - - @Get('payment/find/:dni') - findPayment(@Param('dni') paramPaymentDNI: string) { - return this.appService.findPayment(paramPaymentDNI); - } + // #==== API Reservation @@ -541,6 +510,12 @@ export class AppController { return this.appService.findReservations(community_id); } + + @Delete('reservation/deleteReservation/:id') + deleteReservation(@Param('id') id: string) { + return this.appService.deleteReservation(id); + } + // #==== API Post diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 380e23d1..970b061e 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -571,45 +571,7 @@ export class AppService { .send(pattern, payload) .pipe(map((message: string) => ({ message }))); } - // ====================== PAYMENTS =============================== - - //POST parameter from API - createPayment( - date_payment: Date, - mount: number, - description: string, - period: string, - status: string, - user_id: string, - communty_id: string, - ) { - const pattern = { cmd: 'createPayment' }; - const payload = { - date_payment: date_payment, mount: mount, description: description, - period: period, status: status, user_id: user_id, communty_id: communty_id - }; - return this.clientPaymentApp - .send(pattern, payload) - .pipe(map((message: string) => ({ message }))); - } - - allPayments() { - const pattern = { cmd: 'findAllPayments' }; - const payload = {}; - return this.clientPaymentApp - .send(pattern, payload) - .pipe(map((message: string) => ({ message }))); - } - - //GET parameter from API - findPayment(paramPaymentId: string) { - const pattern = { cmd: 'findOnePayment' }; - const payload = { id: paramPaymentId }; - return this.clientPaymentApp - .send(pattern, payload) - .pipe(map((message: string) => ({ message }))); - } - + // ====================== RESERVATIONS =============================== //POST parameter from API @@ -652,6 +614,15 @@ export class AppService { .pipe(map((message: string) => ({ message }))); } + //DELETE parameter from API + deleteReservation(paramReservationId: string) { + const pattern = { cmd: 'removeReservation' }; + const payload = { id: paramReservationId }; + return this.clientReservationApp + .send(pattern, payload) + .pipe(map((message: string) => ({ message }))); + } + // ====================== POSTS =============================== //POST parameter from API From a44f28f2fb5df00b0b943819c01bd5ab825dee96 Mon Sep 17 00:00:00 2001 From: Mariela Date: Sun, 28 Aug 2022 10:06:17 -0600 Subject: [PATCH 37/55] areglar elimianr reserva de inquilino y otros detalles del crear --- .../web-react/src/components/Reservaciones.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/web-ui/web-react/src/components/Reservaciones.js b/web-ui/web-react/src/components/Reservaciones.js index 05b4aa21..2eb9a73d 100644 --- a/web-ui/web-react/src/components/Reservaciones.js +++ b/web-ui/web-react/src/components/Reservaciones.js @@ -142,7 +142,7 @@ const Reservations = () => { _reservation.user_id = tenantId; _reservation.common_area_id = areaId; _reservation.community_id = cookies.community_id; - _reservation.date = formatDateString(_reservation.date) + if (_reservation.status == '1') { _reservation.status_text = 'Activo'; @@ -161,8 +161,10 @@ const Reservations = () => { if (response.status !== 200 && response.status !== 201) console.log(`Hubo un error en el servicio: ${response.status}`) else return response.json() - }).then(() => { - _reservations.push(_reservation); + }).then((response) => { + let _r = response.message; + _r.date = formatDateString(_r.date) + _reservations.push(_r); setReservations(_reservations) toast.current.show({ severity: 'success', @@ -236,7 +238,9 @@ const Reservations = () => { const deleteReservation = () => { - fetch('http://localhost:4000/reservation/deleteReservation' + reservation._id, { + + + fetch('http://localhost:4000/reservation/deleteReservation/' + reservation._id, { cache: 'no-cache', method: 'DELETE', headers: { @@ -244,13 +248,13 @@ const Reservations = () => { }, }) .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(); }) .then(function (response) { let _reservation = reservations.filter( - (val) => (val._id !== reservation._id || val.status != -1), + (val) => (val._id !== reservation._id), ); setReservations(_reservation); @@ -809,7 +813,7 @@ const Reservations = () => { )} Date: Sun, 28 Aug 2022 10:08:21 -0600 Subject: [PATCH 38/55] fix const duplicated --- web-ui/web-react/src/components/Reservaciones.js | 1 - 1 file changed, 1 deletion(-) diff --git a/web-ui/web-react/src/components/Reservaciones.js b/web-ui/web-react/src/components/Reservaciones.js index 9aa6db02..84764a23 100644 --- a/web-ui/web-react/src/components/Reservaciones.js +++ b/web-ui/web-react/src/components/Reservaciones.js @@ -48,7 +48,6 @@ const Reservations = () => { const [saveButtonTitle, setSaveButtonTitle] = useState("Registrar") const [reservationDialog, setReservationDialog] = useState(false); const [dateMax, setDateMax] = useState(); - const [tenants, setTenants] = useState([]); async function tenantsList(id) { From d5c26c703d15865d5a1ccd917e843177f68d9455 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Mon, 29 Aug 2022 00:06:27 -0600 Subject: [PATCH 39/55] fix table headers --- .../src/components/InvitadosComunidad.js | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/web-ui/web-react/src/components/InvitadosComunidad.js b/web-ui/web-react/src/components/InvitadosComunidad.js index 099f1849..4e59b24f 100644 --- a/web-ui/web-react/src/components/InvitadosComunidad.js +++ b/web-ui/web-react/src/components/InvitadosComunidad.js @@ -72,6 +72,15 @@ const InvitadosComunidad = () => { ); + const headerTenant = ( + <> +

+ {' '} + Inquilino +

+ + ); + const headerLastName = ( <>

@@ -82,6 +91,14 @@ const InvitadosComunidad = () => { ); + const headerPlate = ( +

+ {' '} + {' '} + Placa +

+ ); + const headerDNI = (

{' '} @@ -166,7 +183,7 @@ const InvitadosComunidad = () => { field="number_plate" header="Placa" sortable - header={headerDNI} + header={headerPlate} /> { field="tenant_name" header="Inquilino" sortable - header={headerName} + header={headerTenant} />

From 99788e7121fd0256a936b616b66dbcac954d69d7 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 30 Aug 2022 00:33:49 -0600 Subject: [PATCH 40/55] fix typo --- web-ui/web-react/src/components/RegistroComunicado.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-ui/web-react/src/components/RegistroComunicado.js b/web-ui/web-react/src/components/RegistroComunicado.js index fbe91808..c6057519 100644 --- a/web-ui/web-react/src/components/RegistroComunicado.js +++ b/web-ui/web-react/src/components/RegistroComunicado.js @@ -167,7 +167,7 @@ const RegistroComunicado = () => { >
- {comunicado && ¿Estás seguro que desea eliminar el aviso "{comunicado.post}"?} + {comunicado && ¿Está seguro que desea eliminar el aviso "{comunicado.post}"?}
From a1023fda37d92816f9c4bacd954dc48e2aa95643 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 30 Aug 2022 04:03:09 -0600 Subject: [PATCH 41/55] parameterize button label --- .../src/components/RegistroComunicado.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/web-ui/web-react/src/components/RegistroComunicado.js b/web-ui/web-react/src/components/RegistroComunicado.js index c6057519..7b4452b8 100644 --- a/web-ui/web-react/src/components/RegistroComunicado.js +++ b/web-ui/web-react/src/components/RegistroComunicado.js @@ -29,6 +29,7 @@ const RegistroComunicado = () => { const [comunicado, setComunicado] = useState(emptyComunicado); const [comunicados, setComunicados] = useState([]); + const [saveButtonLabel, setSaveButtonLabel] = useState('Registrar'); const [comunicadoId, setComunicadoId] = useState(null); const [showDeleteDialog, setShowDeleteDialog] = useState(false); const [submitted, setSubmitted] = useState(false); @@ -204,7 +205,22 @@ const RegistroComunicado = () => {
- - - - ); From 30e559daaf3425d76abd5e89497e086be33d5483 Mon Sep 17 00:00:00 2001 From: Mariela Date: Tue, 30 Aug 2022 23:11:34 -0600 Subject: [PATCH 52/55] 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(); }) From 6668d70cfbb281e86583c305983f128f308d42f1 Mon Sep 17 00:00:00 2001 From: Mariela Date: Wed, 31 Aug 2022 00:41:13 -0600 Subject: [PATCH 53/55] =?UTF-8?q?informaci=C3=B3n=20b=C3=A1sica=20de=20la?= =?UTF-8?q?=20comunidad?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web-ui/web-react/src/App.js | 2 + web-ui/web-react/src/AppTopbar.js | 5 +- .../src/components/PerfilAdminComunidad.js | 287 ++++++++++++++++++ 3 files changed, 292 insertions(+), 2 deletions(-) create mode 100644 web-ui/web-react/src/components/PerfilAdminComunidad.js diff --git a/web-ui/web-react/src/App.js b/web-ui/web-react/src/App.js index 48ea0ccd..efa23d58 100644 --- a/web-ui/web-react/src/App.js +++ b/web-ui/web-react/src/App.js @@ -58,6 +58,7 @@ import { useCookies } from "react-cookie"; import LogInUser from './components/LogInUser'; import Page404 from './components/Page404' import Reservaciones from './components/Reservaciones'; +import PerfilAdminComunidad from './components/PerfilAdminComunidad'; const App = () => { @@ -472,6 +473,7 @@ const App = () => { + ) } else { diff --git a/web-ui/web-react/src/AppTopbar.js b/web-ui/web-react/src/AppTopbar.js index f9226f50..122d6ef7 100644 --- a/web-ui/web-react/src/AppTopbar.js +++ b/web-ui/web-react/src/AppTopbar.js @@ -88,10 +88,11 @@ export const AppTopbar = (props) => { */}