fix: Broken reschedule page for migrated user's booking through request-reschedule (#16068)

Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Amit Sharma <[email protected]>
Co-authored-by: zomars <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-08-29 14:35:32 -07:00
1 parent 17f537774c
commit 88f46a6b20
8 files changed
+62 -52

No files matched your search

+20 -8
View File
@@ -16,6 +16,16 @@ export default function Type() {
return null;
}
const querySchema = z.object({
uid: z.string(),
seatReferenceUid: z.string().optional(),
rescheduledBy: z.string().optional(),
allowRescheduleForCancelledBooking: z
.string()
.transform((value) => value === "true")
.optional(),
});
export async function getServerSideProps(context: GetServerSidePropsContext) {
const session = await getServerSession(context);
@@ -23,13 +33,12 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
uid: bookingUid,
seatReferenceUid,
rescheduledBy,
} = z
.object({
uid: z.string(),
seatReferenceUid: z.string().optional(),
rescheduledBy: z.string().optional(),
})
.parse(context.query);
/**
* This is for the case of request-reschedule where the booking is cancelled
*/
allowRescheduleForCancelledBooking,
} = querySchema.parse(context.query);
const coepFlag = context.query["flag.coep"];
const { uid, seatReferenceUid: maybeSeatReferenceUid } = await maybeGetBookingUidFromSeat(
prisma,
@@ -90,7 +99,10 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
// If booking is already CANCELLED or REJECTED, we can't reschedule this booking. Take the user to the booking page which would show it's correct status and other details.
// A booking that has been rescheduled to a new booking will also have a status of CANCELLED
if (booking.status === BookingStatus.CANCELLED || booking.status === BookingStatus.REJECTED) {
if (
!allowRescheduleForCancelledBooking &&
(booking.status === BookingStatus.CANCELLED || booking.status === BookingStatus.REJECTED)
) {
return {
redirect: {
destination: `/booking/${uid}`,
@@ -34,7 +34,7 @@ import type { EventBusyDate, IntervalLimit } from "@calcom/types/Calendar";
import { getMockPaymentService } from "./MockPaymentService";
import type { getMockRequestDataForBooking } from "./getMockRequestDataForBooking";
logger.settings.minLevel = 0;
logger.settings.minLevel = 1;
const log = logger.getSubLogger({ prefix: ["[bookingScenario]"] });
type InputWebhook = {
@@ -143,10 +143,9 @@ expect.extend({
if (!isEmailContentMatched) {
logger.silly("All Emails", JSON.stringify({ numEmails: emailsToLog.length, emailsToLog }));
return {
pass: false,
message: () => `Email content ${isNot ? "is" : "is not"} matching. ${JSON.stringify(emailsToLog)}`,
message: () => `Email content ${isNot ? "is" : "is not"} matching.`,
actual: actualEmailContent,
expected: expectedEmailContent,
};
@@ -818,8 +817,6 @@ export function expectBookingRequestRescheduledEmails({
loggedInUser,
booker,
booking,
bookNewTimePath,
organizer,
}: {
emails: Fixtures["emails"];
organizer: ReturnType<typeof getOrganizer>;
@@ -840,7 +837,7 @@ export function expectBookingRequestRescheduledEmails({
subHeading: "request_reschedule_subtitle",
links: [
{
href: `${bookingUrlOrigin}${bookNewTimePath}?rescheduleUid=${booking.uid}`,
href: `${bookingUrlOrigin}/reschedule/${booking.uid}?allowRescheduleForCancelledBooking=true`,
text: "Book a new time",
},
],