import type {
BookerPlatformWrapperAtomPropsForIndividual,
BookerPlatformWrapperAtomPropsForTeam,
} from "../booker/BookerPlatformWrapper";
import { BookerPlatformWrapper } from "../booker/BookerPlatformWrapper";
import { CalProvider } from "../cal-provider/CalProvider";
import { useGetRoutingFormUrlProps } from "./useGetRoutingFormUrlProps";
export const BookerEmbed = (
props:
| {
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;
routingFormUrl?: undefined;
})
| (BookerPlatformWrapperAtomPropsForTeam & { organizationId?: number; routingFormUrl?: undefined })
) => {
// Use Routing Form Url To Display Correct Booker
const routingFormUrlProps = useGetRoutingFormUrlProps(props);
if (props?.routingFormUrl && routingFormUrlProps) {
const {
organizationId,
teamId: routingTeamId,
eventTypeSlug,
username,
defaultFormValues,
teamMemberEmail,
crmOwnerRecordType,
crmAppSlug,
...routingFormSearchParams
} = routingFormUrlProps;
const { onDryRunSuccess, ...rest } = props;
return (
{
if (onDryRunSuccess) {
onDryRunSuccess();
} else {
window.location.href = `https://app.cal.com/booking/dry-run-successful`;
}
}}
{...rest}
/>
);
}
// If Not For From Routing, Use Props
if (props?.routingFormUrl === undefined) {
return (
);
}
return <>>;
};