Skip to content

Commit 88a645f

Browse files
committed
backend set
1 parent cbe5368 commit 88a645f

File tree

1 file changed

+58
-4
lines changed

1 file changed

+58
-4
lines changed

pcweb/pages/pricing/header.py

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
from pcweb.components.hosting_banner import HostingBannerState
33
from pcweb.pages.framework.views.companies import pricing_page_companies
44
from pcweb.components.new_button import button
5-
from typing import Literal
5+
from typing import Literal, Any
66

7+
import urllib.parse
8+
from datetime import datetime
79
from reflex.event import EventType
810

911
# Import your custom select components
@@ -98,11 +100,49 @@ class QuoteFormState(rx.State):
98100
"""State management for the quote form."""
99101
num_employees: str = "500+"
100102
referral_source: str = "Google Search"
103+
banned_email: bool = False
101104

102105
def set_select_value(self, field: str, value: str):
103106
"""Update the selected value for a given field."""
104107
setattr(self, field, value)
105108

109+
@rx.event
110+
def submit(self, form_data: dict[str, Any]):
111+
# Email domain validation
112+
banned_domains = ['gmail.com', 'yahoo.com', 'outlook.com', 'hotmail.com', 'icloud.com', 'aol.com']
113+
114+
email = form_data.get("email", "").lower()
115+
if "@" in email:
116+
domain = email.split("@")[1]
117+
if domain in banned_domains:
118+
self.banned_email = True
119+
return
120+
121+
122+
self.banned_email = False
123+
now = datetime.now()
124+
current_month = now.strftime("%Y-%m")
125+
current_date = now.strftime("%Y-%m-%d")
126+
127+
params = {
128+
"First Name": form_data.get("first_name", ""),
129+
"Last Name": form_data.get("last_name", ""),
130+
"Business Email Address": form_data.get("email", ""),
131+
"Job Title": form_data.get("job_title", ""),
132+
"Company name": form_data.get("company_name", ""),
133+
"Phone Number": form_data.get("phone_number", ""),
134+
"Number of Employees": self.num_employees, # From state
135+
"What internal tools are you looking to build?": form_data.get("internal_tools", ""),
136+
"Where did you first hear about Reflex?": self.referral_source, # From state
137+
"month": current_month,
138+
"date": current_date,
139+
}
140+
141+
query_string = urllib.parse.urlencode(params)
142+
cal_url = f"https://cal.com/team/reflex/talk-to-a-reflex-expert?{query_string}"
143+
144+
return rx.redirect(cal_url)
145+
106146
def quote_input(placeholder: str, name: str, **props):
107147
return rx.el.input(
108148
placeholder=placeholder,
@@ -198,9 +238,22 @@ def custom_quote_form() -> rx.Component:
198238
text_input_field("Last name", "last_name", "Smith", required=True, class_name="mb-0"),
199239
class_name="flex-row flex gap-x-2 mb-6",
200240
),
201-
202-
text_input_field("Business email", "business_email", "john@reflex.dev", required=True, input_type="email"),
203-
241+
rx.cond(
242+
QuoteFormState.banned_email,
243+
rx.box(
244+
rx.el.div(
245+
rx.text("Business email", class_name="text-slate-11 text-sm font-medium mb-2"),
246+
rx.text("Personal emails not allowed!", class_name="text-red-8 text-sm font-medium mb-2"),
247+
class_name="flex flex-row items-center justify-between w-full",
248+
),
249+
rx.el.input(
250+
placeholder="Personal emails not allowed!",
251+
name="email",
252+
class_name="box-border w-full border-2 border-red-5 bg-slate-1 px-6 pr-8 border rounded-[0.625rem] h-[2.25rem] font-medium text-slate-12 text-sm placeholder:text-slate-9 outline-none focus:outline-none caret-slate-12 peer pl-2.5 disabled:cursor-not-allowed disabled:border disabled:border-slate-5 disabled:!bg-slate-3 disabled:text-slate-8 disabled:placeholder:text-slate-8",
253+
)
254+
),
255+
text_input_field("Business email", "email", "john@reflex.dev", required=True, input_type="email"),
256+
),
204257
rx.el.div(
205258
text_input_field("Job title", "job_title", "CTO", required=True, class_name="mb-0"),
206259
text_input_field("Company name", "company_name", "Pynecone, Inc.", required=True, class_name="mb-0"),
@@ -225,6 +278,7 @@ def custom_quote_form() -> rx.Component:
225278
class_name="w-full mt-2",
226279
),
227280
class_name="w-full space-y-6",
281+
on_submit=QuoteFormState.submit,
228282
),
229283
rx.box(
230284
"1 Month Free Trial",

0 commit comments

Comments
 (0)