feat: add setting to allow booking through a reschedule link (#21652)

* feat: add setting to disable rescheduling cancelled bookings

Co-Authored-By: [email protected] <[email protected]>

* fix: resolve type errors for disableReschedulingCancelledBookings field

Co-Authored-By: [email protected] <[email protected]>

* fix: update test expectations and builder to include disableReschedulingCancelledBookings field

Co-Authored-By: [email protected] <[email protected]>

* fix: add disableReschedulingCancelledBookings field to managed event types

Co-Authored-By: [email protected] <[email protected]>

* fix: remove duplicate disableReschedulingCancelledBookings property in test

Co-Authored-By: [email protected] <[email protected]>

* fix: change default value to true for disableReschedulingCancelledBookings

Co-Authored-By: [email protected] <[email protected]>

* fix: update managed event types to use true as default for disableReschedulingCancelledBookings

Co-Authored-By: [email protected] <[email protected]>

* test: add comprehensive tests for disableReschedulingCancelledBookings feature

Co-Authored-By: [email protected] <[email protected]>

* update and remove unnecesarry test

* update e2e test

* Update reschedule.e2e.ts

* update

* fix

* Reverse the meaning of column

* Simpify logic of rescheduling redirects

* fix test

* revert

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: [email protected] <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: unknown <[email protected]>
Co-authored-by: Hariom Balhara <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-06-07 22:30:54 +02:00
1 parent 55a80ba253
commit 11bddbb71d
16 files changed
+132 -10

No files matched your search

@@ -60,6 +60,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
slug: true,
allowReschedulingPastBookings: true,
disableRescheduling: true,
allowReschedulingCancelledBookings: true,
team: {
select: {
parentId: true,
@@ -110,18 +111,31 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
profileEnrichedBookingUser: enrichedBookingUser,
});
const isForcedRescheduleForCancelledBooking = allowRescheduleForCancelledBooking;
// If booking is already REJECTED, we can't reschedule this booking. Take the user to the booking page which would show it's correct status and other details.
// If the booking is CANCELLED and allowRescheduleForCancelledBooking is false, we redirect the user to the original event link.
// A booking that has been rescheduled to a new booking will also have a status of CANCELLED
const isDisabledRescheduling = booking.eventType?.disableRescheduling;
if (
isDisabledRescheduling ||
(!allowRescheduleForCancelledBooking &&
(booking.status === BookingStatus.CANCELLED || booking.status === BookingStatus.REJECTED))
) {
// This comes from query param and thus is considered forced
const canRescheduleCancelledBooking =
isForcedRescheduleForCancelledBooking || booking.eventType?.allowReschedulingCancelledBookings;
const isNonRescheduleableBooking =
booking.status === BookingStatus.CANCELLED || booking.status === BookingStatus.REJECTED;
if (isDisabledRescheduling) {
return {
redirect: {
destination: booking.status === BookingStatus.CANCELLED ? eventUrl : `/booking/${uid}`,
destination: `/booking/${uid}`,
permanent: false,
},
};
}
if (isNonRescheduleableBooking) {
const canReschedule = booking.status === BookingStatus.CANCELLED && canRescheduleCancelledBooking;
return {
redirect: {
destination: canReschedule ? eventUrl : `/booking/${uid}`,
permanent: false,
},
};
@@ -71,7 +71,11 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
let booking: GetBookingType | null = null;
if (rescheduleUid) {
booking = await getBookingForReschedule(`${rescheduleUid}`, session?.user?.id);
if (booking?.status === BookingStatus.CANCELLED && !allowRescheduleForCancelledBooking) {
if (
booking?.status === BookingStatus.CANCELLED &&
!allowRescheduleForCancelledBooking &&
!eventData.allowReschedulingCancelledBookings
) {
return {
redirect: {
permanent: false,
@@ -212,6 +216,7 @@ const getTeamWithEventsData = async (
hidden: true,
disableCancelling: true,
disableRescheduling: true,
allowReschedulingCancelledBookings: true,
interfaceLanguage: true,
hosts: {
take: 3,