Scheduling infrastructure for absolutely everyone.
chore: remove last booking response dead code (#21426)
Benny Joo25eac5d29b7f
diff --git a/packages/features/bookings/Booker/components/hooks/useBookingForm.ts b/packages/features/bookings/Booker/components/hooks/useBookingForm.tsindex 45d4068824f..84d337344f3 100644--- a/packages/features/bookings/Booker/components/hooks/useBookingForm.ts+++ b/packages/features/bookings/Booker/components/hooks/useBookingForm.ts@@ -22,7 +22,6 @@ export interface IUseBookingForm {guests: string[];name: string | null;};- lastBookingResponse?: Record<string, string>;clientId?: string;}@@ -36,7 +35,6 @@ export const useBookingForm = ({hasSession,extraOptions,prefillFormParams,- lastBookingResponse,clientId,}: IUseBookingForm) => {const rescheduleUid = useBookerStore((state) => state.rescheduleUid);@@ -76,7 +74,6 @@ export const useBookingForm = ({hasSession,extraOptions,prefillFormParams,- lastBookingResponse,clientId,});diff --git a/packages/features/bookings/Booker/components/hooks/useInitialFormValues.ts b/packages/features/bookings/Booker/components/hooks/useInitialFormValues.tsindex 1ad8539eff4..117c18c0fd5 100644--- a/packages/features/bookings/Booker/components/hooks/useInitialFormValues.ts+++ b/packages/features/bookings/Booker/components/hooks/useInitialFormValues.ts@@ -21,7 +21,6 @@ type UseInitialFormValuesProps = {guests: string[];name: string | null;};- lastBookingResponse?: Record<string, string>;clientId?: string;};@@ -63,7 +62,6 @@ export function useInitialFormValues({hasSession,extraOptions,prefillFormParams,- lastBookingResponse,clientId,}: UseInitialFormValuesProps) {const stableHashExtraOptions = getStableHash(extraOptions);@@ -105,7 +103,6 @@ export function useInitialFormValues({// `guests` because the `name` of the corresponding bookingField is `guests`guests: prefillFormParams.guests,});- const parsedLastBookingResponse = z.record(z.any()).nullish().parse(lastBookingResponse);const defaultUserValues = {email:@@ -113,13 +110,13 @@ export function useInitialFormValues({? bookingData?.attendees[0].email: !!parsedQuery["email"]? parsedQuery["email"]- : email ?? parsedLastBookingResponse?.email ?? "",+ : email ?? "",name:rescheduleUid && bookingData && bookingData.attendees.length > 0? bookingData?.attendees[0].name: !!parsedQuery["name"]? parsedQuery["name"]- : name ?? username ?? parsedLastBookingResponse?.name ?? "",+ : name ?? username ?? "",};if (clientId) {diff --git a/packages/features/bookings/Booker/utils/lastBookingResponse.test.ts b/packages/features/bookings/Booker/utils/lastBookingResponse.test.tsdeleted file mode 100644index db72169d3c5..00000000000--- a/packages/features/bookings/Booker/utils/lastBookingResponse.test.ts+++ /dev/null@@ -1,65 +0,0 @@-import { describe, it, expect, beforeEach, vi } from "vitest";--import { localStorage } from "@calcom/lib/webstorage";--import { setLastBookingResponse, getLastBookingResponse } from "./lastBookingResponse";--vi.mock("@calcom/lib/webstorage", () => ({- localStorage: {- getItem: vi.fn(),- setItem: vi.fn(),- },-}));--describe.skip("Last Booking Response", () => {- beforeEach(() => {- vi.clearAllMocks();- });-- describe("setLastBookingResponse", () => {- it("should not store anything if responses is null", () => {- setLastBookingResponse(null);- expect(localStorage.setItem).not.toHaveBeenCalled();- });-- it("should store only allowed responses in localStorage", () => {- const responses = {- email: "[email protected]",- name: "John Doe",- age: 30,- };-- setLastBookingResponse(responses);-- expect(localStorage.setItem).toHaveBeenCalledWith(- "lastBookingResponse",- JSON.stringify({ email: "[email protected]", name: "John Doe" })- );- });- });-- describe("getLastBookingResponse", () => {- it("should return an empty object if there is no last booking response", () => {- (localStorage.getItem as jest.Mock).mockReturnValue(null);-- const result = getLastBookingResponse();- expect(result).toEqual({});- });-- it("should return parsed response if valid JSON is present", () => {- const mockResponse = JSON.stringify({ email: "[email protected]", name: "John Doe" });- (localStorage.getItem as jest.Mock).mockReturnValue(mockResponse);-- const result = getLastBookingResponse();- expect(result).toEqual({ email: "[email protected]", name: "John Doe" });- });-- it("should return an empty object if JSON is invalid", () => {- const invalidJson = "{ email: '[email protected]' ";- (localStorage.getItem as jest.Mock).mockReturnValue(invalidJson);-- const result = getLastBookingResponse();- expect(result).toEqual({});- });- });-});diff --git a/packages/features/bookings/Booker/utils/lastBookingResponse.ts b/packages/features/bookings/Booker/utils/lastBookingResponse.tsdeleted file mode 100644index b90df6892ab..00000000000--- a/packages/features/bookings/Booker/utils/lastBookingResponse.ts+++ /dev/null@@ -1,22 +0,0 @@-// const responsesToStore = ["email", "name"];--// eslint-disable-next-line @typescript-eslint/no-unused-vars-export const setLastBookingResponse = (responses: Record<string, unknown> | null) => {- return;- // if (!responses) return;- // const prevResponse = Object.fromEntries(- // Object.entries(responses).filter(([key]) => responsesToStore.includes(key))- // );- // localStorage.setItem("lastBookingResponse", JSON.stringify(prevResponse));-};--export const getLastBookingResponse = () => {- return {};- // const lastBookingResponse = localStorage.getItem("lastBookingResponse");- // try {- // return JSON.parse(lastBookingResponse ?? "{}");- // } catch (err) {- // logger.error("Error parsing lastBookingResponse: ", err);- // return {};- // }-};diff --git a/packages/platform/atoms/booker/BookerWebWrapper.tsx b/packages/platform/atoms/booker/BookerWebWrapper.tsxindex 3dd99c3b15f..57fa29731b2 100644--- a/packages/platform/atoms/booker/BookerWebWrapper.tsx+++ b/packages/platform/atoms/booker/BookerWebWrapper.tsx@@ -20,7 +20,6 @@ import { useVerifyCode } from "@calcom/features/bookings/Booker/components/hooksimport { 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 type { getPublicEvent } from "@calcom/features/eventtypes/lib/getPublicEvent";import { DEFAULT_LIGHT_BRAND_COLOR, DEFAULT_DARK_BRAND_COLOR, WEBAPP_URL } from "@calcom/lib/constants";@@ -104,8 +103,6 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => {};}, [searchParams, firstNameQueryParam, lastNameQueryParam]);- const lastBookingResponse = getLastBookingResponse();-const bookerForm = useBookingForm({event: event.data,sessionEmail: session?.user.email,@@ -114,7 +111,6 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => {hasSession,extraOptions: routerQuery,prefillFormParams,- lastBookingResponse,});const calendars = useCalendars({ hasSession });const verifyEmail = useVerifyEmail({diff --git a/packages/platform/atoms/hooks/bookings/useHandleBookEvent.ts b/packages/platform/atoms/hooks/bookings/useHandleBookEvent.tsindex 961db371c66..ed1be8a727c 100644--- a/packages/platform/atoms/hooks/bookings/useHandleBookEvent.ts+++ b/packages/platform/atoms/hooks/bookings/useHandleBookEvent.ts@@ -4,7 +4,6 @@ import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";import { useBookerTime } from "@calcom/features/bookings/Booker/components/hooks/useBookerTime";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 { mapBookingToMutationInput, mapRecurringBookingToMutationInput } from "@calcom/features/bookings/lib";import type { BookerEvent } from "@calcom/features/bookings/types";import { useLocale } from "@calcom/lib/hooks/useLocale";@@ -91,8 +90,6 @@ export const useHandleBookEvent = ({? duration: event.data.length;- setLastBookingResponse(values.responses);-const bookingInput = {values,duration: validDuration,