diff --git a/docs/platform/atoms/booker.mdx b/docs/platform/atoms/booker.mdx index dd748a2155..75962bced9 100644 --- a/docs/platform/atoms/booker.mdx +++ b/docs/platform/atoms/booker.mdx @@ -124,6 +124,7 @@ Below is a list of props that can be passed to the booker atom. | allowUpdatingUrlParams | No | Boolean indicating if the URL parameters should be updated, defaults to false. | | confirmButtonDisabled | No | Boolean indicating if the submit button should be disabled, defaults to false. | | timeZones | No | Array of valid IANA timezones to be used in the booker. Eg. ["Asia/Kolkata", "Europe/London"] | +| onTimeslotsLoaded | No | Callback function triggered once the available timeslots have been fetched. | ## Styling diff --git a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx index b55ac0962a..218248e196 100644 --- a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx +++ b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx @@ -56,6 +56,7 @@ export const BookerPlatformWrapper = ( confirmButtonDisabled, isBookingDryRun, handleSlotReservation, + onTimeslotsLoaded, } = props; const layout = BookerLayouts[view]; @@ -276,6 +277,12 @@ export const BookerPlatformWrapper = ( ...routingParams, }); + useEffect(() => { + if (schedule.data && !schedule.isPending && !schedule.error && onTimeslotsLoaded) { + onTimeslotsLoaded(schedule.data.slots); + } + }, [schedule.data, schedule.isPending, schedule.error, onTimeslotsLoaded]); + const bookerForm = useBookingForm({ event: event?.data, sessionEmail: diff --git a/packages/platform/atoms/booker/types.ts b/packages/platform/atoms/booker/types.ts index 41e59cfc73..574214fcc1 100644 --- a/packages/platform/atoms/booker/types.ts +++ b/packages/platform/atoms/booker/types.ts @@ -11,6 +11,7 @@ import type { RoutingFormSearchParams, } from "@calcom/platform-types"; import type { BookerLayouts } from "@calcom/prisma/zod-utils"; +import type { Slot } from "@calcom/trpc/server/routers/viewer/slots/types"; import type { UseCreateBookingInput } from "../hooks/bookings/useCreateBooking"; @@ -81,6 +82,7 @@ export type BookerPlatformWrapperAtomProps = Omit< timeZones?: Timezone[]; isBookingDryRun?: boolean; eventMetaChildren?: React.ReactNode; + onTimeslotsLoaded?: (slots: Record) => void; }; type VIEW_TYPE = keyof typeof BookerLayouts;