From a44f28f2fb5df00b0b943819c01bd5ab825dee96 Mon Sep 17 00:00:00 2001 From: Mariela Date: Sun, 28 Aug 2022 10:06:17 -0600 Subject: [PATCH] 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 = () => { )}