From 2c2e54bd1977c98a2095797e3a254db108b37bcb Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Tue, 23 Aug 2022 02:37:06 -0600 Subject: [PATCH 01/12] 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/12] 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/12] 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/12] 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/12] 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/12] 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/12] 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 (