feat: add redirect option for non-routed visits to event types (#27468)

* feat: add redirect option for non-routing form bookings

Add a new event type option that redirects to a custom URL when the booking
was not made through a routing form (no cal.routingFormResponseId or
cal.queuedFormResponseId query parameters).

Changes:
- Add redirectUrlOnNoRoutingFormResponse field to EventType schema
- Add UI toggle in Advanced tab to configure the redirect URL
- Implement redirect logic in bookingSuccessRedirect hook
- Add translations for new UI strings

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

* fix: add redirectUrlOnNoRoutingFormResponse to test builder

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

* fix: add redirectUrlOnNoRoutingFormResponse to BookerEvent type

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

* fix: add redirectUrlOnNoRoutingFormResponse to getPublicEventSelect

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

* fix: add redirect logic to getServerSideProps for non-routing form bookings

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

* fix: remove redirectUrlOnNoRoutingFormResponse from booking success flow

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

* fix: use 'in' operator for type narrowing on redirectUrlOnNoRoutingFormResponse

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

* fix: exclude redirectUrlOnNoRoutingFormResponse from test assertions

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

* fix: include redirectUrlOnNoRoutingFormResponse in test assertions and update description

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

* fix: add redirectUrlOnNoRoutingFormResponse to mockUpdatedEventType

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

* fix: remove redirect logic from instant meetings

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

* fix: add redirectUrlOnNoRoutingFormResponse to EventTypeRepository select

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

* fix: add redirectUrlOnNoRoutingFormResponse to form default values

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

* Reword string

* fix: bust tRPC cache for redirectUrlOnNoRoutingFormResponse

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

* fix: guard redirect when rescheduleUid or bookingUid is present

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

* fix: add redirectUrlOnNoRoutingFormResponse to dynamicEvent defaults

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

* fix: add bookingUid guard to team getServerSideProps redirect

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

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-02-02 15:48:23 -03:00
1 parent 7062887632
commit c0f6a1b088
17 files changed
+159 -36

No files matched your search

@@ -189,9 +189,11 @@ export const useBookingSuccessRedirect = () => {
query,
booking,
forwardParamsSuccessRedirect,
redirectUrlOnNoRoutingFormResponse,
}: {
successRedirectUrl: EventType["successRedirectUrl"];
forwardParamsSuccessRedirect: EventType["forwardParamsSuccessRedirect"];
redirectUrlOnNoRoutingFormResponse?: EventType["redirectUrlOnNoRoutingFormResponse"];
query: Record<string, string | null | undefined | boolean>;
booking: SuccessRedirectBookingType;
}) => {
@@ -201,6 +203,16 @@ export const useBookingSuccessRedirect = () => {
"cal.rerouting": searchParams.get("cal.rerouting"),
};
// Check if there's no routing form response and redirect URL is configured
const hasRoutingFormResponse =
searchParams.get("cal.routingFormResponseId") || searchParams.get("cal.queuedFormResponseId");
if (!hasRoutingFormResponse && redirectUrlOnNoRoutingFormResponse) {
const url = new URL(redirectUrlOnNoRoutingFormResponse);
navigateInTopWindow(url.toString());
return;
}
if (successRedirectUrl) {
const url = new URL(successRedirectUrl);
// Using parent ensures, Embed iframe would redirect outside of the iframe.
@@ -155,6 +155,7 @@ const commons = {
updatedAt: null,
rrHostSubsetEnabled: false,
enablePerHostLocations: false,
redirectUrlOnNoRoutingFormResponse: null,
};
export const dynamicEvent = {
@@ -129,9 +129,10 @@ export const getPublicEventSelect = (fetchAllUsers: boolean) => {
},
},
},
successRedirectUrl: true,
forwardParamsSuccessRedirect: true,
workflows: {
successRedirectUrl: true,
forwardParamsSuccessRedirect: true,
redirectUrlOnNoRoutingFormResponse: true,
workflows: {
include: {
workflow: {
include: {
@@ -160,6 +160,7 @@ export type FormValues = {
externalId: string;
};
successRedirectUrl: string;
redirectUrlOnNoRoutingFormResponse: string;
durationLimits?: IntervalLimit;
bookingLimits?: IntervalLimit;
onlyShowFirstAvailableSlot: boolean;
@@ -622,6 +622,7 @@ export class EventTypeRepository implements IEventTypesRepository {
isRRWeightsEnabled: true,
rescheduleWithSameRoundRobinHost: true,
successRedirectUrl: true,
redirectUrlOnNoRoutingFormResponse: true,
forwardParamsSuccessRedirect: true,
currency: true,
bookingFields: true,
@@ -937,6 +938,7 @@ export class EventTypeRepository implements IEventTypesRepository {
isRRWeightsEnabled: true,
rescheduleWithSameRoundRobinHost: true,
successRedirectUrl: true,
redirectUrlOnNoRoutingFormResponse: true,
forwardParamsSuccessRedirect: true,
currency: true,
bookingFields: true,
+1
View File
@@ -147,6 +147,7 @@ export const buildEventType = (eventType?: Partial<EventType>): EventType => {
metadata: null,
successRedirectUrl: null,
forwardParamsSuccessRedirect: true,
redirectUrlOnNoRoutingFormResponse: null,
bookingFields: [],
parentId: null,
profileId: null,
@@ -103,6 +103,7 @@ export const useEventTypeForm = ({
hosts: eventType.hosts.sort((a, b) => sortHosts(a, b, eventType.isRRWeightsEnabled)),
hostGroups: eventType.hostGroups || [],
successRedirectUrl: eventType.successRedirectUrl || "",
redirectUrlOnNoRoutingFormResponse: eventType.redirectUrlOnNoRoutingFormResponse || "",
forwardParamsSuccessRedirect: eventType.forwardParamsSuccessRedirect,
users: eventType.users,
useEventTypeDestinationCalendarEmail: eventType.useEventTypeDestinationCalendarEmail,
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "public"."EventType" ADD COLUMN "redirectUrlOnNoRoutingFormResponse" TEXT;
+2
View File
@@ -235,6 +235,8 @@ model EventType {
/// @zod.import(["import { successRedirectUrl } from '../../zod-utils'"]).custom.use(successRedirectUrl)
successRedirectUrl String?
forwardParamsSuccessRedirect Boolean? @default(true)
/// @zod.import(["import { successRedirectUrl } from '../../zod-utils'"]).custom.use(successRedirectUrl)
redirectUrlOnNoRoutingFormResponse String?
workflows WorkflowsOnEventTypes[]
/// @zod.import(["import { intervalLimitsType } from '../../zod-utils'"]).custom.use(intervalLimitsType)
bookingLimits Json?
@@ -1,4 +1,4 @@
// Cache bust: workflows.activeOn.eventType no longer includes _count.children
// Cache bust: added redirectUrlOnNoRoutingFormResponse to eventType
import getEventTypeById from "@calcom/features/eventtypes/lib/getEventTypeById";
import type { PrismaClient } from "@calcom/prisma";
@@ -204,6 +204,7 @@ export type TUpdateInputSchema = {
metadata?: EventTypeMetadata;
successRedirectUrl?: string | null;
forwardParamsSuccessRedirect?: boolean | null;
redirectUrlOnNoRoutingFormResponse?: string | null;
bookingLimits?: IntervalLimit | null;
durationLimits?: IntervalLimit | null;
isInstantEvent?: boolean;
@@ -401,6 +402,7 @@ const BaseEventTypeUpdateInput: z.ZodType<TUpdateInputSchema> = z
metadata: EventTypeMetaDataSchema.optional(),
successRedirectUrl: z.string().nullable().optional(),
forwardParamsSuccessRedirect: z.boolean().nullable().optional(),
redirectUrlOnNoRoutingFormResponse: z.string().nullable().optional(),
bookingLimits: intervalLimitsType.nullable().optional(),
durationLimits: intervalLimitsType.nullable().optional(),
isInstantEvent: z.boolean().optional(),