diff --git a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx index e53220a382..bf774d68a6 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 & { 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; handleCreateBooking?: (input: UseCreateBookingInput) => void; onCreateBookingSuccess?: (data: ApiSuccessResponse) => 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();