fix: skip confirm step followup (#19076)
* Fix: Resolved double-click issue on timeSlot in Booker Atom * fix: show toast on booking error * fix: type error * Prevent the automatic change of bookerState when all fields are filled. * fix: when a user clicks on a new timeslot, any previously displayed "Confirm" button should be hidden * Update useSkipConfirmStep.ts * fix: remove 2 states for slots * Update useSlotsForDate.ts * fix types * use common types * fix: show VerifyCodeDialog and RedirectToInstantMeetingModal when skiping confirm step * fix for instant bookings --------- Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
1 parent
07accf700e
commit
829bb63eb9
11 files changed
+174
-139
No files matched your search
@@ -521,8 +521,8 @@ export const BookerPlatformWrapper = (
|
||||
onOverlaySwitchStateChange={onOverlaySwitchStateChange}
|
||||
extraOptions={extraOptions ?? {}}
|
||||
bookings={{
|
||||
handleBookEvent: () => {
|
||||
handleBookEvent();
|
||||
handleBookEvent: (timeSlot?: string) => {
|
||||
handleBookEvent(timeSlot);
|
||||
return;
|
||||
},
|
||||
expiryTime: undefined,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useIsPlatform } from "@calcom/atoms/monorepo";
|
||||
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";
|
||||
@@ -7,9 +8,11 @@ import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RoutingFormSearchParams } from "@calcom/platform-types";
|
||||
import type { BookingCreateBody } from "@calcom/prisma/zod-utils";
|
||||
import { showToast } from "@calcom/ui";
|
||||
|
||||
import type { UseCreateBookingInput } from "./useCreateBooking";
|
||||
|
||||
type Callbacks = { onSuccess?: () => void; onError?: (err: any) => void };
|
||||
type UseHandleBookingProps = {
|
||||
bookingForm: UseBookingFormReturnType["bookingForm"];
|
||||
event?: {
|
||||
@@ -20,9 +23,9 @@ type UseHandleBookingProps = {
|
||||
};
|
||||
metadata: Record<string, string>;
|
||||
hashedLink?: string | null;
|
||||
handleBooking: (input: UseCreateBookingInput) => void;
|
||||
handleInstantBooking: (input: BookingCreateBody) => void;
|
||||
handleRecBooking: (input: BookingCreateBody[]) => void;
|
||||
handleBooking: (input: UseCreateBookingInput, callbacks?: Callbacks) => void;
|
||||
handleInstantBooking: (input: BookingCreateBody, callbacks?: Callbacks) => void;
|
||||
handleRecBooking: (input: BookingCreateBody[], callbacks?: Callbacks) => void;
|
||||
locationUrl?: string;
|
||||
routingFormSearchParams?: RoutingFormSearchParams;
|
||||
};
|
||||
@@ -38,6 +41,7 @@ export const useHandleBookEvent = ({
|
||||
locationUrl,
|
||||
routingFormSearchParams,
|
||||
}: UseHandleBookingProps) => {
|
||||
const isPlatform = useIsPlatform();
|
||||
const setFormValues = useBookerStore((state) => state.setFormValues);
|
||||
const storeTimeSlot = useBookerStore((state) => state.selectedTimeslot);
|
||||
const duration = useBookerStore((state) => state.selectedDuration);
|
||||
@@ -54,10 +58,15 @@ export const useHandleBookEvent = ({
|
||||
const teamMemberEmail = useBookerStore((state) => state.teamMemberEmail);
|
||||
const crmOwnerRecordType = useBookerStore((state) => state.crmOwnerRecordType);
|
||||
const crmAppSlug = useBookerStore((state) => state.crmAppSlug);
|
||||
const handleError = (err: any) => {
|
||||
const errorMessage = err?.message ? t(err.message) : t("can_you_try_again");
|
||||
showToast(errorMessage, "error");
|
||||
};
|
||||
|
||||
const handleBookEvent = (inputTimeSlot?: string) => {
|
||||
const values = bookingForm.getValues();
|
||||
const timeslot = inputTimeSlot ?? storeTimeSlot;
|
||||
const callbacks = inputTimeSlot && !isPlatform ? { onError: handleError } : undefined;
|
||||
if (timeslot) {
|
||||
// Clears form values stored in store, so old values won't stick around.
|
||||
setFormValues({});
|
||||
@@ -101,11 +110,11 @@ export const useHandleBookEvent = ({
|
||||
};
|
||||
|
||||
if (isInstantMeeting) {
|
||||
handleInstantBooking(mapBookingToMutationInput(bookingInput));
|
||||
handleInstantBooking(mapBookingToMutationInput(bookingInput), callbacks);
|
||||
} else if (event.data?.recurringEvent?.freq && recurringEventCount && !rescheduleUid) {
|
||||
handleRecBooking(mapRecurringBookingToMutationInput(bookingInput, recurringEventCount));
|
||||
handleRecBooking(mapRecurringBookingToMutationInput(bookingInput, recurringEventCount), callbacks);
|
||||
} else {
|
||||
handleBooking({ ...mapBookingToMutationInput(bookingInput), locationUrl });
|
||||
handleBooking({ ...mapBookingToMutationInput(bookingInput), locationUrl }, callbacks);
|
||||
}
|
||||
// Clears form values stored in store, so old values won't stick around.
|
||||
setFormValues({});
|
||||
|
||||
Reference in new issue
Block a user