Scheduling infrastructure for absolutely everyone.
feat: Add `onTimeslotsLoaded` prop to `Booker` atom (#21871)
Dhairyashil Shinde8b83d39ac338
diff --git a/docs/platform/atoms/booker.mdx b/docs/platform/atoms/booker.mdxindex dd748a2155c..75962bced91 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. |## Stylingdiff --git a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx b/packages/platform/atoms/booker/BookerPlatformWrapper.tsxindex b55ac0962a5..218248e196a 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.tsindex 41e59cfc738..574214fcc1e 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<string, Slot[]>) => void;};type VIEW_TYPE = keyof typeof BookerLayouts;