feat: Add onTimeslotsLoaded prop to Booker atom (#21871)
* [CAL-5926] Add 'onTimeslotsLoaded' prop to 'Booker' atom * Added 'onTimeslotsLoaded' to BookerPlatformWrapperAtomProps * fixed type error and added onTimeslotsLoaded prop to doc --------- Co-authored-by: Somay Chauhan <somaychauhan98@gmail.com>
This commit is contained in:
co-authored by
Somay Chauhan
parent
4edb39616d
commit
8b83d39ac3
@@ -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
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user