instruction
stringlengths
0
1k
input
stringlengths
1
1k
output
stringlengths
10
6.51k
rx.cond( is_active_column, rx.cond( DashboardState.sort_order == "asc", rx.icon( "arrow-up", size=12, class_name=active_icon_class, ), rx.icon( "arrow-down", size=12, ...
combined_class = f"{sortable_class} {text_align_class}" header_content_inner = rx.el.div( col_name, sort_icon(column_key), class_name="flex items-center group-hover:text-gray-700 transition-colors duration-150 ease-in-out", style={"justify_content": justify_content_val}, ) ...
justify_content_val = rx.match( col_name, ("Revenue", "flex-end"), ("Licenses", "center"), ("Active licenses", "center"), "flex-start", )
class_name=active_icon_class, ), rx.icon( "arrow-down", size=12, class_name=active_icon_class, ), ), rx.icon( "chevrons-up-down", size=12, class_name=inactive_icon_class, )...
header_content_inner = rx.el.div( col_name, sort_icon(column_key), class_name="flex items-center group-hover:text-gray-700 transition-colors duration-150 ease-in-out", style={"justify_content": justify_content_val}, ) return rx.el.th( header_content_inner, sc...
combined_class = f"{sortable_class} {text_align_class}"
rx.icon( "arrow-down", size=12, class_name=active_icon_class, ), ), rx.icon( "chevrons-up-down", size=12, class_name=inactive_icon_class, ), ) def sortable_table_header(col_name: str, column_ke...
return rx.el.th( header_content_inner, scope="col", class_name=combined_class, on_click=lambda: DashboardState.sort_by(column_key), ) def non_sortable_table_header( col_name: str, ) -> rx.Component: """Renders a non-sortable table header cell.""" base_class = ( ...
header_content_inner = rx.el.div( col_name, sort_icon(column_key), class_name="flex items-center group-hover:text-gray-700 transition-colors duration-150 ease-in-out", style={"justify_content": justify_content_val}, )
xt-left text-xs font-medium text-gray-500 uppercase tracking-wider group" sortable_class = f"{base_class} cursor-pointer" text_align_class = rx.match( col_name, ("Revenue", "text-right"), ("Licenses", "text-center"), ("Active licenses", "text-center"), "text-left", ) ...
def table_header( col_data: rx.Var[Tuple[str, Optional[SortColumn]]], ) -> rx.Component: """Renders a table header cell, deciding if it's sortable or not.""" col_name = col_data[0] column_key = col_data[1] return rx.cond( column_key, sortable_table_header(col_name, column_key.to(S...
def non_sortable_table_header( col_name: str, ) -> rx.Component: """Renders a non-sortable table header cell.""" base_class = ( "px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider" ) text_align_class = rx.match( col_name, ("Revenue", "text-right"),...
text_align_class = rx.match( col_name, ("Revenue", "text-right"), ("Licenses", "text-center"), ("Active licenses", "text-center"), "text-left", ) justify_content_val = rx.match( col_name, ("Revenue", "flex-end"), ("Licenses", "center"), ...
text_align_class = rx.match( col_name, ("Revenue", "text-right"), ("Licenses", "text-center"), ("Active licenses", "text-center"), "text-left", ) justify_content_val = rx.match( col_name, ("Revenue", "flex-end"), ("Licenses", "center"), ...
base_class = ( "px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider" )
center"), ("Active licenses", "text-center"), "text-left", ) justify_content_val = rx.match( col_name, ("Revenue", "flex-end"), ("Licenses", "center"), ("Active licenses", "center"), "flex-start", ) combined_class = f"{sortable_class} {text_align_c...
justify_content_val = rx.match( col_name, ("Revenue", "flex-end"), ("Licenses", "center"), ("Active licenses", "center"), "flex-start", ) combined_class = f"{base_class} {text_align_class}" header_content_inner = rx.el.div( col_name, class_name="f...
text_align_class = rx.match( col_name, ("Revenue", "text-right"), ("Licenses", "text-center"), ("Active licenses", "text-center"), "text-left", )
er"), ("Active licenses", "center"), "flex-start", ) combined_class = f"{sortable_class} {text_align_class}" header_content_inner = rx.el.div( col_name, sort_icon(column_key), class_name="flex items-center group-hover:text-gray-700 transition-colors duration-150 ease-...
combined_class = f"{base_class} {text_align_class}" header_content_inner = rx.el.div( col_name, class_name="flex items-center", style={"justify_content": justify_content_val}, ) return rx.el.th( header_content_inner, scope="col", class_name=combined_class...
justify_content_val = rx.match( col_name, ("Revenue", "flex-end"), ("Licenses", "center"), ("Active licenses", "center"), "flex-start", )
e, sort_icon(column_key), class_name="flex items-center group-hover:text-gray-700 transition-colors duration-150 ease-in-out", style={"justify_content": justify_content_val}, ) return rx.el.th( header_content_inner, scope="col", class_name=combined_class, ...
header_content_inner = rx.el.div( col_name, class_name="flex items-center", style={"justify_content": justify_content_val}, ) return rx.el.th( header_content_inner, scope="col", class_name=combined_class, ) def table_header( col_data: rx.Var[Tuple[s...
combined_class = f"{base_class} {text_align_class}"
ex items-center group-hover:text-gray-700 transition-colors duration-150 ease-in-out", style={"justify_content": justify_content_val}, ) return rx.el.th( header_content_inner, scope="col", class_name=combined_class, on_click=lambda: DashboardState.sort_by(column_key), ...
return rx.el.th( header_content_inner, scope="col", class_name=combined_class, ) def table_header( col_data: rx.Var[Tuple[str, Optional[SortColumn]]], ) -> rx.Component: """Renders a table header cell, deciding if it's sortable or not.""" col_name = col_data[0] column_...
header_content_inner = rx.el.div( col_name, class_name="flex items-center", style={"justify_content": justify_content_val}, )
ick=lambda: DashboardState.sort_by(column_key), ) def non_sortable_table_header( col_name: str, ) -> rx.Component: """Renders a non-sortable table header cell.""" base_class = ( "px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider" ) text_align_class = rx.mat...
def get_cell_content(col_name: rx.Var[str], customer: CustomerData) -> rx.Component: """Gets the appropriate component for a specific cell based on column name.""" base_class = "px-4 py-3 whitespace-nowrap text-sm" return rx.match( col_name, ( "ID", rx.el.td( ...
def table_header( col_data: rx.Var[Tuple[str, Optional[SortColumn]]], ) -> rx.Component: """Renders a table header cell, deciding if it's sortable or not.""" col_name = col_data[0] column_key = col_data[1] return rx.cond( column_key, sortable_table_header(col_name, column_key.to(Sort...
ll.""" base_class = ( "px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider" ) text_align_class = rx.match( col_name, ("Revenue", "text-right"), ("Licenses", "text-center"), ("Active licenses", "text-center"), "text-left", ) j...
column_key = col_data[1] return rx.cond( column_key, sortable_table_header(col_name, column_key.to(SortColumn)), non_sortable_table_header(col_name), ) def get_cell_content(col_name: rx.Var[str], customer: CustomerData) -> rx.Component: """Gets the appropriate component for a ...
col_name = col_data[0]
"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider" ) text_align_class = rx.match( col_name, ("Revenue", "text-right"), ("Licenses", "text-center"), ("Active licenses", "text-center"), "text-left", ) justify_content_val = rx.mat...
return rx.cond( column_key, sortable_table_header(col_name, column_key.to(SortColumn)), non_sortable_table_header(col_name), ) def get_cell_content(col_name: rx.Var[str], customer: CustomerData) -> rx.Component: """Gets the appropriate component for a specific cell based on column...
column_key = col_data[1]
e", "flex-end"), ("Licenses", "center"), ("Active licenses", "center"), "flex-start", ) combined_class = f"{base_class} {text_align_class}" header_content_inner = rx.el.div( col_name, class_name="flex items-center", style={"justify_content": justify_content_va...
return rx.match( col_name, ( "ID", rx.el.td( customer["id"], class_name=f"{base_class} text-gray-700 text-left", ), ), ( "Customer name", rx.el.td( customer["customer_name"], ...
base_class = "px-4 py-3 whitespace-nowrap text-sm"
( rx.cond( customer["active_license_growth"] > 0, "+", "", ) + customer["active_license_growth"].to_string() + "%", class_name=rx.cond( customer["active_license...
def data_table() -> rx.Component: """The main data table component including search and results count.""" return rx.el.div( rx.el.div( rx.el.div( rx.icon( "search", size=20, class_name="text-gray-400 absolute left...
def table_row(customer: CustomerData) -> rx.Component: """Renders a single row in the data table.""" return rx.el.tr( rx.foreach( DashboardState.column_data, lambda col_data: get_cell_content(col_data[0], customer), ), on_click=lambda: DashboardState.select_custom...
from admin_dashboard.states.navigation_state import NavigationState def navigation_item(text: str, href: str) -> rx.Component: """Creates a styled navigation link.""" return rx.el.a( text, href=href, class_name=rx.cond( NavigationState.current_page == href, "p...
import reflex as rx
import reflex as rx
def navigation_item(text: str, href: str) -> rx.Component: """Creates a styled navigation link.""" return rx.el.a( text, href=href, class_name=rx.cond( NavigationState.current_page == href, "px-4 py-2 text-sm font-medium text-white bg-emerald-700 rounded-md sha...
from admin_dashboard.states.navigation_state import NavigationState
from typing import ( Dict, List, Optional, TypedDict, Union, ) class CustomerData(TypedDict): id: int customer_name: str next_renewal: str revenue: float licenses: int active_licenses: int active_license_growth: int license_growth: int industry: str platfor...
from datetime import datetime
from typing import ( List, Literal, Optional, Tuple, ) import reflex as rx from admin_dashboard.models.models import CustomerData from admin_dashboard.states.data import initial_customer_data_raw from admin_dashboard.states.utils import parse_date SortColumn = Literal[ "id", "next_renewal", ...
from datetime import datetime
from datetime import datetime
import reflex as rx from admin_dashboard.models.models import CustomerData from admin_dashboard.states.data import initial_customer_data_raw from admin_dashboard.states.utils import parse_date SortColumn = Literal[ "id", "next_renewal", "revenue", "licenses", "active_licenses", ] SortOrder = Lit...
from typing import ( List, Literal, Optional, Tuple, )
from datetime import datetime from typing import ( List, Literal, Optional, Tuple, )
from admin_dashboard.models.models import CustomerData from admin_dashboard.states.data import initial_customer_data_raw from admin_dashboard.states.utils import parse_date SortColumn = Literal[ "id", "next_renewal", "revenue", "licenses", "active_licenses", ] SortOrder = Literal["asc", "desc"] ...
import reflex as rx
from datetime import datetime from typing import ( List, Literal, Optional, Tuple, ) import reflex as rx
from admin_dashboard.states.data import initial_customer_data_raw from admin_dashboard.states.utils import parse_date SortColumn = Literal[ "id", "next_renewal", "revenue", "licenses", "active_licenses", ] SortOrder = Literal["asc", "desc"] processed_customers: List[CustomerData] = [ { ...
from admin_dashboard.models.models import CustomerData
from datetime import datetime from typing import ( List, Literal, Optional, Tuple, ) import reflex as rx from admin_dashboard.models.models import CustomerData
from admin_dashboard.states.utils import parse_date SortColumn = Literal[ "id", "next_renewal", "revenue", "licenses", "active_licenses", ] SortOrder = Literal["asc", "desc"] processed_customers: List[CustomerData] = [ { **customer, "next_renewal_date": parse_date(customer["ne...
from admin_dashboard.states.data import initial_customer_data_raw
from datetime import datetime from typing import ( List, Literal, Optional, Tuple, ) import reflex as rx from admin_dashboard.models.models import CustomerData from admin_dashboard.states.data import initial_customer_data_raw
SortColumn = Literal[ "id", "next_renewal", "revenue", "licenses", "active_licenses", ] SortOrder = Literal["asc", "desc"] processed_customers: List[CustomerData] = [ { **customer, "next_renewal_date": parse_date(customer["next_renewal"]), } for customer in initial_cus...
from admin_dashboard.states.utils import parse_date
from datetime import datetime from typing import ( List, Literal, Optional, Tuple, ) import reflex as rx from admin_dashboard.models.models import CustomerData from admin_dashboard.states.data import initial_customer_data_raw from admin_dashboard.states.utils import parse_date
SortOrder = Literal["asc", "desc"] processed_customers: List[CustomerData] = [ { **customer, "next_renewal_date": parse_date(customer["next_renewal"]), } for customer in initial_customer_data_raw ] COLUMN_MAPPING: List[Tuple[str, Optional[SortColumn]]] = [ ("ID", "id"), ("Customer...
SortColumn = Literal[ "id", "next_renewal", "revenue", "licenses", "active_licenses", ]
n = Literal[ "id", "next_renewal", "revenue", "licenses", "active_licenses", ] SortOrder = Literal["asc", "desc"] processed_customers: List[CustomerData] = [ { **customer, "next_renewal_date": parse_date(customer["next_renewal"]), } for customer in initial_customer_data_...
@rx.var def filtered_customers(self) -> List[CustomerData]: """Returns the list of customers filtered by search term and sorted according to current settings.""" customers_to_process = list(self.customers) if self.search_term: search_lower = self.search_term.lower() ...
def column_data( self, ) -> List[Tuple[str, Optional[SortColumn]]]: """Returns the master list of column configurations (name and sort key).""" return COLUMN_MAPPING
= [ ("ID", "id"), ("Customer name", None), ("Next renewal", "next_renewal"), ("Revenue", "revenue"), ("Licenses", "licenses"), ("Active licenses", "active_licenses"), ("Active license growth", None), ("Industry", None), ("Platform", None), ] class DashboardState(rx.State): """...
if self.search_term: search_lower = self.search_term.lower() customers_to_process = [ customer for customer in customers_to_process if search_lower in customer["customer_name"].lower() ] if self.sort_column: ...
customers_to_process = list(self.customers)
("Next renewal", "next_renewal"), ("Revenue", "revenue"), ("Licenses", "licenses"), ("Active licenses", "active_licenses"), ("Active license growth", None), ("Industry", None), ("Platform", None), ] class DashboardState(rx.State): """State class managing the customer dashboard data and...
if self.sort_column: def get_sort_key(customer: CustomerData): sort_key = self.sort_column if sort_key == "next_renewal": date_val = customer.get("next_renewal_date") if date_val is None: return ( ...
if self.search_term: search_lower = self.search_term.lower() customers_to_process = [ customer for customer in customers_to_process if search_lower in customer["customer_name"].lower() ]
l"), ("Revenue", "revenue"), ("Licenses", "licenses"), ("Active licenses", "active_licenses"), ("Active license growth", None), ("Industry", None), ("Platform", None), ] class DashboardState(rx.State): """State class managing the customer dashboard data and UI interactions.""" custome...
customers_to_process = [ customer for customer in customers_to_process if search_lower in customer["customer_name"].lower() ] if self.sort_column: def get_sort_key(customer: CustomerData): sort_key = self.sort_...
search_lower = self.search_term.lower()
icenses"), ("Active licenses", "active_licenses"), ("Active license growth", None), ("Industry", None), ("Platform", None), ] class DashboardState(rx.State): """State class managing the customer dashboard data and UI interactions.""" customers: List[CustomerData] = processed_customers sel...
if self.sort_column: def get_sort_key(customer: CustomerData): sort_key = self.sort_column if sort_key == "next_renewal": date_val = customer.get("next_renewal_date") if date_val is None: return ( ...
customers_to_process = [ customer for customer in customers_to_process if search_lower in customer["customer_name"].lower() ]
ata] = processed_customers selected_customer_id: Optional[int] = None search_term: str = "" sort_column: Optional[SortColumn] = "id" sort_order: SortOrder = "asc" @rx.var def column_data( self, ) -> List[Tuple[str, Optional[SortColumn]]]: """Returns the master list of column...
if sort_key == "next_renewal": date_val = customer.get("next_renewal_date") if date_val is None: return ( datetime.max if self.sort_order == "asc" else datetime.min ) ...
sort_key = self.sort_column
= "" sort_column: Optional[SortColumn] = "id" sort_order: SortOrder = "asc" @rx.var def column_data( self, ) -> List[Tuple[str, Optional[SortColumn]]]: """Returns the master list of column configurations (name and sort key).""" return COLUMN_MAPPING @rx.var def filt...
if date_val is None: return ( datetime.max if self.sort_order == "asc" else datetime.min ) return date_val elif sort_key in [ "id", "revenue", ...
date_val = customer.get("next_renewal_date")
SortOrder = "asc" @rx.var def column_data( self, ) -> List[Tuple[str, Optional[SortColumn]]]: """Returns the master list of column configurations (name and sort key).""" return COLUMN_MAPPING @rx.var def filtered_customers(self) -> List[CustomerData]: """Returns th...
return date_val elif sort_key in [ "id", "revenue", "licenses", "active_licenses", ]: key_value = customer.get(sort_key) return key_value if isinst...
if date_val is None: return ( datetime.max if self.sort_order == "asc" else datetime.min )
MN_MAPPING @rx.var def filtered_customers(self) -> List[CustomerData]: """Returns the list of customers filtered by search term and sorted according to current settings.""" customers_to_process = list(self.customers) if self.search_term: search_lower = self.search_term.lower...
customers_to_process = sorted( customers_to_process, key=get_sort_key, reverse=self.sort_order == "desc", ) return customers_to_process @rx.var def selected_customer(self) -> Optional[CustomerData]: """Returns the full da...
elif sort_key in [ "id", "revenue", "licenses", "active_licenses", ]: key_value = customer.get(sort_key) return key_value if isinstance(key_value, (int, float)) else 0 ...
""" customers_to_process = list(self.customers) if self.search_term: search_lower = self.search_term.lower() customers_to_process = [ customer for customer in customers_to_process if search_lower in customer["customer_name"].lower()...
return key_value if isinstance(key_value, (int, float)) else 0 else: return 0 customers_to_process = sorted( customers_to_process, key=get_sort_key, reverse=self.sort_order == "desc", ) ...
key_value = customer.get(sort_key)
customer for customer in customers_to_process if search_lower in customer["customer_name"].lower() ] if self.sort_column: def get_sort_key(customer: CustomerData): sort_key = self.sort_column if sort_key == "next_re...
return customers_to_process @rx.var def selected_customer(self) -> Optional[CustomerData]: """Returns the full data dictionary for the currently selected customer, or None if no selection.""" if self.selected_customer_id is None: return None for customer in self.cus...
customers_to_process = sorted( customers_to_process, key=get_sort_key, reverse=self.sort_order == "desc", )
CustomerData): sort_key = self.sort_column if sort_key == "next_renewal": date_val = customer.get("next_renewal_date") if date_val is None: return ( datetime.max if self.sort_order == "asc" else ...
@rx.var def result_count(self) -> int: """Returns the number of customers currently displayed in the table (after filtering).""" return len(self.filtered_customers) @rx.event def select_customer(self, customer_id: int): """Handles clicking on a customer row. Selects the custom...
def selected_customer(self) -> Optional[CustomerData]: """Returns the full data dictionary for the currently selected customer, or None if no selection.""" if self.selected_customer_id is None: return None for customer in self.customers: if customer["id"] == self.selected...
if date_val is None: return ( datetime.max if self.sort_order == "asc" else datetime.min ) return date_val elif sort_key in [ "id", "revenue", ...
for customer in self.customers: if customer["id"] == self.selected_customer_id: return customer return None @rx.var def result_count(self) -> int: """Returns the number of customers currently displayed in the table (after filtering).""" return len(se...
if self.selected_customer_id is None: return None
n ( datetime.max if self.sort_order == "asc" else datetime.min ) return date_val elif sort_key in [ "id", "revenue", "licenses", "active_licenses", ...
return None @rx.var def result_count(self) -> int: """Returns the number of customers currently displayed in the table (after filtering).""" return len(self.filtered_customers) @rx.event def select_customer(self, customer_id: int): """Handles clicking on a customer row...
for customer in self.customers: if customer["id"] == self.selected_customer_id: return customer
if self.sort_order == "asc" else datetime.min ) return date_val elif sort_key in [ "id", "revenue", "licenses", "active_licenses", ]: key_value...
return None @rx.var def result_count(self) -> int: """Returns the number of customers currently displayed in the table (after filtering).""" return len(self.filtered_customers) @rx.event def select_customer(self, customer_id: int): """Handles clicking on a customer row...
if customer["id"] == self.selected_customer_id: return customer
elif sort_key in [ "id", "revenue", "licenses", "active_licenses", ]: key_value = customer.get(sort_key) return key_value if isinstance(key_value, (int, float)) else 0 ...
@rx.event def select_customer(self, customer_id: int): """Handles clicking on a customer row. Selects the customer or deselects if already selected.""" if self.selected_customer_id == customer_id: self.selected_customer_id = None else: self.selected_customer_id ...
def result_count(self) -> int: """Returns the number of customers currently displayed in the table (after filtering).""" return len(self.filtered_customers)
key_value = customer.get(sort_key) return key_value if isinstance(key_value, (int, float)) else 0 else: return 0 customers_to_process = sorted( customers_to_process, key=get_sort_key, reverse=self.sort...
@rx.event def set_search_term(self, term: str): """Updates the search term based on user input.""" self.search_term = term if self.selected_customer_id is not None: found = any( ( customer["id"] == self.selected_customer_id ...
def select_customer(self, customer_id: int): """Handles clicking on a customer row. Selects the customer or deselects if already selected.""" if self.selected_customer_id == customer_id: self.selected_customer_id = None else: self.selected_customer_id = customer_id
return 0 customers_to_process = sorted( customers_to_process, key=get_sort_key, reverse=self.sort_order == "desc", ) return customers_to_process @rx.var def selected_customer(self) -> Optional[CustomerData]: """Returns...
@rx.event def set_search_term(self, term: str): """Updates the search term based on user input.""" self.search_term = term if self.selected_customer_id is not None: found = any( ( customer["id"] == self.selected_customer_id ...
if self.selected_customer_id == customer_id: self.selected_customer_id = None else: self.selected_customer_id = customer_id
customers_to_process, key=get_sort_key, reverse=self.sort_order == "desc", ) return customers_to_process @rx.var def selected_customer(self) -> Optional[CustomerData]: """Returns the full data dictionary for the currently selected cust...
else: self.selected_customer_id = customer_id @rx.event def set_search_term(self, term: str): """Updates the search term based on user input.""" self.search_term = term if self.selected_customer_id is not None: found = any( ( ...
self.selected_customer_id = None
et_sort_key, reverse=self.sort_order == "desc", ) return customers_to_process @rx.var def selected_customer(self) -> Optional[CustomerData]: """Returns the full data dictionary for the currently selected customer, or None if no selection.""" if self.selected_...
@rx.event def set_search_term(self, term: str): """Updates the search term based on user input.""" self.search_term = term if self.selected_customer_id is not None: found = any( ( customer["id"] == self.selected_customer_id ...
self.selected_customer_id = customer_id
sc", ) return customers_to_process @rx.var def selected_customer(self) -> Optional[CustomerData]: """Returns the full data dictionary for the currently selected customer, or None if no selection.""" if self.selected_customer_id is None: return None for cu...
@rx.event def sort_by(self, column_key: SortColumn): """Handles clicking on a sortable table header. Updates the sort column and order.""" if self.sort_column == column_key: self.sort_order = "desc" if self.sort_order == "asc" else "asc" else: self.sort_column =...
def set_search_term(self, term: str): """Updates the search term based on user input.""" self.search_term = term if self.selected_customer_id is not None: found = any( ( customer["id"] == self.selected_customer_id for customer i...
tional[CustomerData]: """Returns the full data dictionary for the currently selected customer, or None if no selection.""" if self.selected_customer_id is None: return None for customer in self.customers: if customer["id"] == self.selected_customer_id: ret...
if self.selected_customer_id is not None: found = any( ( customer["id"] == self.selected_customer_id for customer in self.filtered_customers ) ) if not found: self.selected_customer_id = ...
self.search_term = term
"Returns the full data dictionary for the currently selected customer, or None if no selection.""" if self.selected_customer_id is None: return None for customer in self.customers: if customer["id"] == self.selected_customer_id: return customer return None...
@rx.event def sort_by(self, column_key: SortColumn): """Handles clicking on a sortable table header. Updates the sort column and order.""" if self.sort_column == column_key: self.sort_order = "desc" if self.sort_order == "asc" else "asc" else: self.sort_column =...
if self.selected_customer_id is not None: found = any( ( customer["id"] == self.selected_customer_id for customer in self.filtered_customers ) ) if not found: self.selected_customer_id = None
lected customer, or None if no selection.""" if self.selected_customer_id is None: return None for customer in self.customers: if customer["id"] == self.selected_customer_id: return customer return None @rx.var def result_count(self) -> int: ...
if not found: self.selected_customer_id = None @rx.event def sort_by(self, column_key: SortColumn): """Handles clicking on a sortable table header. Updates the sort column and order.""" if self.sort_column == column_key: self.sort_order = "desc" if self....
found = any( ( customer["id"] == self.selected_customer_id for customer in self.filtered_customers ) )
ed_customer_id: return customer return None @rx.var def result_count(self) -> int: """Returns the number of customers currently displayed in the table (after filtering).""" return len(self.filtered_customers) @rx.event def select_customer(self, customer_id: int)...
@rx.event def sort_by(self, column_key: SortColumn): """Handles clicking on a sortable table header. Updates the sort column and order.""" if self.sort_column == column_key: self.sort_order = "desc" if self.sort_order == "asc" else "asc" else: self.sort_column =...
if not found: self.selected_customer_id = None
return customer return None @rx.var def result_count(self) -> int: """Returns the number of customers currently displayed in the table (after filtering).""" return len(self.filtered_customers) @rx.event def select_customer(self, customer_id: int): """Handles clicking ...
@rx.event def sort_by(self, column_key: SortColumn): """Handles clicking on a sortable table header. Updates the sort column and order.""" if self.sort_column == column_key: self.sort_order = "desc" if self.sort_order == "asc" else "asc" else: self.sort_column =...
self.selected_customer_id = None
def result_count(self) -> int: """Returns the number of customers currently displayed in the table (after filtering).""" return len(self.filtered_customers) @rx.event def select_customer(self, customer_id: int): """Handles clicking on a customer row. Selects the customer or deselects...
def sort_by(self, column_key: SortColumn): """Handles clicking on a sortable table header. Updates the sort column and order.""" if self.sort_column == column_key: self.sort_order = "desc" if self.sort_order == "asc" else "asc" else: self.sort_column = column_key ...
n len(self.filtered_customers) @rx.event def select_customer(self, customer_id: int): """Handles clicking on a customer row. Selects the customer or deselects if already selected.""" if self.selected_customer_id == customer_id: self.selected_customer_id = None else: ...
if self.sort_column == column_key: self.sort_order = "desc" if self.sort_order == "asc" else "asc" else: self.sort_column = column_key self.sort_order = "asc"
def select_customer(self, customer_id: int): """Handles clicking on a customer row. Selects the customer or deselects if already selected.""" if self.selected_customer_id == customer_id: self.selected_customer_id = None else: self.selected_customer_id = customer_id ...
else: self.sort_column = column_key self.sort_order = "asc"
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
row. Selects the customer or deselects if already selected.""" if self.selected_customer_id == customer_id: self.selected_customer_id = None else: self.selected_customer_id = customer_id @rx.event def set_search_term(self, term: str): """Updates the search term b...
self.sort_order = "asc"
self.sort_column = column_key
already selected.""" if self.selected_customer_id == customer_id: self.selected_customer_id = None else: self.selected_customer_id = customer_id @rx.event def set_search_term(self, term: str): """Updates the search term based on user input.""" self.search...
self.sort_order = "asc"
class NavigationState(rx.State): """State for managing navigation.""" @rx.var def current_page(self) -> str: """Get the current page route.""" return self.router.url.path
import reflex as rx
from typing import Optional def parse_date(date_str: str) -> Optional[datetime]: """Helper function to parse date strings into datetime objects. Handles common formats found in the data. Returns None if parsing fails. """ try: return datetime.strptime(date_str, "%b %d, %Y") except ValueEr...
from datetime import datetime
from datetime import datetime
def parse_date(date_str: str) -> Optional[datetime]: """Helper function to parse date strings into datetime objects. Handles common formats found in the data. Returns None if parsing fails. """ try: return datetime.strptime(date_str, "%b %d, %Y") except ValueError: try: ...
from typing import Optional
from admin_panel.components.customer_form import customer_edit_form from admin_panel.components.customer_table import customer_table from admin_panel.states.customer_state import CustomerState def index() -> rx.Component: return rx.el.div( rx.el.main( rx.el.div( rx.cond( ...
import reflex as rx
import reflex as rx
from admin_panel.components.customer_table import customer_table from admin_panel.states.customer_state import CustomerState def index() -> rx.Component: return rx.el.div( rx.el.main( rx.el.div( rx.cond( CustomerState.error_message != "", ...
from admin_panel.components.customer_form import customer_edit_form
import reflex as rx from admin_panel.components.customer_form import customer_edit_form
from admin_panel.states.customer_state import CustomerState def index() -> rx.Component: return rx.el.div( rx.el.main( rx.el.div( rx.cond( CustomerState.error_message != "", rx.el.div( CustomerState.error_message,...
from admin_panel.components.customer_table import customer_table
import reflex as rx from admin_panel.components.customer_form import customer_edit_form from admin_panel.components.customer_table import customer_table
def index() -> rx.Component: return rx.el.div( rx.el.main( rx.el.div( rx.cond( CustomerState.error_message != "", rx.el.div( CustomerState.error_message, class_name=rx.cond( ...
from admin_panel.states.customer_state import CustomerState
from admin_panel.states.customer_state import CustomerState def customer_edit_form() -> rx.Component: return rx.el.dialog( rx.el.div( rx.el.h2( rx.cond( CustomerState.form_customer_id == 0, "Add New User", "Edit User...
import reflex as rx
import reflex as rx
def customer_edit_form() -> rx.Component: return rx.el.dialog( rx.el.div( rx.el.h2( rx.cond( CustomerState.form_customer_id == 0, "Add New User", "Edit User", ), class_name="text-lg sm:...
from admin_panel.states.customer_state import CustomerState
from admin_panel.states.customer_state import CustomerData, CustomerState def sortable_table_header_cell(text: str, column_key: str, icon: str) -> rx.Component: return rx.el.th( rx.el.div( rx.icon( tag=icon, size=16, class_name="text-gray-500",...
import reflex as rx
import reflex as rx
def sortable_table_header_cell(text: str, column_key: str, icon: str) -> rx.Component: return rx.el.th( rx.el.div( rx.icon( tag=icon, size=16, class_name="text-gray-500", ), text, rx.cond( Cust...
from admin_panel.states.customer_state import CustomerData, CustomerState
import reflex as rx from admin_panel.states.customer_state import CustomerData, CustomerState
def static_table_header_cell(text: str, icon: str) -> rx.Component: return rx.el.th( rx.el.div( rx.icon( tag=icon, size=16, class_name="text-gray-500", ), text, class_name="flex flex-row items-center gap-2", ...
def sortable_table_header_cell(text: str, column_key: str, icon: str) -> rx.Component: return rx.el.th( rx.el.div( rx.icon( tag=icon, size=16, class_name="text-gray-500", ), text, rx.cond( Custome...
def sortable_table_header_cell(text: str, column_key: str, icon: str) -> rx.Component: return rx.el.th( rx.el.div( rx.icon( tag=icon, size=16, class_name="text-gray-500", ), text, rx.cond( Custom...
def customer_table_header() -> rx.Component: return rx.el.thead( rx.el.tr( sortable_table_header_cell("Name", "name", "user"), sortable_table_header_cell("Status", "status", "target"), sortable_table_header_cell("Role", "role", "briefcase-business"), static...
def static_table_header_cell(text: str, icon: str) -> rx.Component: return rx.el.th( rx.el.div( rx.icon( tag=icon, size=16, class_name="text-gray-500", ), text, class_name="flex flex-row items-center gap-2", ...
CustomerState.sort_order == "asc", "chevron_up", "chevron_down", ), size=16, class_name="text-gray-700 w-[16px]", ), rx.fragment(), ), class_name="flex gap...
def status_badge(status: str) -> rx.Component: return rx.el.div( rx.el.div( class_name=rx.match( status, ( "Active", "h-1.5 w-1.5 rounded-full bg-teal-500", ), ( "Onboar...
def customer_table_header() -> rx.Component: return rx.el.thead( rx.el.tr( sortable_table_header_cell("Name", "name", "user"), sortable_table_header_cell("Status", "status", "target"), sortable_table_header_cell("Role", "role", "briefcase-business"), static_ta...
"Onboarding", "inline-flex items-center gap-x-1.5 rounded-md px-2 py-1 text-xs font-medium text-yellow-700 bg-yellow-100 ring-1 ring-inset ring-yellow-200", ), ( "Pending", "inline-flex items-center gap-x-1.5 rounded-md px-2 py-1 text-xs...
def customer_table_row( customer: CustomerData, ) -> rx.Component: return rx.el.tr( rx.el.td( rx.el.div( rx.image( src=f"https://api.dicebear.com/9.x/micah/svg?seed={customer['email']}", class_name="size-8 rounded-full mr-2 sm:mr-3 b...
def tag_item(tag_name: str) -> rx.Component: return rx.el.div( tag_name, class_name="inline-flex items-center rounded-full bg-gray-50 px-2 py-1 text-xs font-medium text-gray-600 ring-1 ring-inset ring-gray-500/10", )
pace-nowrap text-sm", ), rx.el.td( status_badge(customer["status"]), class_name="px-3 py-4 whitespace-nowrap text-sm", ), rx.el.td( customer["role"], class_name="px-3 py-4 whitespace-nowrap text-sm text-gray-500", ), rx.el.t...
def customer_table() -> rx.Component: return rx.el.div( rx.el.div( rx.el.div( rx.el.div( rx.icon( tag="users", size=20, class_name="text-gray-500", ), ...
def pagination_controls() -> rx.Component: return rx.el.div( rx.el.button( "Previous", on_click=CustomerState.prev_page, disabled=CustomerState.current_page <= 1, class_name="px-3 py-2 sm:px-4 text-xs sm:text-sm font-medium text-gray-700 bg-white border border...
import math import random from typing import List, Set, TypedDict from typing import Optional as TypingOptional import pandas as pd import reflex as rx class CustomerData(TypedDict): customer_id: int first_name: str last_name: str email: str phone: TypingOptional[str] status: str avatar_...
import datetime
import datetime
import random from typing import List, Set, TypedDict from typing import Optional as TypingOptional import pandas as pd import reflex as rx class CustomerData(TypedDict): customer_id: int first_name: str last_name: str email: str phone: TypingOptional[str] status: str avatar_url: str ...
import math
import datetime import math
from typing import List, Set, TypedDict from typing import Optional as TypingOptional import pandas as pd import reflex as rx class CustomerData(TypedDict): customer_id: int first_name: str last_name: str email: str phone: TypingOptional[str] status: str avatar_url: str role: str ...
import random
import datetime import math import random
from typing import Optional as TypingOptional import pandas as pd import reflex as rx class CustomerData(TypedDict): customer_id: int first_name: str last_name: str email: str phone: TypingOptional[str] status: str avatar_url: str role: str tags: List[str] created_at: str ...
from typing import List, Set, TypedDict
import datetime import math import random from typing import List, Set, TypedDict
import pandas as pd import reflex as rx class CustomerData(TypedDict): customer_id: int first_name: str last_name: str email: str phone: TypingOptional[str] status: str avatar_url: str role: str tags: List[str] created_at: str updated_at: str selected: bool class Cu...
from typing import Optional as TypingOptional
import datetime import math import random from typing import List, Set, TypedDict from typing import Optional as TypingOptional
import reflex as rx class CustomerData(TypedDict): customer_id: int first_name: str last_name: str email: str phone: TypingOptional[str] status: str avatar_url: str role: str tags: List[str] created_at: str updated_at: str selected: bool class CustomerState(rx.State)...
import pandas as pd
import datetime import math import random from typing import List, Set, TypedDict from typing import Optional as TypingOptional import pandas as pd
class CustomerData(TypedDict): customer_id: int first_name: str last_name: str email: str phone: TypingOptional[str] status: str avatar_url: str role: str tags: List[str] created_at: str updated_at: str selected: bool class CustomerState(rx.State): _all_customers...
import reflex as rx
import datetime import math import random from typing import List, Set, TypedDict from typing import Optional as TypingOptional import pandas as pd import reflex as rx
class CustomerState(rx.State): _all_customers_data: List[CustomerData] = [] loading: bool = False error_message: str = "" show_edit_dialog: bool = False form_customer_id: int = 0 form_first_name: str = "" form_last_name: str = "" form_email: str = "" form_status: str = "Active" ...
class CustomerData(TypedDict): customer_id: int first_name: str last_name: str email: str phone: TypingOptional[str] status: str avatar_url: str role: str tags: List[str] created_at: str updated_at: str selected: bool
= "" form_role: str = "" customer_statuses: List[str] = [ "Active", "Onboarding", "Inactive", "Pending", "Suspended", ] all_selected: bool = False available_roles: List[str] = [ "Administrator", "Accounting", "Product Designer", ...
@rx.var def total_pages(self) -> int: num_items = len(self._processed_customers) if ( self.items_per_page <= 0 ): # Guard against division by zero or invalid items_per_page return 0 if num_items == 0: return 0 return math.ceil(num_it...
def total_users(self) -> int: return len(self._processed_customers)
Onboarding", "Inactive", "Pending", "Suspended", ] all_selected: bool = False available_roles: List[str] = [ "Administrator", "Accounting", "Product Designer", "Human Resources", "Devops", "Hiring Manager", "Customer Success", ...
@rx.var def _processed_customers(self) -> List[CustomerData]: data_to_process = list( self._all_customers_data ) # Make a copy to avoid modifying the original list if needed elsewhere # Apply search filter if self.search_query and self.search_query.strip(): ...
def total_pages(self) -> int: num_items = len(self._processed_customers) if ( self.items_per_page <= 0 ): # Guard against division by zero or invalid items_per_page return 0 if num_items == 0: return 0 return math.ceil(num_items / self.items_p...
"Pending", "Suspended", ] all_selected: bool = False available_roles: List[str] = [ "Administrator", "Accounting", "Product Designer", "Human Resources", "Devops", "Hiring Manager", "Customer Success", ] available_tags: List[str] = [...
if ( self.items_per_page <= 0 ): # Guard against division by zero or invalid items_per_page return 0 if num_items == 0: return 0 return math.ceil(num_items / self.items_per_page) @rx.var def _processed_customers(self) -> List[CustomerData]: ...
num_items = len(self._processed_customers)
lected: bool = False available_roles: List[str] = [ "Administrator", "Accounting", "Product Designer", "Human Resources", "Devops", "Hiring Manager", "Customer Success", ] available_tags: List[str] = [ "Collaboration", "Leadership", ...
if num_items == 0: return 0 return math.ceil(num_items / self.items_per_page) @rx.var def _processed_customers(self) -> List[CustomerData]: data_to_process = list( self._all_customers_data ) # Make a copy to avoid modifying the original list if needed e...
if ( self.items_per_page <= 0 ): # Guard against division by zero or invalid items_per_page return 0
man Resources", "Devops", "Hiring Manager", "Customer Success", ] available_tags: List[str] = [ "Collaboration", "Leadership", "Innovation", "Creativity", "Feedback", "Coaching", "Mentoring", "Delegation", ] sort_col...
return math.ceil(num_items / self.items_per_page) @rx.var def _processed_customers(self) -> List[CustomerData]: data_to_process = list( self._all_customers_data ) # Make a copy to avoid modifying the original list if needed elsewhere # Apply search filter ...
if num_items == 0: return 0
"Innovation", "Creativity", "Feedback", "Coaching", "Mentoring", "Delegation", ] sort_column: str = "name" sort_order: str = "asc" current_page: int = 1 items_per_page: int = 10 total_db_customers: int = 0 _target_customer_email_for_tags: str | N...
# Make a copy to avoid modifying the original list if needed elsewhere # Apply search filter if self.search_query and self.search_query.strip(): query_lower = self.search_query.lower().strip() data_to_process = [ c for c in data_to_process ...
data_to_process = list( self._all_customers_data )
"asc" current_page: int = 1 items_per_page: int = 10 total_db_customers: int = 0 _target_customer_email_for_tags: str | None = None _target_customer_tag_str: str | None = None _target_customer_role: str | None = None _next_customer_id: int = 1 search_query: str = "" @rx.var def...
# Apply sorting def get_sort_value(customer_data_item: CustomerData): if self.sort_column == "name": first = customer_data_item.get("first_name", "") last = customer_data_item.get("last_name", "") return (first.lower(), last.lower()) ...
if self.search_query and self.search_query.strip(): query_lower = self.search_query.lower().strip() data_to_process = [ c for c in data_to_process if query_lower in f"{c.get('first_name', '')} {c.get('last_name', '')}".lower() ...
total_db_customers: int = 0 _target_customer_email_for_tags: str | None = None _target_customer_tag_str: str | None = None _target_customer_role: str | None = None _next_customer_id: int = 1 search_query: str = "" @rx.var def total_users(self) -> int: return len(self._processed_cu...
data_to_process = [ c for c in data_to_process if query_lower in f"{c.get('first_name', '')} {c.get('last_name', '')}".lower() ] # Apply sorting def get_sort_value(customer_data_item: CustomerData): if ...
query_lower = self.search_query.lower().strip()
_tags: str | None = None _target_customer_tag_str: str | None = None _target_customer_role: str | None = None _next_customer_id: int = 1 search_query: str = "" @rx.var def total_users(self) -> int: return len(self._processed_customers) @rx.var def total_pages(self) -> int: ...
# Apply sorting def get_sort_value(customer_data_item: CustomerData): if self.sort_column == "name": first = customer_data_item.get("first_name", "") last = customer_data_item.get("last_name", "") return (first.lower(), last.lower()) ...
data_to_process = [ c for c in data_to_process if query_lower in f"{c.get('first_name', '')} {c.get('last_name', '')}".lower() ]
len(self._processed_customers) @rx.var def total_pages(self) -> int: num_items = len(self._processed_customers) if ( self.items_per_page <= 0 ): # Guard against division by zero or invalid items_per_page return 0 if num_items == 0: return 0 ...
sorted_data = sorted( data_to_process, key=get_sort_value, reverse=self.sort_order == "desc", ) return sorted_data @rx.var def customers(self) -> List[CustomerData]: data_for_page = self._processed_customers start_index = (self.curre...
def get_sort_value(customer_data_item: CustomerData): if self.sort_column == "name": first = customer_data_item.get("first_name", "") last = customer_data_item.get("last_name", "") return (first.lower(), last.lower()) sort_val = customer_data_item...
lf) -> int: num_items = len(self._processed_customers) if ( self.items_per_page <= 0 ): # Guard against division by zero or invalid items_per_page return 0 if num_items == 0: return 0 return math.ceil(num_items / self.items_per_page) @rx....
sort_val = customer_data_item.get(self.sort_column) if isinstance(sort_val, str): return sort_val.lower() return sort_val sorted_data = sorted( data_to_process, key=get_sort_value, reverse=self.sort_order == "desc", ...
if self.sort_column == "name": first = customer_data_item.get("first_name", "") last = customer_data_item.get("last_name", "") return (first.lower(), last.lower())
ssed_customers) if ( self.items_per_page <= 0 ): # Guard against division by zero or invalid items_per_page return 0 if num_items == 0: return 0 return math.ceil(num_items / self.items_per_page) @rx.var def _processed_customers(self) -> List[...
last = customer_data_item.get("last_name", "") return (first.lower(), last.lower()) sort_val = customer_data_item.get(self.sort_column) if isinstance(sort_val, str): return sort_val.lower() return sort_val sorted_data = sorte...
first = customer_data_item.get("first_name", "")
): # Guard against division by zero or invalid items_per_page return 0 if num_items == 0: return 0 return math.ceil(num_items / self.items_per_page) @rx.var def _processed_customers(self) -> List[CustomerData]: data_to_process = list( self._...
return (first.lower(), last.lower()) sort_val = customer_data_item.get(self.sort_column) if isinstance(sort_val, str): return sort_val.lower() return sort_val sorted_data = sorted( data_to_process, key=get_sort_value,...
last = customer_data_item.get("last_name", "")
== 0: return 0 return math.ceil(num_items / self.items_per_page) @rx.var def _processed_customers(self) -> List[CustomerData]: data_to_process = list( self._all_customers_data ) # Make a copy to avoid modifying the original list if needed elsewhere # A...
if isinstance(sort_val, str): return sort_val.lower() return sort_val sorted_data = sorted( data_to_process, key=get_sort_value, reverse=self.sort_order == "desc", ) return sorted_data @rx.var def customers(se...
sort_val = customer_data_item.get(self.sort_column)
self.items_per_page) @rx.var def _processed_customers(self) -> List[CustomerData]: data_to_process = list( self._all_customers_data ) # Make a copy to avoid modifying the original list if needed elsewhere # Apply search filter if self.search_query and self.search_...
return sort_val sorted_data = sorted( data_to_process, key=get_sort_value, reverse=self.sort_order == "desc", ) return sorted_data @rx.var def customers(self) -> List[CustomerData]: data_for_page = self._processed_customers ...
if isinstance(sort_val, str): return sort_val.lower()
o_process = list( self._all_customers_data ) # Make a copy to avoid modifying the original list if needed elsewhere # Apply search filter if self.search_query and self.search_query.strip(): query_lower = self.search_query.lower().strip() data_to_process = [ ...
return sorted_data @rx.var def customers(self) -> List[CustomerData]: data_for_page = self._processed_customers start_index = (self.current_page - 1) * self.items_per_page end_index = start_index + self.items_per_page return data_for_page[start_index:end_index] def...
sorted_data = sorted( data_to_process, key=get_sort_value, reverse=self.sort_order == "desc", )
search_query and self.search_query.strip(): query_lower = self.search_query.lower().strip() data_to_process = [ c for c in data_to_process if query_lower in f"{c.get('first_name', '')} {c.get('last_name', '')}".lower() ]...
def _parse_tags_string(self, tags_str: str | None) -> List[str]: if not tags_str: return [] tag_names_from_input = [ name.strip() for name in tags_str.split(",") if name.strip() ] unique_tags: List[str] = [] seen_tags: Set[str] = set() for ta...
def customers(self) -> List[CustomerData]: data_for_page = self._processed_customers start_index = (self.current_page - 1) * self.items_per_page end_index = start_index + self.items_per_page return data_for_page[start_index:end_index]
query_lower = self.search_query.lower().strip() data_to_process = [ c for c in data_to_process if query_lower in f"{c.get('first_name', '')} {c.get('last_name', '')}".lower() ] # Apply sorting def get_sort_valu...
start_index = (self.current_page - 1) * self.items_per_page end_index = start_index + self.items_per_page return data_for_page[start_index:end_index] def _parse_tags_string(self, tags_str: str | None) -> List[str]: if not tags_str: return [] tag_names_from_input...
data_for_page = self._processed_customers
() data_to_process = [ c for c in data_to_process if query_lower in f"{c.get('first_name', '')} {c.get('last_name', '')}".lower() ] # Apply sorting def get_sort_value(customer_data_item: CustomerData): i...
end_index = start_index + self.items_per_page return data_for_page[start_index:end_index] def _parse_tags_string(self, tags_str: str | None) -> List[str]: if not tags_str: return [] tag_names_from_input = [ name.strip() for name in tags_str.split(",") if nam...
start_index = (self.current_page - 1) * self.items_per_page
for c in data_to_process if query_lower in f"{c.get('first_name', '')} {c.get('last_name', '')}".lower() ] # Apply sorting def get_sort_value(customer_data_item: CustomerData): if self.sort_column == "name": first = customer_data_...
return data_for_page[start_index:end_index] def _parse_tags_string(self, tags_str: str | None) -> List[str]: if not tags_str: return [] tag_names_from_input = [ name.strip() for name in tags_str.split(",") if name.strip() ] unique_tags: List[str] = [...
end_index = start_index + self.items_per_page
{c.get('last_name', '')}".lower() ] # Apply sorting def get_sort_value(customer_data_item: CustomerData): if self.sort_column == "name": first = customer_data_item.get("first_name", "") last = customer_data_item.get("last_name", "") ...
def _format_tags_list_to_string(self, tags_list: List[str]) -> str: return ", ".join(tags_list) @rx.event def sort_by_column(self, column_name: str): if self.sort_column == column_name: self.sort_order = "desc" if self.sort_order == "asc" else "asc" else: s...
def _parse_tags_string(self, tags_str: str | None) -> List[str]: if not tags_str: return [] tag_names_from_input = [ name.strip() for name in tags_str.split(",") if name.strip() ] unique_tags: List[str] = [] seen_tags: Set[str] = set() for tag in t...