feat: Autofill feature (#15437)

* feat: Autofill feature

* Revert "feat: Autofill feature"

This reverts commit ac94257cbb516e140ed550ae804e725ca5d036ca.

* feat: store prev response in localStorage

* review fixes

* add tests

* remove unused import

---------

Co-authored-by: Hariom Balhara <[email protected]>
Co-authored-by: unknown <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-11-18 20:04:02 +05:30
1 parent 7b94822c8d
commit 8194ffcd07
6 files changed
+103 -3

No files matched your search

@@ -19,6 +19,7 @@ import { useVerifyCode } from "@calcom/features/bookings/Booker/components/hooks
import { useVerifyEmail } from "@calcom/features/bookings/Booker/components/hooks/useVerifyEmail";
import { useBookerStore, useInitializeBookerStore } from "@calcom/features/bookings/Booker/store";
import { useEvent, useScheduleForEvent } from "@calcom/features/bookings/Booker/utils/event";
import { getLastBookingResponse } from "@calcom/features/bookings/Booker/utils/lastBookingResponse";
import { useBrandColors } from "@calcom/features/bookings/Booker/utils/use-brand-colors";
import { DEFAULT_LIGHT_BRAND_COLOR, DEFAULT_DARK_BRAND_COLOR, WEBAPP_URL } from "@calcom/lib/constants";
import { useRouterQuery } from "@calcom/lib/hooks/useRouterQuery";
@@ -85,6 +86,8 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => {
};
}, [searchParams, firstNameQueryParam, lastNameQueryParam]);
const lastBookingResponse = getLastBookingResponse();
const bookerForm = useBookingForm({
event: event.data,
sessionEmail: session?.user.email,
@@ -93,6 +96,7 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => {
hasSession,
extraOptions: routerQuery,
prefillFormParams,
lastBookingResponse,
});
const calendars = useCalendars({ hasSession });
const verifyEmail = useVerifyEmail({
@@ -1,5 +1,6 @@
import type { UseBookingFormReturnType } from "@calcom/features/bookings/Booker/components/hooks/useBookingForm";
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
import { setLastBookingResponse } from "@calcom/features/bookings/Booker/utils/lastBookingResponse";
import {
useTimePreferences,
mapBookingToMutationInput,
@@ -74,6 +75,8 @@ export const useHandleBookEvent = ({
? duration
: event.data.length;
setLastBookingResponse(values.responses);
const bookingInput = {
values,
duration: validDuration,