1+ from typing import Optional , Tuple
2+
13import reflex as rx
4+
25from admin_dashboard .states .dashboard_state import (
6+ CustomerData ,
37 DashboardState ,
48 SortColumn ,
5- SortOrder ,
6- CustomerData ,
79)
8- from typing import Optional , List , Tuple
910
1011
1112def platform_tag (platform : rx .Var [str ]) -> rx .Component :
@@ -56,12 +57,12 @@ def industry_tag(industry: rx.Var[str]) -> rx.Component:
5657
5758def sort_icon (column_key : SortColumn ) -> rx .Component :
5859 """Displays sort direction icon or a neutral sortable indicator."""
59- icon_base_class = "ml-1 inline-block w-3 h-3 transition-colors duration-150 ease-in-out"
60+ icon_base_class = (
61+ "ml-1 inline-block w-3 h-3 transition-colors duration-150 ease-in-out"
62+ )
6063 active_icon_class = f"{ icon_base_class } text-gray-700"
6164 inactive_icon_class = f"{ icon_base_class } text-gray-400 group-hover:text-gray-600"
62- is_active_column = (
63- DashboardState .sort_column == column_key
64- )
65+ is_active_column = DashboardState .sort_column == column_key
6566 return rx .cond (
6667 is_active_column ,
6768 rx .cond (
@@ -85,9 +86,7 @@ def sort_icon(column_key: SortColumn) -> rx.Component:
8586 )
8687
8788
88- def sortable_table_header (
89- col_name : str , column_key : SortColumn
90- ) -> rx .Component :
89+ def sortable_table_header (col_name : str , column_key : SortColumn ) -> rx .Component :
9190 """Renders a sortable table header cell."""
9291 base_class = "px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider group"
9392 sortable_class = f"{ base_class } cursor-pointer"
@@ -124,7 +123,9 @@ def non_sortable_table_header(
124123 col_name : str ,
125124) -> rx .Component :
126125 """Renders a non-sortable table header cell."""
127- base_class = "px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
126+ base_class = (
127+ "px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
128+ )
128129 text_align_class = rx .match (
129130 col_name ,
130131 ("Revenue" , "text-right" ),
@@ -159,17 +160,13 @@ def table_header(
159160 col_name = col_data [0 ]
160161 column_key = col_data [1 ]
161162 return rx .cond (
162- column_key != None ,
163- sortable_table_header (
164- col_name , column_key .to (SortColumn )
165- ),
163+ column_key is not None ,
164+ sortable_table_header (col_name , column_key .to (SortColumn )),
166165 non_sortable_table_header (col_name ),
167166 )
168167
169168
170- def get_cell_content (
171- col_name : rx .Var [str ], customer : CustomerData
172- ) -> rx .Component :
169+ def get_cell_content (col_name : rx .Var [str ], customer : CustomerData ) -> rx .Component :
173170 """Gets the appropriate component for a specific cell based on column name."""
174171 base_class = "px-4 py-3 whitespace-nowrap text-sm"
175172 return rx .match (
@@ -224,9 +221,7 @@ def get_cell_content(
224221 "+" ,
225222 "" ,
226223 )
227- + customer [
228- "active_license_growth"
229- ].to_string ()
224+ + customer ["active_license_growth" ].to_string ()
230225 + "%" ,
231226 class_name = rx .cond (
232227 customer ["active_license_growth" ] > 0 ,
@@ -261,16 +256,11 @@ def table_row(customer: CustomerData) -> rx.Component:
261256 return rx .el .tr (
262257 rx .foreach (
263258 DashboardState .column_data ,
264- lambda col_data : get_cell_content (
265- col_data [0 ], customer
266- ),
267- ),
268- on_click = lambda : DashboardState .select_customer (
269- customer ["id" ]
259+ lambda col_data : get_cell_content (col_data [0 ], customer ),
270260 ),
261+ on_click = lambda : DashboardState .select_customer (customer ["id" ]),
271262 class_name = rx .cond (
272- DashboardState .selected_customer_id
273- == customer ["id" ],
263+ DashboardState .selected_customer_id == customer ["id" ],
274264 "bg-emerald-50 border-l-4 border-emerald-500 cursor-pointer hover:bg-emerald-100 transition-colors duration-150 ease-in-out" ,
275265 "border-b border-gray-200 cursor-pointer hover:bg-gray-50 transition-colors duration-150 ease-in-out" ,
276266 ),
@@ -290,9 +280,7 @@ def data_table() -> rx.Component:
290280 rx .el .input (
291281 placeholder = "Search by customer name..." ,
292282 default_value = DashboardState .search_term ,
293- on_change = DashboardState .set_search_term .debounce (
294- 300
295- ),
283+ on_change = DashboardState .set_search_term .debounce (300 ),
296284 class_name = "w-full pl-10 pr-4 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent text-sm text-gray-800 placeholder-gray-500" ,
297285 ),
298286 class_name = "relative flex-grow" ,
@@ -334,11 +322,10 @@ def data_table() -> rx.Component:
334322 ),
335323 rx .el .div (
336324 rx .el .p (
337- DashboardState .result_count .to_string ()
338- + " results" ,
325+ DashboardState .result_count .to_string () + " results" ,
339326 class_name = "text-sm text-gray-500 mt-4" ,
340327 ),
341328 class_name = "flex justify-end" ,
342329 ),
343330 class_name = "bg-white p-6 rounded-lg shadow-md" ,
344- )
331+ )
0 commit comments