Skip to content
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

feat: removed the confirm step in creating bookings #18380

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions packages/features/bookings/Booker/Booker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,25 @@ const BookerComponent = ({
};

useEffect(() => {
if (event.isPending) return setBookerState("loading");
if (!selectedDate) return setBookerState("selecting_date");
if (!selectedTimeslot) return setBookerState("selecting_time");
return setBookerState("booking");
}, [event, selectedDate, selectedTimeslot, setBookerState]);
if (event.isPending) {
setBookerState("loading");
return;
}
if (!selectedDate) {
setBookerState("selecting_date");
return;
}
if (!selectedTimeslot) {
setBookerState("selecting_time");
return;
}

// Only call handleBookEvent if we're not already booking
if (bookerState !== "booking") {
setBookerState("booking");
handleBookEvent();
}
}, [event, selectedDate, selectedTimeslot, setBookerState, handleBookEvent, bookerState]);

const slot = getQueryParam("slot");
useEffect(() => {
Expand Down Expand Up @@ -266,7 +280,6 @@ const BookerComponent = ({
return (
<>
{event.data && !isPlatform ? <BookingPageTagManager eventType={event.data} /> : <></>}

<div
className={classNames(
// In a popup embed, if someone clicks outside the main(having main class or main tag), it closes the embed
Expand Down Expand Up @@ -474,7 +487,6 @@ const BookerComponent = ({
</m.span>
)}
</div>

<BookFormAsModal
onCancel={() => setSelectedTimeslot(null)}
visible={bookerState === "booking" && shouldShowFormInDialog}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ export const BookEventForm = ({
// still change the timeslot, and comes back to the form, all their values
// still exist. This gets cleared when the form is submitted.
const values = bookingForm.getValues();
setFormValues(values);

if (JSON.stringify(values) !== JSON.stringify(bookingData)) {
Copy link
Member

@hariombalhara hariombalhara Jan 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it do? Doesn't seem like the correct approach.

The comparison is sensitive to irrelevant changes like property order or case, leading to unexpected form behavior

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ok I will correct this then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this addressed?

setFormValues(values);
}
}}
form={bookingForm}
handleSubmit={onSubmit}
Expand Down
Loading