Skip to content

Commit 0e31b24

Browse files
committed
feat: Show thank you screen after calendar booking instead of closing
1 parent 7dab568 commit 0e31b24

File tree

1 file changed

+59
-9
lines changed

1 file changed

+59
-9
lines changed

reflex_ui/blocks/demo_form.py

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ class DemoFormState(rx.State):
117117
# Show calendar flag (shows embedded Cal.com calendar)
118118
show_calendar: bool = False
119119

120+
# Booking complete flag (shows thank you after calendar submission)
121+
booking_complete: bool = False
122+
120123
# Cal.com prefill data (stored as JSON string for use in script)
121124
cal_prefill_json: str = "{}"
122125
cal_prefill_query: str = ""
@@ -161,9 +164,15 @@ def reset_form(self):
161164
self.is_loading = False
162165
self.sent_to_unify = False
163166
self.show_calendar = False
167+
self.booking_complete = False
164168
self.cal_prefill_json = "{}"
165169
self.cal_prefill_query = ""
166170

171+
@rx.event
172+
def on_booking_complete(self):
173+
"""Handle successful calendar booking."""
174+
self.booking_complete = True
175+
167176
@rx.event
168177
def submit_step_1(self, form_data: dict[str, Any]):
169178
"""Handle step 1 submission - validate email and proceed or send to Unify."""
@@ -334,14 +343,13 @@ def init_cal_embed(self):
334343
calLink: "team/reflex/reflex-intro-call?{self.cal_prefill_query}"
335344
}});
336345
337-
// Close overlay on booking success
346+
// Show thank you on booking success
338347
Cal.ns[ns]("on", {{
339348
action: "bookingSuccessful",
340349
callback: function() {{
341-
setTimeout(function() {{
342-
var btn = document.querySelector('.cal-embed-container').closest('[class*="fixed"]').querySelector('button[aria-label="Close"]');
343-
if (btn) btn.click();
344-
}}, 1500);
350+
// Click hidden button to trigger Reflex event
351+
var btn = document.getElementById('booking-complete-trigger');
352+
if (btn) btn.click();
345353
}}
346354
}});
347355
}})();
@@ -715,28 +723,70 @@ def thank_you_screen() -> rx.Component:
715723
)
716724

717725

726+
def calendar_thank_you() -> rx.Component:
727+
"""Thank you screen shown after successful booking."""
728+
return rx.el.div(
729+
rx.el.div(
730+
ui.hi("CheckmarkCircle02Icon", class_name="size-12 text-green-500"),
731+
class_name="flex justify-center mb-4",
732+
),
733+
rx.el.h2(
734+
"You're all set!",
735+
class_name="text-2xl font-bold text-secondary-12 text-center mb-2",
736+
),
737+
rx.el.p(
738+
"Thanks for booking a demo with Reflex. We'll see you soon!",
739+
class_name="text-secondary-11 text-center mb-6",
740+
),
741+
ui.button(
742+
"Close",
743+
on_click=DemoFormState.reset_form,
744+
class_name="w-full",
745+
),
746+
class_name="flex flex-col items-center justify-center p-8",
747+
)
748+
749+
718750
def calendar_overlay() -> rx.Component:
719751
"""Full-screen calendar overlay that replaces the dialog."""
720752
return rx.cond(
721753
DemoFormState.show_calendar,
722754
rx.el.div(
755+
# Hidden button to trigger booking complete event
756+
rx.el.button(
757+
id="booking-complete-trigger",
758+
on_click=DemoFormState.on_booking_complete,
759+
class_name="hidden",
760+
),
723761
# Backdrop
724762
rx.el.div(
725763
class_name="fixed inset-0 bg-black/50 backdrop-blur-sm",
726-
on_click=DemoFormState.go_back_from_calendar,
764+
on_click=rx.cond(
765+
DemoFormState.booking_complete,
766+
DemoFormState.reset_form,
767+
DemoFormState.go_back_from_calendar,
768+
),
727769
),
728770
# Calendar container
729771
rx.el.div(
730772
ui.button(
731773
ui.hi("Cancel01Icon"),
732774
variant="ghost",
733775
size="icon-sm",
734-
on_click=DemoFormState.go_back_from_calendar,
776+
on_click=rx.cond(
777+
DemoFormState.booking_complete,
778+
DemoFormState.reset_form,
779+
DemoFormState.go_back_from_calendar,
780+
),
735781
class_name="text-secondary-11 absolute top-3 right-3 z-10",
736782
aria_label="Close",
737783
),
738-
rx.el.div(
739-
class_name="w-full min-h-[550px] overflow-auto cal-embed-container",
784+
rx.cond(
785+
DemoFormState.booking_complete,
786+
calendar_thank_you(),
787+
rx.el.div(
788+
class_name="w-full min-h-[550px] overflow-auto cal-embed-container",
789+
),
740790
),
741791
class_name="relative bg-secondary-1 rounded-xl shadow-2xl w-full max-w-4xl max-h-[90vh] overflow-auto",
742792
on_mount=DemoFormState.init_cal_embed,

0 commit comments

Comments
 (0)