-
Notifications
You must be signed in to change notification settings - Fork 8.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: skip confirm step followup #19076
Open
SomayChauhan
wants to merge
13
commits into
main
Choose a base branch
from
followup/skip-confirm-step
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+104
−77
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
06dfd34
Fix: Resolved double-click issue on timeSlot in Booker Atom
SomayChauhan da0b6d7
Merge branch 'main' into followup/skip-confirm-step
SomayChauhan 1cecfa1
Merge branch 'main' into followup/skip-confirm-step
SomayChauhan 98d9af7
fix: show toast on booking error
SomayChauhan 51e5c89
Merge branch 'main' into followup/skip-confirm-step
SomayChauhan 1355f03
fix: type error
SomayChauhan 0319c5b
Prevent the automatic change of bookerState when all fields are filled.
SomayChauhan fa6659e
fix: when a user clicks on a new timeslot, any previously displayed "…
SomayChauhan 0f78af6
Merge branch 'main' into followup/skip-confirm-step
SomayChauhan b42f0b0
Merge branch 'followup/skip-confirm-step' of https://github.com/calco…
SomayChauhan 55d00c4
Merge branch 'main' into followup/skip-confirm-step
SomayChauhan e7b820c
Merge branch 'main' into followup/skip-confirm-step
SomayChauhan 1bd09a6
Update useSkipConfirmStep.ts
SomayChauhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,8 @@ import { getQueryParam } from "../Booker/utils/query-param"; | |
import { useCheckOverlapWithOverlay } from "../lib/useCheckOverlapWithOverlay"; | ||
import { SeatsAvailabilityText } from "./SeatsAvailabilityText"; | ||
|
||
type Slot = Slots[string][number] & { showConfirmButton?: boolean }; | ||
|
||
type TOnTimeSelect = ( | ||
time: string, | ||
attendees: number, | ||
|
@@ -34,10 +36,10 @@ export type AvailableTimesProps = { | |
slots: IGetAvailableSlots["slots"][string]; | ||
showTimeFormatToggle?: boolean; | ||
className?: string; | ||
} & Omit<SlotItemProps, "slot">; | ||
} & Omit<SlotItemProps, "slot" | "handleSlotClick">; | ||
|
||
type SlotItemProps = { | ||
slot: Slots[string][number]; | ||
slot: Slot; | ||
seatsPerTimeSlot?: number | null; | ||
selectedSlots?: string[]; | ||
onTimeSelect: TOnTimeSelect; | ||
|
@@ -52,6 +54,7 @@ type SlotItemProps = { | |
skipConfirmStep?: boolean; | ||
shouldRenderCaptcha?: boolean; | ||
watchedCfToken?: string; | ||
handleSlotClick: (slot: Slot, isOverlapping: boolean) => void; | ||
}; | ||
|
||
const SlotItem = ({ | ||
|
@@ -68,6 +71,7 @@ const SlotItem = ({ | |
skipConfirmStep, | ||
shouldRenderCaptcha, | ||
watchedCfToken, | ||
handleSlotClick, | ||
}: SlotItemProps) => { | ||
const { t } = useLocale(); | ||
|
||
|
@@ -106,26 +110,6 @@ const SlotItem = ({ | |
offset, | ||
}); | ||
|
||
const [showConfirm, setShowConfirm] = useState(false); | ||
|
||
const onButtonClick = useCallback(() => { | ||
if (!showConfirm && ((overlayCalendarToggled && isOverlapping) || skipConfirmStep)) { | ||
setShowConfirm(true); | ||
return; | ||
} | ||
onTimeSelect(slot.time, slot?.attendees || 0, seatsPerTimeSlot, slot.bookingUid); | ||
}, [ | ||
overlayCalendarToggled, | ||
isOverlapping, | ||
showConfirm, | ||
onTimeSelect, | ||
slot.time, | ||
slot?.attendees, | ||
slot.bookingUid, | ||
seatsPerTimeSlot, | ||
skipConfirmStep, | ||
]); | ||
|
||
return ( | ||
<AnimatePresence> | ||
<div className="flex gap-2"> | ||
|
@@ -143,7 +127,7 @@ const SlotItem = ({ | |
data-testid="time" | ||
data-disabled={bookingFull} | ||
data-time={slot.time} | ||
onClick={onButtonClick} | ||
onClick={() => handleSlotClick(slot, isOverlapping)} | ||
className={classNames( | ||
`hover:border-brand-default min-h-9 mb-2 flex h-auto w-full flex-grow flex-col justify-center py-2`, | ||
selectedSlots?.includes(slot.time) && "border-brand-default", | ||
|
@@ -176,47 +160,40 @@ const SlotItem = ({ | |
</p> | ||
)} | ||
</Button> | ||
{showConfirm && ( | ||
{!!slot.showConfirmButton && ( | ||
<HoverCard.Root> | ||
<HoverCard.Trigger asChild> | ||
<m.div initial={{ width: 0 }} animate={{ width: "auto" }} exit={{ width: 0 }}> | ||
{skipConfirmStep ? ( | ||
<Button | ||
type="button" | ||
onClick={() => | ||
onTimeSelect(slot.time, slot?.attendees || 0, seatsPerTimeSlot, slot.bookingUid) | ||
} | ||
data-testid="skip-confirm-book-button" | ||
disabled={ | ||
(!!shouldRenderCaptcha && !watchedCfToken) || | ||
loadingStates?.creatingBooking || | ||
loadingStates?.creatingRecurringBooking || | ||
isVerificationCodeSending || | ||
loadingStates?.creatingInstantBooking | ||
} | ||
color="primary" | ||
loading={ | ||
(selectedTimeslot === slot.time && loadingStates?.creatingBooking) || | ||
loadingStates?.creatingRecurringBooking || | ||
isVerificationCodeSending || | ||
loadingStates?.creatingInstantBooking | ||
}> | ||
{renderConfirmNotVerifyEmailButtonCond | ||
? isPaidEvent | ||
? t("pay_and_book") | ||
: t("confirm") | ||
: t("verify_email_email_button")} | ||
</Button> | ||
) : ( | ||
<Button | ||
variant={layout === "column_view" ? "icon" : "button"} | ||
StartIcon={layout === "column_view" ? "chevron-right" : undefined} | ||
onClick={() => | ||
onTimeSelect(slot.time, slot?.attendees || 0, seatsPerTimeSlot, slot.bookingUid) | ||
}> | ||
{layout !== "column_view" && t("confirm")} | ||
</Button> | ||
)} | ||
<m.div key={slot.time} initial={{ width: 0 }} animate={{ width: "auto" }} exit={{ width: 0 }}> | ||
<Button | ||
variant={layout === "column_view" ? "icon" : "button"} | ||
StartIcon={layout === "column_view" ? "chevron-right" : undefined} | ||
type="button" | ||
onClick={() => | ||
onTimeSelect(slot.time, slot?.attendees || 0, seatsPerTimeSlot, slot.bookingUid) | ||
} | ||
data-testid="skip-confirm-book-button" | ||
disabled={ | ||
(!!shouldRenderCaptcha && !watchedCfToken) || | ||
loadingStates?.creatingBooking || | ||
loadingStates?.creatingRecurringBooking || | ||
isVerificationCodeSending || | ||
loadingStates?.creatingInstantBooking | ||
} | ||
color="primary" | ||
loading={ | ||
(selectedTimeslot === slot.time && loadingStates?.creatingBooking) || | ||
loadingStates?.creatingRecurringBooking || | ||
isVerificationCodeSending || | ||
loadingStates?.creatingInstantBooking | ||
}> | ||
{layout == "column_view" | ||
? "" | ||
: renderConfirmNotVerifyEmailButtonCond | ||
? isPaidEvent | ||
? t("pay_and_book") | ||
: t("confirm") | ||
: t("verify_email_email_button")} | ||
</Button> | ||
</m.div> | ||
</HoverCard.Trigger> | ||
{isOverlapping && ( | ||
|
@@ -241,13 +218,42 @@ const SlotItem = ({ | |
}; | ||
|
||
export const AvailableTimes = ({ | ||
slots, | ||
slots: Incomingslots, | ||
showTimeFormatToggle = true, | ||
className, | ||
seatsPerTimeSlot, | ||
skipConfirmStep, | ||
onTimeSelect, | ||
...props | ||
}: AvailableTimesProps) => { | ||
const { t } = useLocale(); | ||
|
||
const [slots, setSlots] = useState(Incomingslots); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering if this could cause some issues in the future as we would have to maintain two different states of slots |
||
|
||
const overlayCalendarToggled = | ||
getQueryParam("overlayCalendar") === "true" || localStorage.getItem("overlayCalendarSwitchDefault"); | ||
|
||
const handleSlotClick = useCallback( | ||
(selectedSlot: Slot, isOverlapping: boolean) => { | ||
if ((overlayCalendarToggled && isOverlapping) || skipConfirmStep) { | ||
setSlots((prevSlots) => | ||
prevSlots.map((slot) => ({ | ||
...slot, | ||
showConfirmButton: slot.time === selectedSlot.time ? !selectedSlot?.showConfirmButton : false, | ||
})) | ||
); | ||
return; | ||
} | ||
onTimeSelect( | ||
selectedSlot.time, | ||
selectedSlot?.attendees || 0, | ||
seatsPerTimeSlot, | ||
selectedSlot.bookingUid | ||
); | ||
}, | ||
[overlayCalendarToggled, onTimeSelect, seatsPerTimeSlot, skipConfirmStep] | ||
); | ||
|
||
const oooAllDay = slots.every((slot) => slot.away); | ||
if (oooAllDay) { | ||
return <OOOSlot {...slots[0]} />; | ||
|
@@ -273,7 +279,17 @@ export const AvailableTimes = ({ | |
{oooBeforeSlots && !oooAfterSlots && <OOOSlot {...slots[0]} />} | ||
{slots.map((slot) => { | ||
if (slot.away) return null; | ||
return <SlotItem key={slot.time} slot={slot} {...props} />; | ||
return ( | ||
<SlotItem | ||
key={slot.time} | ||
slot={slot} | ||
{...props} | ||
handleSlotClick={handleSlotClick} | ||
seatsPerTimeSlot={seatsPerTimeSlot} | ||
skipConfirmStep={skipConfirmStep} | ||
onTimeSelect={onTimeSelect} | ||
/> | ||
); | ||
})} | ||
{oooAfterSlots && !oooBeforeSlots && <OOOSlot {...slots[slots.length - 1]} className="pb-0" />} | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cross-dependency on @features/schedules is a bit odd. Maybe we want to type this directly into the bookings component.