descomentar fetch de registro

This commit is contained in:
Mariela 2022-08-26 13:44:00 -06:00
parent ac80892afb
commit 5a2f0846d8
1 changed files with 30 additions and 30 deletions

View File

@ -150,30 +150,30 @@ const Reservations = () => {
} }
console.log(_reservation) console.log(_reservation)
/* fetch('http://localhost:4000/reservation/createReservation/', { fetch('http://localhost:4000/reservation/createReservation/', {
cache: 'no-cache', cache: 'no-cache',
method: 'POST', method: 'POST',
body: JSON.stringify(_reservation), body: JSON.stringify(_reservation),
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
}) })
.then((response) => { .then((response) => {
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(() => {
_reservations.push(_reservation); _reservations.push(_reservation);
setReservations(_reservations) setReservations(_reservations)
toast.current.show({ toast.current.show({
severity: 'success', severity: 'success',
summary: 'Éxito', summary: 'Éxito',
detail: 'Reservación realizada', detail: 'Reservación realizada',
life: 3000, life: 3000,
}); });
setReservationDialog(false) setReservationDialog(false)
/*})*/ })
@ -440,13 +440,13 @@ const Reservations = () => {
let booked = reservations.filter(item => item.common_area_id == areaId && item.date == reservation.date && item.time == reservation.time); let booked = reservations.filter(item => item.common_area_id == areaId && item.date == reservation.date && item.time == reservation.time);
if (booked.length > 0) { if (booked.length > 0) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
return ( return (
<div className="grid"> <div className="grid">
@ -590,8 +590,8 @@ const Reservations = () => {
lang='es' lang='es'
value={reservation.date} value={reservation.date}
className={classNames({ className={classNames({
'p-invalid': submitted && (reservation.date === '' 'p-invalid': submitted && (reservation.date === ''
|| validationIsReservation()), || validationIsReservation()),
})} })}
/> />
@ -599,7 +599,7 @@ const Reservations = () => {
{submitted && reservation.date === '' && ( {submitted && reservation.date === '' && (
<small className="p-invalid">Fecha es requirida.</small> <small className="p-invalid">Fecha es requirida.</small>
)} )}
</div> </div>
</div> </div>
@ -619,8 +619,8 @@ const Reservations = () => {
type="time" type="time"
step='3600' step='3600'
className={classNames({ className={classNames({
'p-invalid': submitted && (reservation.time === '' 'p-invalid': submitted && (reservation.time === ''
|| validationTime() || validationIsReservation()), || validationTime() || validationIsReservation()),
})} })}
/> />
</div> </div>