areglar elimianr reserva de inquilino y otros detalles del crear

This commit is contained in:
Mariela 2022-08-28 10:06:17 -06:00
parent c619cc396a
commit a44f28f2fb
1 changed files with 11 additions and 7 deletions

View File

@ -142,7 +142,7 @@ const Reservations = () => {
_reservation.user_id = tenantId; _reservation.user_id = tenantId;
_reservation.common_area_id = areaId; _reservation.common_area_id = areaId;
_reservation.community_id = cookies.community_id; _reservation.community_id = cookies.community_id;
_reservation.date = formatDateString(_reservation.date)
if (_reservation.status == '1') { if (_reservation.status == '1') {
_reservation.status_text = 'Activo'; _reservation.status_text = 'Activo';
@ -161,8 +161,10 @@ const Reservations = () => {
if (response.status !== 200 && response.status !== 201) if (response.status !== 200 && response.status !== 201)
console.log(`Hubo un error en el servicio: ${response.status}`) console.log(`Hubo un error en el servicio: ${response.status}`)
else return response.json() else return response.json()
}).then(() => { }).then((response) => {
_reservations.push(_reservation); let _r = response.message;
_r.date = formatDateString(_r.date)
_reservations.push(_r);
setReservations(_reservations) setReservations(_reservations)
toast.current.show({ toast.current.show({
severity: 'success', severity: 'success',
@ -236,7 +238,9 @@ const Reservations = () => {
const deleteReservation = () => { const deleteReservation = () => {
fetch('http://localhost:4000/reservation/deleteReservation' + reservation._id, {
fetch('http://localhost:4000/reservation/deleteReservation/' + reservation._id, {
cache: 'no-cache', cache: 'no-cache',
method: 'DELETE', method: 'DELETE',
headers: { headers: {
@ -244,13 +248,13 @@ const Reservations = () => {
}, },
}) })
.then(function (response) { .then(function (response) {
if (response.status != 201) if (response.status != 201 || response.status != 200)
console.log('Ocurrió un error con el servicio: ' + response.status); console.log('Ocurrió un error con el servicio: ' + response.status);
else return response.json(); else return response.json();
}) })
.then(function (response) { .then(function (response) {
let _reservation = reservations.filter( let _reservation = reservations.filter(
(val) => (val._id !== reservation._id || val.status != -1), (val) => (val._id !== reservation._id),
); );
setReservations(_reservation); setReservations(_reservation);
@ -809,7 +813,7 @@ const Reservations = () => {
)} )}
</Dialog> </Dialog>
<Dialog <Dialog
visible={deleteReservationsDialog} visible={deleteReservationDialog}
style={{ width: '450px' }} style={{ width: '450px' }}
header="Confirmar" header="Confirmar"
modal modal