@@ -175,7 +175,6 @@ async function httpCheckBooking(phoneNumber) {
175
175
}
176
176
}
177
177
178
-
179
178
//load bookings for given date as json
180
179
async function httpGetBookings ( dateMoment ) {
181
180
try {
@@ -284,13 +283,15 @@ async function httpSubmitBooking(bookingData) {
284
283
status : "confirmed" ,
285
284
} ;
286
285
287
- await uploadSlot ( slot ) ;
286
+ //alert(JSON.stringify({ ...bookingData, ... slot }) );
288
287
289
288
const response = await addDoc ( bookingsCollectionRef , {
290
289
...bookingData ,
291
290
...slot ,
292
291
} ) ;
293
292
293
+ await uploadSlot ( slot ) ;
294
+
294
295
//pull out the id that was returned here...
295
296
return response . id ;
296
297
} else {
@@ -324,18 +325,23 @@ async function httpCancelBooking(id) {
324
325
//get reference to booking to be deleted
325
326
const bookingDocRef = doc ( db , "bookings" , id ) ;
326
327
328
+ let bookingSnap = await getDoc ( bookingDocRef ) ;
329
+
330
+ let firebaseTimeStamp = bookingSnap . data ( ) . date ;
331
+ await deleteRemoteSlot ( firebaseTimeStamp , "confirmed" ) ;
332
+
327
333
//will update the status field on the booking to being updated...
328
334
const newFields = { status : "cancelled" } ;
329
335
330
336
//mark booking as deleted in database
331
337
await updateDoc ( bookingDocRef , newFields ) ;
332
338
333
- let bookingSnap = await getDoc ( bookingDocRef ) ;
339
+ bookingSnap = await getDoc ( bookingDocRef ) ;
334
340
335
341
if ( bookingSnap . exists ( ) ) {
336
342
//delete slot for this booking from blocked and confirmed slot collection
337
- let firebaseTimeStamp = bookingSnap . data ( ) . date ;
338
- await deleteRemoteSlot ( firebaseTimeStamp , "confirmed" ) ;
343
+ // let firebaseTimeStamp = bookingSnap.data().date;
344
+ // await deleteRemoteSlot(firebaseTimeStamp, "confirmed");
339
345
} else {
340
346
//TODO: stop transaction....
341
347
throw new Error ( "The booking you are attempting to cancel was not found!" ) ;
0 commit comments