diff --git a/pages/api/book/confirm.ts b/pages/api/book/confirm.ts index d7440d1df0..ea35cf831d 100644 --- a/pages/api/book/confirm.ts +++ b/pages/api/book/confirm.ts @@ -1,4 +1,4 @@ -import { User, Booking, SchedulingType } from "@prisma/client"; +import { User, Booking, SchedulingType, BookingStatus } from "@prisma/client"; import type { NextApiRequest, NextApiResponse } from "next"; import { refund } from "@ee/lib/stripe/server"; @@ -146,6 +146,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) }, data: { rejected: true, + status: BookingStatus.REJECTED, }, }); const attendeeMail = new EventRejectionMail(evt); diff --git a/prisma/migrations/20211101151249_update_rejected_bookings/migration.sql b/prisma/migrations/20211101151249_update_rejected_bookings/migration.sql new file mode 100644 index 0000000000..a170caecf3 --- /dev/null +++ b/prisma/migrations/20211101151249_update_rejected_bookings/migration.sql @@ -0,0 +1 @@ +UPDATE "Booking" SET "status" = 'rejected' WHERE "rejected" = TRUE; diff --git a/server/routers/viewer.tsx b/server/routers/viewer.tsx index 17da551900..e366e3eb2f 100644 --- a/server/routers/viewer.tsx +++ b/server/routers/viewer.tsx @@ -237,9 +237,32 @@ const loggedInViewerRouter = createProtectedRouter() const { prisma, user } = ctx; const bookingListingByStatus = input.status; const bookingListingFilters: Record = { - upcoming: [{ endTime: { gte: new Date() }, NOT: { status: { equals: BookingStatus.CANCELLED } } }], - past: [{ endTime: { lte: new Date() }, NOT: { status: { equals: BookingStatus.CANCELLED } } }], - cancelled: [{ status: { equals: BookingStatus.CANCELLED } }], + upcoming: [ + { + endTime: { gte: new Date() }, + AND: [ + { NOT: { status: { equals: BookingStatus.CANCELLED } } }, + { NOT: { status: { equals: BookingStatus.REJECTED } } }, + ], + }, + ], + past: [ + { + endTime: { lte: new Date() }, + AND: [ + { NOT: { status: { equals: BookingStatus.CANCELLED } } }, + { NOT: { status: { equals: BookingStatus.REJECTED } } }, + ], + }, + ], + cancelled: [ + { + OR: [ + { status: { equals: BookingStatus.CANCELLED } }, + { status: { equals: BookingStatus.REJECTED } }, + ], + }, + ], }; const bookingListingOrderby: Record = { upcoming: { startTime: "desc" },