Skip to content

Commit ce79bee

Browse files
committed
update demo form
1 parent 3b42b20 commit ce79bee

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

reflex_ui/blocks/demo_form.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,9 @@ def check_if_company_email(email: str) -> bool:
209209
return domain not in personal_domains and ".edu" not in domain
210210

211211

212-
def check_if_number_of_employees_is_valid(number_of_employees: str) -> bool:
213-
"""Check if the number of employees is valid."""
214-
return number_of_employees.strip() != "Select"
215-
216-
217-
def check_if_referral_source_is_valid(referral_source: str) -> bool:
218-
"""Check if the referral source is valid."""
219-
return referral_source.strip() != "Select"
212+
def check_if_default_value_is_selected(value: str) -> bool:
213+
"""Check if the default value is selected."""
214+
return value.strip() != "Select"
220215

221216

222217
class DemoForm(rx.ComponentState):
@@ -241,7 +236,7 @@ async def on_submit(self, form_data: dict[str, Any]):
241236
yield demo_form_error_message.push("Please enter a valid company email")
242237
return
243238
# Check if the has selected a number of employees
244-
if not check_if_number_of_employees_is_valid(
239+
if not check_if_default_value_is_selected(
245240
form_data.get("number_of_employees", "")
246241
):
247242
yield rx.toast.error(
@@ -250,9 +245,8 @@ async def on_submit(self, form_data: dict[str, Any]):
250245
)
251246
yield demo_form_error_message.push("Please select a number of employees")
252247
return
253-
254248
# Check if the has entered a referral source
255-
if not check_if_referral_source_is_valid(
249+
if not check_if_default_value_is_selected(
256250
form_data.get("how_did_you_hear_about_us", "")
257251
):
258252
yield rx.toast.error(
@@ -263,6 +257,15 @@ async def on_submit(self, form_data: dict[str, Any]):
263257
"Please select how did you hear about us"
264258
)
265259
return
260+
# Check if the has entered a technical level
261+
if not check_if_default_value_is_selected(form_data.get("technical_level", "")):
262+
yield rx.set_focus("technical_level")
263+
yield rx.toast.error(
264+
"Please select a technical level",
265+
position="top-center",
266+
)
267+
yield demo_form_error_message.push("Please select a technical level")
268+
return
266269
yield is_sending_demo_form.push(True)
267270
# Send to PostHog and Slack for all submissions
268271
await self.send_demo_event(form_data)

0 commit comments

Comments
 (0)