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 = ( + <> +