Fix booking update and reactivity
All checks were successful
Build BAB Application Deployment Artifact / build (push) Successful in 2m28s

This commit is contained in:
2024-06-02 10:08:57 -04:00
parent 9104ccab0f
commit b2420b270c
3 changed files with 51 additions and 17 deletions

View File

@@ -221,9 +221,9 @@ const onSubmit = async () => {
)
) {
// TODO: Make a proper validator
return;
return false;
}
const reservation = <Reservation>{
const newReservation = <Reservation>{
resource: booking.interval.resource,
start: booking.interval.start,
end: booking.interval.end,
@@ -231,6 +231,7 @@ const onSubmit = async () => {
status: 'confirmed',
reason: booking.reason,
comment: booking.comment,
$id: reservation.value?.$id,
};
const status = $q.notify({
color: 'secondary',
@@ -243,11 +244,11 @@ const onSubmit = async () => {
group: false,
});
try {
const r = await reservationStore.createReservation(reservation);
const r = await reservationStore.createOrUpdateReservation(newReservation);
status({
color: 'positive',
icon: 'cloud_done',
message: `Booking successful: ${
message: `Booking ${newReservation.$id ? 'updated' : 'created'}: ${
boatStore.getBoatById(r.resource)?.name
} at ${formatDate(r.start)}`,
spinner: false,