Scheduling infrastructure for absolutely everyone.
chore: Platform Booker defaultFormValues for prefilling (#15219)
Morgand8a6c375d0c3
diff --git a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx b/packages/platform/atoms/booker/BookerPlatformWrapper.tsxindex e53220a3822..bf774d68a6a 100644--- a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx+++ b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx@@ -43,12 +43,18 @@ import { AtomsWrapper } from "../src/components/atoms-wrapper";type BookerPlatformWrapperAtomProps = Omit<BookerProps, "username" | "entity"> & {rescheduleUid?: string;bookingUid?: string;- firstName?: string;- lastName?: string;- guests?: string[];- name?: string;username: string | string[];entity?: BookerProps["entity"];+ // values for the booking form and booking fields+ defaultFormValues?: {+ firstName?: string;+ lastName?: string;+ guests?: string[];+ name?: string;+ email?: string;+ notes?: string;+ rescheduleReason?: string;+ } & Record<string, string | string[]>;handleCreateBooking?: (input: UseCreateBookingInput) => void;onCreateBookingSuccess?: (data: ApiSuccessResponse<BookingResponse>) => void;onCreateBookingError?: (data: ApiErrorResponse | Error) => void;@@ -139,12 +145,17 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>const { data: session } = useMe();const hasSession = !!session;+ const { name: defaultName, guests: defaultGuests, ...restFormValues } = props.defaultFormValues ?? {};const prefillFormParams = useMemo(() => {return {- name: props.name ?? null,- guests: props.guests ?? [],+ name: defaultName ?? null,+ guests: defaultGuests ?? [],};- }, [props.name, props.guests]);+ }, [defaultName, defaultGuests]);++ const extraOptions = useMemo(() => {+ return restFormValues;+ }, [restFormValues]);const date = dayjs(selectedDate).format("YYYY-MM-DD");const prefetchNextMonth =@@ -198,7 +209,7 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>sessionUsername: session?.data?.username,sessionName: session?.data?.username,hasSession,- extraOptions: {},+ extraOptions: extraOptions ?? {},prefillFormParams: prefillFormParams,});const {@@ -314,7 +325,7 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>onOverlaySwitchStateChange={function (state: boolean): void {throw new Error("Function not implemented.");}}- extraOptions={{}}+ extraOptions={extraOptions ?? {}}bookings={{handleBookEvent: () => {handleBookEvent();