From 2c2e54bd1977c98a2095797e3a254db108b37bcb Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 23 Aug 2022 02:37:06 -0600 Subject: [PATCH 01/26] 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 02/26] 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 03/26] 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 04/26] 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 05/26] 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 06/26] 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 10/26] 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 (
From c619cc396ad5c4a188118a77eb2a4ba85a2fc34b Mon Sep 17 00:00:00 2001 From: Mariela Date: Sun, 28 Aug 2022 02:02:02 -0600 Subject: [PATCH 13/26] 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 14/26] 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 15/26] 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 16/26] 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 17/26] 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 18/26] 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 = () => { -