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

* fix: rejected bookings should be displayed in cancelled bookings tab

* fix: add migration to update status of rejected bookings

* unrelated fix

Co-authored-by: Alex van Andel <me@alexvanandel.com>
This commit is contained in:
Mihai C 2021-11-05 00:24:15 +02:00 committed by GitHub
parent 773e9ac57e
commit debef8119e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 4 deletions

View file

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

View file

@ -0,0 +1 @@
UPDATE "Booking" SET "status" = 'rejected' WHERE "rejected" = TRUE;

View file

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