diff --git a/packages/platform/atoms/booker-embed/BookerEmbed.tsx b/packages/platform/atoms/booker-embed/BookerEmbed.tsx index 852c41f04f..016f020cd9 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 ( { - 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} /> ); diff --git a/packages/platform/atoms/router/Router.tsx b/packages/platform/atoms/router/Router.tsx index c4b5be2263..d85eb2c683 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 * 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, + | "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(); const [routerUrl, setRouterUrl] = useState(); @@ -103,13 +119,7 @@ export const Router = React.memo( if (redirectParams.get("cal.action") === "eventTypeRedirectUrl") { // display booker with redirect URL onDisplayBookerEmbed?.(); - return ( - - ); + return ; } else if (redirectParams.get("cal.action") === "externalRedirectUrl") { onExternalRedirect?.(); window.location.href = routerUrl;