diff --git a/pages/api/cancel.ts b/pages/api/cancel.ts index 1929609383..e2a5df0e22 100644 --- a/pages/api/cancel.ts +++ b/pages/api/cancel.ts @@ -21,7 +21,7 @@ export default async function handler(req, res) { } }); - await deleteEvent(bookingToDelete.user.credentials[0], uid); + const credentials = bookingToDelete.user.credentials[0]; await prisma.attendee.deleteMany({ where: { @@ -35,7 +35,6 @@ export default async function handler(req, res) { } }); - //TODO Delete booking from calendar integrations //TODO Perhaps send emails to user and client to tell about the cancellation const deleteBooking = await prisma.booking.delete({ @@ -44,6 +43,8 @@ export default async function handler(req, res) { }, }); + await deleteEvent(credentials, uid); + res.status(200).json({message: 'Booking deleted successfully'}); } } \ No newline at end of file