Skip to content

Scheduling infrastructure for absolutely everyone.

chore: enable more router props (#19088)

Morgan14ec3813ee47
diff --git a/packages/platform/atoms/booker-embed/BookerEmbed.tsx b/packages/platform/atoms/booker-embed/BookerEmbed.tsx
index 852c41f04fc..016f020cd9d 100644
--- a/packages/platform/atoms/booker-embed/BookerEmbed.tsx
+++ b/packages/platform/atoms/booker-embed/BookerEmbed.tsx
@@ -12,6 +12,19 @@ export const BookerEmbed = (
routingFormUrl: string;
bannerUrl?: BookerPlatformWrapperAtomPropsForTeam["bannerUrl"];
customClassNames?: BookerPlatformWrapperAtomPropsForTeam["customClassNames"];
+ onCreateBookingSuccess?: BookerPlatformWrapperAtomPropsForTeam["onCreateBookingSuccess"];
+ onCreateBookingError?: BookerPlatformWrapperAtomPropsForTeam["onCreateBookingError"];
+ onCreateRecurringBookingSuccess?: BookerPlatformWrapperAtomPropsForTeam["onCreateRecurringBookingSuccess"];
+ onCreateRecurringBookingError?: BookerPlatformWrapperAtomPropsForTeam["onCreateRecurringBookingError"];
+ onReserveSlotSuccess?: BookerPlatformWrapperAtomPropsForTeam["onReserveSlotSuccess"];
+ onReserveSlotError?: BookerPlatformWrapperAtomPropsForTeam["onReserveSlotError"];
+ onDeleteSlotSuccess?: BookerPlatformWrapperAtomPropsForTeam["onDeleteSlotSuccess"];
+ onDeleteSlotError?: BookerPlatformWrapperAtomPropsForTeam["onDeleteSlotError"];
+ view?: BookerPlatformWrapperAtomPropsForTeam["view"];
+ onDryRunSuccess?: BookerPlatformWrapperAtomPropsForTeam["onDryRunSuccess"];
+ hostsLimit?: BookerPlatformWrapperAtomPropsForTeam["hostsLimit"];
+ metadata?: BookerPlatformWrapperAtomPropsForTeam["metadata"];
+ handleCreateBooking?: BookerPlatformWrapperAtomPropsForTeam["handleCreateBooking"];
}
| (BookerPlatformWrapperAtomPropsForIndividual & {
organizationId?: undefined;
@@ -30,6 +43,7 @@ export const BookerEmbed = (
defaultFormValues,
...routingFormSearchParams
} = routingFormUrlProps;
+ const { onDryRunSuccess, ...rest } = props;
return (
<CalProvider
clientId={import.meta.env.VITE_BOOKER_EMBED_OAUTH_CLIENT_ID}
@@ -45,20 +59,22 @@ export const BookerEmbed = (
isTeamEvent: true,
teamId: routingTeamId || 0,
username: "",
- customClassNames: props?.customClassNames,
}
: {
eventSlug: eventTypeSlug,
username: username ?? "",
isTeamEvent: false,
- customClassNames: props?.customClassNames,
})}
routingFormSearchParams={routingFormSearchParams}
defaultFormValues={defaultFormValues}
- bannerUrl={props.bannerUrl}
onDryRunSuccess={() => {
- window.location.href = `https://app.cal.com/booking/dry-run-successful`;
+ if (onDryRunSuccess) {
+ onDryRunSuccess();
+ } else {
+ window.location.href = `https://app.cal.com/booking/dry-run-successful`;
+ }
}}
+ {...rest}
/>
</CalProvider>
);
diff --git a/packages/platform/atoms/router/Router.tsx b/packages/platform/atoms/router/Router.tsx
index c4b5be22635..d85eb2c6836 100644
--- a/packages/platform/atoms/router/Router.tsx
+++ b/packages/platform/atoms/router/Router.tsx
@@ -12,10 +12,11 @@ import type { BookerPlatformWrapperAtomPropsForTeam } from "../booker/BookerPlat
* <Router
* formId="1a1a1a1a-2b2b-3c3c-4d4d-5e5e5e5e5e5e"
* formResponsesURLParams={new URLSearchParams({ Territory: "Europe" })}
- * bookerBannerUrl="https://i0.wp.com/mahala.co.uk/wp-content/uploads/2014/12/img_banner-thin_mountains.jpg?fit=800%2C258&ssl=1"
- * bookerCustomClassNames={{
- * bookerWrapper: "dark",
- * }}
+ * bookerProps={{
+ * customClassNames: { bookerWrapper: "dark" },
+ * bannerUrl: "https://i0.wp.com/mahala.co.uk/wp-content/uploads/2014/12/img_banner-thin_mountains.jpg?fit=800%2C258&ssl=1",
+ * onCreateBookingSuccess: (data) => console.log(data),
+ * onCreateBookingError: (err) => console.error(err)
* />
* ```
*/
@@ -27,11 +28,10 @@ export const Router = React.memo(
onExternalRedirect,
onDisplayBookerEmbed,
renderMessage,
- bookerBannerUrl,
- bookerCustomClassNames,
onSubmitFormStart,
onSubmitFormEnd,
renderLoader,
+ bookerProps,
}: {
formId: string;
formResponsesURLParams?: URLSearchParams;
@@ -40,9 +40,25 @@ export const Router = React.memo(
onSubmitFormStart?: () => void;
onSubmitFormEnd?: () => void;
renderMessage?: (message?: string) => ReactElement | ReactElement[];
+ bookerProps?: Pick<
+ Partial<BookerPlatformWrapperAtomPropsForTeam>,
+ | "customClassNames"
+ | "bannerUrl"
+ | "onCreateBookingSuccess"
+ | "onCreateBookingError"
+ | "onCreateRecurringBookingSuccess"
+ | "onCreateRecurringBookingError"
+ | "onReserveSlotSuccess"
+ | "onReserveSlotError"
+ | "onDeleteSlotSuccess"
+ | "onDeleteSlotError"
+ | "view"
+ | "onDryRunSuccess"
+ | "hostsLimit"
+ | "metadata"
+ | "handleCreateBooking"
+ >;
renderLoader?: (isLoading?: boolean) => ReactElement | ReactElement[];
- bookerBannerUrl?: BookerPlatformWrapperAtomPropsForTeam["bannerUrl"];
- bookerCustomClassNames?: BookerPlatformWrapperAtomPropsForTeam["customClassNames"];
}) => {
const [isLoading, setIsLoading] = useState<boolean>();
const [routerUrl, setRouterUrl] = useState<string>();
@@ -103,13 +119,7 @@ export const Router = React.memo(
if (redirectParams.get("cal.action") === "eventTypeRedirectUrl") {
// display booker with redirect URL
onDisplayBookerEmbed?.();
- return (
- <BookerEmbed
- routingFormUrl={routerUrl}
- customClassNames={bookerCustomClassNames}
- bannerUrl={bookerBannerUrl}
- />
- );
+ return <BookerEmbed routingFormUrl={routerUrl} {...bookerProps} />;
} else if (redirectParams.get("cal.action") === "externalRedirectUrl") {
onExternalRedirect?.();
window.location.href = routerUrl;