@@ -14,7 +14,6 @@ class Tiers(enum.Enum):
1414
1515
1616class BillingState (rx .State ):
17-
1817 selected_plan : str = Tiers .PRO .value
1918 # Rates
2019 cpu_rate : float = 0.000463
@@ -54,11 +53,11 @@ def max_ram(self) -> int:
5453 return 64
5554
5655 @rx .event
57- def change_plan (self , plan : str ) -> None :
58- self .selected_plan = plan
56+ def change_plan (self , plan : str | list [ str ] ) -> None :
57+ self .selected_plan = plan [ 0 ] if isinstance ( plan , list ) else plan
5958 if plan == Tiers .PRO .value :
6059 self .included_cpu = 1
61- self .included_ram = .5
60+ self .included_ram = 0 .5
6261 self .included_seats = 1
6362 # Enforce Pro tier limits
6463 self .estimated_cpu_number = min (self .estimated_cpu_number , 5 )
@@ -157,13 +156,13 @@ def pricing_widget() -> rx.Component:
157156 rx .box (
158157 rx .segmented_control .root (
159158 rx .segmented_control .item ("Pro" , value = "Pro" ),
160- #rx.segmented_control.item("Team (coming soon)", value="Team"),
159+ # rx.segmented_control.item("Team (coming soon)", value="Team"),
161160 on_change = BillingState .change_plan ,
162161 default_value = "Pro" ,
163162 width = "100%" ,
164163 ),
165164 class_name = "flex flex-row pt-2 !w-[8.5rem] !h-[2.25rem] mb-2" ,
166- ),
165+ ),
167166 "" ,
168167 ),
169168 # Team seats
@@ -225,37 +224,29 @@ def pricing_widget() -> rx.Component:
225224 rx .badge (
226225 f"Total: ${ calculate_total ()} - $20 free credits = " ,
227226 rx .text .strong (f"${ calculate_total ()- 20 } /mo" ),
228-
229- size = '3' ,
227+ size = "3" ,
230228 ),
231229 class_name = "mt-6" ,
232- )
230+ )
233231 ),
234232 class_name = "flex-1 flex flex-col relative h-full w-full max-w-[25rem] pb-2.5 z-[2]" ,
235233 )
236234
237235
238236def calculate_total ():
239237 # Base price using rx.cond
240- base_price = rx .cond (
241- BillingState .selected_plan == Tiers .PRO .value ,
242- 20 ,
243- 250
244- )
245-
238+ base_price = rx .cond (BillingState .selected_plan == Tiers .PRO .value , 20 , 250 )
239+
246240 # Calculate additional seats cost
247241 additional_seats = rx .cond (
248- BillingState .estimated_seats > 1 ,
249- BillingState .estimated_seats - 1 ,
250- 0
242+ BillingState .estimated_seats > 1 , BillingState .estimated_seats - 1 , 0
251243 )
252244 seat_cost = additional_seats * BillingState .seat_rate
253-
254- compute_cost = (
255- (BillingState .estimated_ram_gb ) * (BillingState .mem_rate * MONTH_MINUTES ) +
256- (BillingState .estimated_cpu_number ) * (BillingState .cpu_rate * MONTH_MINUTES )
257- )
258-
245+
246+ compute_cost = (BillingState .estimated_ram_gb ) * (
247+ BillingState .mem_rate * MONTH_MINUTES
248+ ) + (BillingState .estimated_cpu_number ) * (BillingState .cpu_rate * MONTH_MINUTES )
249+
259250 total = base_price + seat_cost + compute_cost
260251 return round (total )
261252
@@ -318,12 +309,10 @@ def calculator_section() -> rx.Component:
318309 width = "100%" ,
319310 ),
320311 align_items = "center" ,
321- width = "100%" ,
312+ width = "100%" ,
322313 ),
323314 rx .box (pricing_widget ()),
324315 class_name = "flex flex-col p-8 border border-slate-4 rounded-[1.125rem] shadow-small bg-slate-2 relative z-[1]" ,
325- ),
316+ ),
326317 class_name = "flex flex-col w-full max-w-[64.19rem] 2xl:border-x border-slate-4 2xl:border-b pb-[6rem] justify-center items-center" ,
327318 )
328-
329-
0 commit comments