Skip to content

Scheduling infrastructure for absolutely everyone.

Rejected bookings should be displayed in cancelled bookings tab (#1100)

Mihai Cdebef8119ed0
diff --git a/pages/api/book/confirm.ts b/pages/api/book/confirm.ts
index d7440d1df06..ea35cf831d6 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 00000000000..a170caecf37
--- /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 17da551900b..e366e3eb2f9 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<typeof bookingListingByStatus, Prisma.BookingWhereInput[]> = {
- 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<typeof bookingListingByStatus, Prisma.BookingOrderByInput> = {
upcoming: { startTime: "desc" },