No delete of booking on seated events, fix id->uid (#7839)

* No delete of booking on seated events, fix id->uid

* Use uid or id
pull/7879/head
Alex van Andel 2023-03-20 19:30:00 +01:00 committed by GitHub
parent 19bc329377
commit 1cd96d4c25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -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

View File

@ -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,