Skip to content

Commit

Permalink
Merge pull request #52 from untilhamza:release/v1.10.0
Browse files Browse the repository at this point in the history
Release/v1.10.0
  • Loading branch information
untilhamza committed Mar 18, 2023
2 parents a0cdcc6 + 550930c commit 9f9d93b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/hooks/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ async function httpCheckBooking(phoneNumber) {
}
}


//load bookings for given date as json
async function httpGetBookings(dateMoment) {
try {
Expand Down Expand Up @@ -284,13 +283,15 @@ async function httpSubmitBooking(bookingData) {
status: "confirmed",
};

await uploadSlot(slot);
//alert(JSON.stringify({ ...bookingData, ...slot }));

const response = await addDoc(bookingsCollectionRef, {
...bookingData,
...slot,
});

await uploadSlot(slot);

//pull out the id that was returned here...
return response.id;
} else {
Expand Down Expand Up @@ -324,18 +325,23 @@ async function httpCancelBooking(id) {
//get reference to booking to be deleted
const bookingDocRef = doc(db, "bookings", id);

let bookingSnap = await getDoc(bookingDocRef);

let firebaseTimeStamp = bookingSnap.data().date;
await deleteRemoteSlot(firebaseTimeStamp, "confirmed");

//will update the status field on the booking to being updated...
const newFields = { status: "cancelled" };

//mark booking as deleted in database
await updateDoc(bookingDocRef, newFields);

let bookingSnap = await getDoc(bookingDocRef);
bookingSnap = await getDoc(bookingDocRef);

if (bookingSnap.exists()) {
//delete slot for this booking from blocked and confirmed slot collection
let firebaseTimeStamp = bookingSnap.data().date;
await deleteRemoteSlot(firebaseTimeStamp, "confirmed");
// let firebaseTimeStamp = bookingSnap.data().date;
// await deleteRemoteSlot(firebaseTimeStamp, "confirmed");
} else {
//TODO: stop transaction....
throw new Error("The booking you are attempting to cancel was not found!");
Expand Down
2 changes: 1 addition & 1 deletion src/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "1.9.0"
"version": "1.10.0"
}

0 comments on commit 9f9d93b

Please sign in to comment.