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:
parent
773e9ac57e
commit
debef8119e
3 changed files with 29 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
UPDATE "Booking" SET "status" = 'rejected' WHERE "rejected" = TRUE;
|
|
@ -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" },
|
||||
|
|
Loading…
Reference in a new issue