From bd79c3a6a84f926ec5cc172ee1b0b4f5dfdd3acb Mon Sep 17 00:00:00 2001 From: Mariela Date: Fri, 26 Aug 2022 00:30:47 -0600 Subject: [PATCH] =?UTF-8?q?agregar=20dialogo=20para=20agregar=20y=20valida?= =?UTF-8?q?ciones=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 = ( + <> +