diff --git a/apps/web/components/booking/CancelBooking.tsx b/apps/web/components/booking/CancelBooking.tsx index dece688720..ede84d6199 100644 --- a/apps/web/components/booking/CancelBooking.tsx +++ b/apps/web/components/booking/CancelBooking.tsx @@ -86,7 +86,7 @@ export default function CancelBooking(props: Props) { const res = await fetch("/api/cancel", { body: JSON.stringify({ - id: booking?.id, + uid: booking?.uid, cancellationReason: cancellationReason, allRemainingBookings, // @NOTE: very important this shouldn't cancel with number ID use uid instead diff --git a/packages/features/bookings/lib/handleCancelBooking.ts b/packages/features/bookings/lib/handleCancelBooking.ts index 3c91f3b742..ab2cc124fd 100644 --- a/packages/features/bookings/lib/handleCancelBooking.ts +++ b/packages/features/bookings/lib/handleCancelBooking.ts @@ -1,4 +1,4 @@ -import type { WebhookTriggerEvents, WorkflowReminder } from "@prisma/client"; +import type { WebhookTriggerEvents, WorkflowReminder, Prisma } from "@prisma/client"; import { BookingStatus, MembershipRole, WorkflowMethods } from "@prisma/client"; import type { NextApiRequest } from "next"; @@ -266,10 +266,13 @@ async function handler(req: CustomRequest) { await Promise.all(integrationsToDelete).then(async () => { if (lastAttendee) { - await prisma.booking.delete({ + await prisma.booking.update({ where: { id: bookingToDelete.id, }, + data: { + status: BookingStatus.CANCELLED, + }, }); } }); @@ -388,11 +391,11 @@ async function handler(req: CustomRequest) { }, }); } + + const where: Prisma.BookingWhereUniqueInput = uid ? { uid } : { id }; + const updatedBooking = await prisma.booking.update({ - where: { - id, - uid, - }, + where, data: { status: BookingStatus.CANCELLED, cancellationReason: cancellationReason,