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,
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_key: SortColumn) -> rx.Component:
"""Renders a sortable table header cell."""
base_class = "px-4 py-3 text-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",
)
|
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},
)
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 = (
"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.match(
col_name,
("Revenue", "f | 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,
),
)
def sortable_table_header(col_name: str, column_key: SortColumn) -> rx.Component:
"""Renders a sortable table header cell."""
base_class = "px-4 py-3 text-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",
)
justify_content_val = rx.match(
col_name,
("Revenue", "flex-end"),
("Licenses", "center"),
("Active licenses", "center"),
"flex-start",
)
|
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,
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 = (
"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.match(
col_name,
("Revenue", "flex-end"),
("Licenses", "center"),
("Active | 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_key: SortColumn) -> rx.Component:
"""Renders a sortable table header cell."""
base_class = "px-4 py-3 text-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",
)
justify_content_val = rx.match(
col_name,
("Revenue", "flex-end"),
("Licenses", "center"),
("Active licenses", "center"),
"flex-start",
)
combined_class = f"{sortable_class} {text_align_class}"
|
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 = (
"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.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="flex items-center",
style={"justify_content": justify_content_val},
| 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",
)
justify_content_val = rx.match(
col_name,
("Revenue", "flex-end"),
("Licenses", "center"),
("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-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),
)
|
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(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 name."""
base_class = "px-4 py-3 whitespace-nowrap text-sm"
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"],
class_name=f"{base_class} font-medium text-gray-900 text | 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"),
("Licenses", "text-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"{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,
) |
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"),
("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-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),
)
def non_sortable_table_header(
col_name: str,
) -> rx.Component:
"""Renders a non-sortable table header cell."""
|
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"),
("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_val},
)
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_key = col_data[1]
return rx.cond(
column_key,
sortable_table_heade | 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_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,
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 = (
"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
)
|
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="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[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(SortColumn)),
non_sortable_table_header(col_name),
)
def get_cell_content(col_name: rx.Var[str], customer: CustomerData) -> rx.Component:
"""Gets the | 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-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),
)
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"),
("Licenses", "text-center"),
("Active licenses", "text-center"),
"text-left",
)
|
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,
)
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(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 name."""
base_class = "px-4 py-3 whitespace-nowrap text-sm"
return rx.match(
col_name,
(
"ID | 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,
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 = (
"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.match(
col_name,
("Revenue", "flex-end"),
("Licenses", "center"),
("Active licenses", "center"),
"flex-start",
)
|
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[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(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 name."""
base_class = "px-4 py-3 whitespace-nowrap text-sm"
return rx.match(
col_name,
(
"ID",
rx.el.td(
customer["id"], | 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),
)
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"),
("Licenses", "text-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"{base_class} {text_align_class}"
|
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_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 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(
customer["id"],
class_name=f"{base_class} text-gray-700 text-left",
),
),
(
"Customer name",
rx.el.td(
| 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.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"),
("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_val},
)
return rx.el.th(
header_content_inner,
scope="col",
class_name=combined_class,
)
|
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(
customer["id"],
class_name=f"{base_class} text-gray-700 text-left",
),
),
(
"Customer name",
rx.el.td(
customer["customer_name"],
class_name=f"{base_class} font-medium text-gray-900 text-left",
),
),
(
"Next renewal",
rx.el.td(
customer["next_renewal"],
class_name=f"{base_class} text-gray-700 text-left",
),
),
(
"Revenue",
rx.el.td(
"$" + customer["revenue"].to_string(),
class_name=f"{base_class} t | 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(SortColumn)),
non_sortable_table_header(col_name),
) |
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",
)
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="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[str, Optional[SortColumn]]],
) -> rx.Component:
"""Renders a table header cell, deciding if it's sortable or not."""
|
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 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(
customer["id"],
class_name=f"{base_class} text-gray-700 text-left",
),
),
(
"Customer name",
rx.el.td(
customer["customer_name"],
class_name=f"{base_class} font-medium text-gray-900 text-left",
),
),
(
"Next renewal",
rx.el.td(
customer["next_renewal"],
class_name=f"{base_class} text-gray-700 tex | 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.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="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[str, Optional[SortColumn]]],
) -> rx.Component:
"""Renders a table header cell, deciding if it's sortable or not."""
col_name = col_data[0]
|
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 name."""
base_class = "px-4 py-3 whitespace-nowrap text-sm"
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"],
class_name=f"{base_class} font-medium text-gray-900 text-left",
),
),
(
"Next renewal",
rx.el.td(
customer["next_renewal"],
class_name=f"{base_class} text-gray-700 text-left",
),
| 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_val},
)
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_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 specific cell based on column name."""
|
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"],
class_name=f"{base_class} font-medium text-gray-900 text-left",
),
),
(
"Next renewal",
rx.el.td(
customer["next_renewal"],
class_name=f"{base_class} text-gray-700 text-left",
),
),
(
"Revenue",
rx.el.td(
"$" + customer["revenue"].to_string(),
class_name=f"{base_class} text-gray-700 text-right",
),
),
(
"Licenses",
rx.el.td(
customer["licenses"],
class_name=f"{base_class} text-gray-700 text-center",
| 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_growth"] > 0,
f"{base_class} text-green-600 text-center",
f"{base_class} text-red-600 text-center",
),
),
),
(
"Industry",
rx.el.td(
industry_tag(customer["industry"]),
class_name=f"{base_class} text-left",
),
),
(
"Platform",
rx.el.td(
platform_tag(customer["platform"]),
class_name=f"{base_class} text-left",
),
),
rx.el.td(
"-",
class_name=f"{base_class} text-gray-500 text-left",
),
)
|
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-3 top-1/2 transform -translate-y-1/2 pointer-events-none",
),
rx.el.input(
placeholder="Search by customer name...",
default_value=DashboardState.search_term,
on_change=DashboardState.set_search_term.debounce(300),
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",
),
class_name="relative flex-grow",
),
class_name="flex items-center gap-4 mb-4",
), | 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_customer(customer["id"]),
class_name=rx.cond(
DashboardState.selected_customer_id == customer["id"],
"w-full bg-emerald-50 border-l-4 border-emerald-500 cursor-pointer hover:bg-emerald-100 transition-colors duration-150 ease-in-out",
"w-full border-b border-gray-200 cursor-pointer hover:bg-gray-50 transition-colors duration-150 ease-in-out",
),
) |
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,
"px-4 py-2 text-sm font-medium text-white bg-emerald-700 rounded-md shadow-sm whitespace-nowrap sm:whitespace-normal",
"px-4 py-2 text-sm font-medium text-emerald-100 hover:bg-emerald-600 hover:text-white rounded-md transition-colors duration-150 ease-in-out whitespace-nowrap sm:whitespace-normal",
),
)
def navigation() -> rx.Component:
"""The top navigation bar component."""
return rx.el.div(
rx.el.div(
rx.el.img(
src="https://avatars.githubusercontent.com/u/104714959?s=200&v=4",
class_name="h-8 w-auto mr-4 max-md:hidden",
alt="App Logo",
),
navigat | 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 shadow-sm whitespace-nowrap sm:whitespace-normal",
"px-4 py-2 text-sm font-medium text-emerald-100 hover:bg-emerald-600 hover:text-white rounded-md transition-colors duration-150 ease-in-out whitespace-nowrap sm:whitespace-normal",
),
)
def navigation() -> rx.Component:
"""The top navigation bar component."""
return rx.el.div(
rx.el.div(
rx.el.img(
src="https://avatars.githubusercontent.com/u/104714959?s=200&v=4",
class_name="h-8 w-auto mr-4 max-md:hidden",
alt="App Logo",
),
navigation_item("Sales Pipeline", "/sales-pipeline"),
navigation | 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
platform: str
usage_history: List[Dict[str, Union[str, int]]]
next_renewal_date: Optional[datetime]
| 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",
"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_raw
]
COLUMN_MAPPING: List[Tuple[str, Optional[SortColumn]]] = [
("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):
"""State class managing t | 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 = 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 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):
"""State class managing the customer dashboard data and UI interactions."""
customers: List | 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"]
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 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):
"""State class managing the customer dashboard data and UI interactions."""
customers: List[CustomerData] = proc | 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] = [
{
**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 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):
"""State class managing the customer dashboard data and UI interactions."""
customers: List[CustomerData] = processed_customers
selected_customer_id: Optional[int] | 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["next_renewal"]),
}
for customer in initial_customer_data_raw
]
COLUMN_MAPPING: List[Tuple[str, Optional[SortColumn]]] = [
("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):
"""State class managing the customer dashboard data and UI interactions."""
customers: List[CustomerData] = processed_customers
selected_customer_id: Optional[int] = None
search_term: str = ""
sort_column: Optional[SortCol | 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_customer_data_raw
]
COLUMN_MAPPING: List[Tuple[str, Optional[SortColumn]]] = [
("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):
"""State class managing the customer dashboard data and UI interactions."""
customers: List[CustomerData] = processed_customers
selected_customer_id: Optional[int] = None
search_term: str = ""
sort_column: Optional[SortColumn] = "id"
sort_order: SortOrder = "asc"
@ | 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 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):
"""State class managing the customer dashboard data and UI interactions."""
customers: List[CustomerData] = 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 | 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_raw
]
COLUMN_MAPPING: List[Tuple[str, Optional[SortColumn]]] = [
("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):
"""State class managing the customer dashboard data and UI interactions."""
customers: List[CustomerData] = processed_customers
selected_customer_id: Optional[int] = None
search_term: str = ""
sort_column: Optional[SortColumn] = "id"
sort_order: SortOrder = "asc"
@rx.var
|
@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 = [
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_renewal":
date_val = customer.get("next_renewal_date")
if date_val is None:
return (
datetime.max if self.sort_order == "asc" else datetime.min
)
return date_val
elif sort_ | 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):
"""State class managing the customer dashboard data and UI interactions."""
customers: List[CustomerData] = 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 configurations (name and sort key)."""
return COLUMN_MAPPING
@rx.var
def filtered_customers(self) -> List[CustomerData]:
"""Returns the list of customers filtered by search term and sorted according to current settings."""
|
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:
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 (
datetime.max if self.sort_order == "asc" else datetime.min
)
return date_val
elif sort_key in [
"id",
"revenue",
"licenses",
"active_licenses",
]:
key_value = customer.get(sort_key)
| 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 UI interactions."""
customers: List[CustomerData] = 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 configurations (name and sort key)."""
return COLUMN_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.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 (
datetime.max if self.sort_order == "asc" else datetime.min
)
return date_val
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
else:
return 0
customers_to_process = sorted(
customers_to_process,
key=get_sort_key,
reverse=self.sort_order == "desc" | 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."""
customers: List[CustomerData] = 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 configurations (name and sort key)."""
return COLUMN_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:
|
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_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
)
return date_val
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
el | 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
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 configurations (name and sort key)."""
return COLUMN_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()
|
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 (
datetime.max if self.sort_order == "asc" else datetime.min
)
return date_val
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
else:
return 0
customers_to_process = sorted(
customers_to_process,
key=get_sort_key,
reverse=self.sort_order == "desc" | 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 configurations (name and sort key)."""
return COLUMN_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 = [
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):
|
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
)
return date_val
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
else:
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]:
| 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 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 = [
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_renewal":
|
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",
"licenses",
"active_licenses",
]:
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_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."""
| 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 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 = [
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_renewal":
date_val = customer.get("next_renewal_date")
|
return date_val
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
else:
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 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 c | 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 = [
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_renewal":
date_val = customer.get("next_renewal_date")
if date_val is None:
return (
datetime.max if self.sort_order == "asc" else datetime.min
)
return date_val
|
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 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.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 customer or deselects if already selected."""
if self.sele | 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
else:
return 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()
]
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 (
datetime.max if self.sort_order == "asc" else datetime.min
)
return date_val
elif sort_key in [
"id",
"revenue",
"licenses",
"active_licenses",
]:
|
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",
)
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.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(self.filtered_customers)
@rx.event
def select_customer(self, customer_i | 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_renewal":
date_val = customer.get("next_renewal_date")
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",
"licenses",
"active_licenses",
]:
key_value = customer.get(sort_key)
return key_value if isinstance(key_value, (int, float)) else 0
else:
return 0
|
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.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(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:
self.selected_customer_id = customer_id
@rx.event
def set_search_ter | 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 datetime.min
)
return date_val
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
else:
return 0
customers_to_process = sorted(
customers_to_process,
key=get_sort_key,
reverse=self.sort_order == "desc",
)
return customers_to_process
@rx.var
|
@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 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 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 in self.filtered_customers
)
)
if not found:
self.selected_customer_id = None
| 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_customer_id:
return customer
return None |
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",
"licenses",
"active_licenses",
]:
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_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."""
|
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(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:
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(
(
customer["id"] == self.selected_customer_id
| 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",
]:
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_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_customer_id is None:
return None
|
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. 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 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 in self.filtered_customers
)
)
if not found:
self.selected_cus | 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 = 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_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_customer_id is None:
return None
for customer in self.customers:
|
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. 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 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 in self.filtered_customers
)
)
if not found:
self.selected_cus | 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
else:
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 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.var
|
@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 = 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(
(
customer["id"] == self.selected_customer_id
for customer in self.filtered_customers
)
)
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_ | 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_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_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:
"""Returns the number of customers currently displayed in the table (after filtering)."""
return len(self.filtered_customers)
@rx.event
|
@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
for customer in self.filtered_customers
)
)
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.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 |
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 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.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 customer or deselects if already 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
for customer in self.filtered_customers
)
)
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.sort_order == "asc" else "asc"
else:
self.sort_column = column_key
self.sort_order = "asc"
| 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 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:
"""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 if already selected."""
if self.selected_customer_id == customer_id:
|
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(
(
customer["id"] == self.selected_customer_id
for customer in self.filtered_customers
)
)
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.sort_order == "asc" else "asc"
else:
self.sort_column = column_key
self.sort_order = "asc"
| 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_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:
"""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 if already selected."""
if self.selected_customer_id == customer_id:
self.selected_customer_id = None
else:
|
@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
for customer in self.filtered_customers
)
)
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.sort_order == "asc" else "asc"
else:
self.sort_column = column_key
self.sort_order = "asc"
| 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 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(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:
self.selected_customer_id = customer_id
@rx.event
|
@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 = column_key
self.sort_order = "asc"
| 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 in self.filtered_customers
)
)
if not found:
self.selected_customer_id = None |
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:
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 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
@rx.event
def set_search_term(self, term: str):
"""Updates the search term based on user input."""
|
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
@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 = column_key
self.sort_order = "asc"
| 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.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 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 based on user input."""
self.search_term = term
|
@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 = column_key
self.sort_order = "asc"
| 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:
"""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 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 based on user input."""
self.search_term = term
if self.selected_customer_id is not None:
|
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.sort_order == "asc" else "asc"
else:
self.sort_column = column_key
self.sort_order = "asc"
| 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):
"""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
@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
for customer in self.filtered_customers
)
)
|
@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 = column_key
self.sort_order = "asc"
| 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 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
@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
for customer in self.filtered_customers
)
)
if not found:
|
@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 = column_key
self.sort_order = "asc"
| 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 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 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 in self.filtered_customers
)
)
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.sort_order == "asc" else "asc"
else:
self.sort_column = column_key
self.sort_order = "asc" | |
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:
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(
(
customer["id"] == self.selected_customer_id
for customer in self.filtered_customers
)
)
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.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
@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
for customer in self.filtered_customers
)
)
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:
|
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 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 in self.filtered_customers
)
)
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.sort_order == "asc" else "asc"
else:
|
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_term = term
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
@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 = column_key
| 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 ValueError:
try:
return datetime.strptime(date_str, "%Y-%m-%d")
except ValueError:
return None
| 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:
return datetime.strptime(date_str, "%Y-%m-%d")
except ValueError:
return None
| 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(
CustomerState.error_message != "",
rx.el.div(
CustomerState.error_message,
class_name=rx.cond(
CustomerState.error_message.contains("Failed")
| CustomerState.error_message.contains(
"Failed to simulate"
),
"mb-4 p-4 rounded-md text-sm bg-red-100 border border-red-300 text-red-700 shadow",
"mb-4 p-4 rounded-md text-sm bg-yellow-100 border border-yellow-300 text-yellow-700 shadow",
),
| 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 != "",
rx.el.div(
CustomerState.error_message,
class_name=rx.cond(
CustomerState.error_message.contains("Failed")
| CustomerState.error_message.contains(
"Failed to simulate"
),
"mb-4 p-4 rounded-md text-sm bg-red-100 border border-red-300 text-red-700 shadow",
"mb-4 p-4 rounded-md text-sm bg-yellow-100 border border-yellow-300 text-yellow-700 shadow",
),
),
rx.fragment(),
),
| 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,
class_name=rx.cond(
CustomerState.error_message.contains("Failed")
| CustomerState.error_message.contains(
"Failed to simulate"
),
"mb-4 p-4 rounded-md text-sm bg-red-100 border border-red-300 text-red-700 shadow",
"mb-4 p-4 rounded-md text-sm bg-yellow-100 border border-yellow-300 text-yellow-700 shadow",
),
),
rx.fragment(),
),
customer_table(),
customer_edit_form(), | 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(
CustomerState.error_message.contains("Failed")
| CustomerState.error_message.contains(
"Failed to simulate"
),
"mb-4 p-4 rounded-md text-sm bg-red-100 border border-red-300 text-red-700 shadow",
"mb-4 p-4 rounded-md text-sm bg-yellow-100 border border-yellow-300 text-yellow-700 shadow",
),
),
rx.fragment(),
),
customer_table(),
customer_edit_form(),
class_name="mx-auto w-full lg:p-8 p-4",
| 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",
),
class_name="text-lg sm:text-xl font-semibold mb-4 sm:mb-6 text-gray-800",
),
rx.el.form(
rx.el.input(
type="hidden",
name="customer_id",
default_value=CustomerState.form_customer_id.to_string(),
key=rx.cond(
CustomerState.form_customer_id == 0,
"customer_id-new-form",
CustomerState.form_customer_id.to_string() + "_cust_id_form",
),
),
rx.el.div(
rx.el.label(
| 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:text-xl font-semibold mb-4 sm:mb-6 text-gray-800",
),
rx.el.form(
rx.el.input(
type="hidden",
name="customer_id",
default_value=CustomerState.form_customer_id.to_string(),
key=rx.cond(
CustomerState.form_customer_id == 0,
"customer_id-new-form",
CustomerState.form_customer_id.to_string() + "_cust_id_form",
),
),
rx.el.div(
rx.el.label(
"First Name:",
html_for="form_ | 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",
),
text,
rx.cond(
CustomerState.sort_column == column_key,
rx.icon(
tag=rx.cond(
CustomerState.sort_order == "asc",
"chevron_up",
"chevron_down",
),
size=16,
class_name="text-gray-700 w-[16px]",
),
rx.fragment(),
),
class_name="flex gap-2 items-center cursor-pointer hover:text-gray-900",
on_click=lambda: CustomerState.sort_by_column(column_key),
),
scope="col",
cla | 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(
CustomerState.sort_column == column_key,
rx.icon(
tag=rx.cond(
CustomerState.sort_order == "asc",
"chevron_up",
"chevron_down",
),
size=16,
class_name="text-gray-700 w-[16px]",
),
rx.fragment(),
),
class_name="flex gap-2 items-center cursor-pointer hover:text-gray-900",
on_click=lambda: CustomerState.sort_by_column(column_key),
),
scope="col",
class_name="px-3 py-3.5 text-left text-sm font-semibold text-gray-600",
)
| 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",
),
scope="col",
class_name="px-3 py-3.5 text-left text-sm font-semibold text-gray-600",
)
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_table_header_cell("Email", "mail"),
static_table_header_cell("Tags", "tag"),
class_name="border-b border-gray-200 bg-gray-50",
)
)
def status_badge(status: str) -> rx.Component:
return rx.el.div(
| 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(
CustomerState.sort_column == column_key,
rx.icon(
tag=rx.cond(
CustomerState.sort_order == "asc",
"chevron_up",
"chevron_down",
),
size=16,
class_name="text-gray-700 w-[16px]",
),
rx.fragment(),
),
class_name="flex gap-2 items-center cursor-pointer hover:text-gray-900",
on_click=lambda: CustomerState.sort_by_column(column_key),
),
scope="col",
class_name="px-3 py-3.5 text-left text-sm font-semibold text-gray-600",
) |
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(
CustomerState.sort_column == column_key,
rx.icon(
tag=rx.cond(
CustomerState.sort_order == "asc",
"chevron_up",
"chevron_down",
),
size=16,
class_name="text-gray-700 w-[16px]",
),
rx.fragment(),
),
class_name="flex gap-2 items-center cursor-pointer hover:text-gray-900",
on_click=lambda: CustomerState.sort_by_column(column_key),
),
scope="col",
class_name="px-3 py-3.5 text-left text-sm font-semibold text-gray-600",
)
|
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_table_header_cell("Email", "mail"),
static_table_header_cell("Tags", "tag"),
class_name="border-b border-gray-200 bg-gray-50",
)
)
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",
),
(
"Onboarding",
"h-1.5 w-1.5 rounded-full bg-yellow-500",
),
(
"Pending",
"h-1.5 w-1.5 rounded-full bg-orange- | 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",
),
scope="col",
class_name="px-3 py-3.5 text-left text-sm font-semibold text-gray-600",
) |
CustomerState.sort_order == "asc",
"chevron_up",
"chevron_down",
),
size=16,
class_name="text-gray-700 w-[16px]",
),
rx.fragment(),
),
class_name="flex gap-2 items-center cursor-pointer hover:text-gray-900",
on_click=lambda: CustomerState.sort_by_column(column_key),
),
scope="col",
class_name="px-3 py-3.5 text-left text-sm font-semibold text-gray-600",
)
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",
),
scope="col",
class_name="px-3 py-3.5 text-left text-sm font-semibold text-gray-600",
)
|
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",
),
(
"Onboarding",
"h-1.5 w-1.5 rounded-full bg-yellow-500",
),
(
"Pending",
"h-1.5 w-1.5 rounded-full bg-orange-500",
),
(
"Suspended",
"h-1.5 w-1.5 rounded-full bg-red-500",
),
(
"Inactive",
"h-1.5 w-1.5 rounded-full bg-gray-500",
),
"h-1.5 w-1.5 rounded-full bg-gray-500",
)
),
status,
class_name=rx.match(
status,
(
"Active",
"i | 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_table_header_cell("Email", "mail"),
static_table_header_cell("Tags", "tag"),
class_name="border-b border-gray-200 bg-gray-50",
)
) |
"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 font-medium text-orange-700 bg-orange-100 ring-1 ring-inset ring-orange-200",
),
(
"Suspended",
"inline-flex items-center gap-x-1.5 rounded-md px-2 py-1 text-xs font-medium text-red-700 bg-red-100 ring-1 ring-inset ring-red-200",
),
(
"Inactive",
"inline-flex items-center gap-x-1.5 rounded-md px-2 py-1 text-xs font-medium text-gray-700 bg-gray-100 ring-1 ring-inset ring-gray-200",
),
"inline-flex items-center gap-x-1.5 rounded-md px-2 py-1 text-xs font-medium text-gray-700 bg-gray-100 ring-1 ring-inset ring-gray-200",
),
)
|
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 border border-gray-200",
),
rx.el.p(
f"{customer['first_name']} {customer['last_name']}",
class_name="font-medium text-gray-900 text-sm",
),
class_name="flex items-center",
),
class_name="px-3 py-4 whitespace-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.td(
customer["emai | 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.td(
customer["email"],
class_name="px-3 py-4 whitespace-nowrap text-sm text-gray-500",
),
rx.el.td(
rx.el.div(
rx.cond(
customer["tags"].length() > 0,
tag_item(customer["tags"][0]),
rx.fragment(),
),
class_name="flex items-center space-x-1 sm:space-x-2 flex-wrap gap-1",
),
class_name="px-3 py-4 whitespace-nowrap text-sm",
),
class_name="border-b border-gray-200 hover:bg-gray-50 cursor-pointer",
on_click=lambda: CustomerState.select_customer_for_edit(customer),
)
|
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",
),
rx.el.h1(
CustomerState.total_users.to_string() + " Users",
class_name="text-xl sm:text-2xl font-semibold text-gray-900",
),
class_name="flex items-center gap-2",
),
rx.el.p(
"See your active workplace and make changes",
class_name="mt-1 text-xs sm:text-sm text-gray-500",
),
class_name="flex-grow",
),
rx.el.div(
rx.el.button(
rx.icon(
tag="download",
size=16,
| 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-gray-300 rounded-md shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",
),
rx.el.span(
CustomerState.current_page.to_string()
+ " / "
+ CustomerState.total_pages.to_string(),
class_name="px-3 py-2 sm:px-4 text-xs sm:text-sm text-gray-700",
),
rx.el.button(
"Next",
on_click=CustomerState.next_page,
disabled=CustomerState.current_page >= CustomerState.total_pages,
class_name="px-3 py-2 sm:px-4 text-xs sm:text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",
),
class_name="flex justify-center items-center mt-4 sm:mt-6 space-x-1 sm:space-x-2",
) |
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_url: str
role: str
tags: List[str]
created_at: str
updated_at: str
selected: bool
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"
form_tags: str = ""
form_role: str = ""
customer_statuses: List[str] = [
"Active",
"Onboarding",
"Inactive",
"Pending",
"Suspended",
]
all_selected: bool = False
available_roles: List[str] = [
| 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
role: str
tags: List[str]
created_at: str
updated_at: str
selected: bool
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"
form_tags: str = ""
form_role: str = ""
customer_statuses: List[str] = [
"Active",
"Onboarding",
"Inactive",
"Pending",
"Suspended",
]
all_selected: bool = False
available_roles: List[str] = [
"Adminis | 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
tags: List[str]
created_at: str
updated_at: str
selected: bool
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"
form_tags: str = ""
form_role: str = ""
customer_statuses: List[str] = [
"Active",
"Onboarding",
"Inactive",
"Pending",
"Suspended",
]
all_selected: bool = False
available_roles: List[str] = [
"Administrator",
| 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
updated_at: str
selected: bool
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"
form_tags: str = ""
form_role: str = ""
customer_statuses: List[str] = [
"Active",
"Onboarding",
"Inactive",
"Pending",
"Suspended",
]
all_selected: bool = False
available_roles: List[str] = [
"Administrator",
"Accounting",
"Product Design | 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 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"
form_tags: str = ""
form_role: str = ""
customer_statuses: List[str] = [
"Active",
"Onboarding",
"Inactive",
"Pending",
"Suspended",
]
all_selected: bool = False
available_roles: List[str] = [
"Administrator",
"Accounting",
"Product Designer",
"Human Resources",
"Devop | 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):
_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"
form_tags: str = ""
form_role: str = ""
customer_statuses: List[str] = [
"Active",
"Onboarding",
"Inactive",
"Pending",
"Suspended",
]
all_selected: bool = False
available_roles: List[str] = [
"Administrator",
"Accounting",
"Product Designer",
"Human Resources",
"Devops",
"Hiring M | 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_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"
form_tags: str = ""
form_role: str = ""
customer_statuses: List[str] = [
"Active",
"Onboarding",
"Inactive",
"Pending",
"Suspended",
]
all_selected: bool = False
available_roles: List[str] = [
"Administrator",
"Accounting",
"Product Designer",
"Human Resources",
"Devops",
"Hiring Manager",
"Cu | 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"
form_tags: str = ""
form_role: str = ""
customer_statuses: List[str] = [
"Active",
"Onboarding",
"Inactive",
"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] = [
"Collaboration",
"Leadership",
"Innovation",
"Creativity",
"Feedback",
"Coaching",
"Mentoring",
"Delegation",
]
sort_column: str = "name"
| 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",
"Human Resources",
"Devops",
"Hiring Manager",
"Customer Success",
]
available_tags: List[str] = [
"Collaboration",
"Leadership",
"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 | 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
|
@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_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 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()
]
# Apply sorting
def get_sort_value(customer_da | 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",
]
available_tags: List[str] = [
"Collaboration",
"Leadership",
"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 | 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
|
@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():
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_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.get(self.sort_column)
if isinstance(sort_va | 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_per_page) |
"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] = [
"Collaboration",
"Leadership",
"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 | 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:
|
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]:
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():
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_value(customer_data_item: CustomerData):
if self.sort_column == "name":
first = custome | 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",
"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 | 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:
num_items = len(self._processed_customers)
|
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 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
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_item.get("first_name", "")
last = customer_data_item.get("last_name", "")
return (first.lower(), last.l | 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_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 | 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:
num_items = len(self._processed_customers)
if (
self.items_per_page <= 0
): # Guard against division by zero or invalid items_per_page
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
# 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
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_item.get("first_name", "")
last = customer_data_item.get("last_name", "")
return (first.lower(), last.lower())
sort_val = customer_data_it | 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 | 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:
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.var
def _processed_customers(self) -> List[CustomerData]:
| # 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
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_item.get("first_name", "")
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 = sorted(
data_to_process,
k | 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 total_users(self) -> int:
return 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
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
|
# 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())
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",
)
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 _parse_tags_string(self, tags_str: str | Non | 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_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
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 self.search_query and self.search_query.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_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.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",
)
return sorted_data
@rx.var
def customers(self) -> List[CustomerData]:
data_for_page = self._processed_customers
st | 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:
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.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():
query_lower = self.search_query.lower().strip()
|
# 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())
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",
)
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 _parse_tags_string(self, tags_str: str | Non | 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
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 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()
]
# Apply sorting
|
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.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 = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: | 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.get(self.sort_column)
if isinstance(sort_val, str):
return sort_val.lower()
return sort_val |
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.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():
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_value(customer_data_item: CustomerData):
|
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",
)
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 _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 tag_names_from_input:
if tag | 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[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():
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_value(customer_data_item: CustomerData):
if self.sort_column == "name":
|
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 = 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.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 = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_ | 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._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 = [
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 self.sort_column == "name":
first = customer_data_item.get("first_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 = 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.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 = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
| 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
# 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
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_item.get("first_name", "")
last = customer_data_item.get("last_name", "")
return (first.lower(), last.lower())
|
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(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 _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 tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
| 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_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()
]
# 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())
sort_val = customer_data_item.get(self.sort_column)
|
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
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 = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list | 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 = [
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 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.get(self.sort_column)
if isinstance(sort_val, str):
return sort_val.lower()
return sort_val
|
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 _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 tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
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 == | 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()
]
# 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())
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",
)
return sorted_data
@rx.var
|
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 tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
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:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_ | 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_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.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",
)
return sorted_data
@rx.var
def customers(self) -> List[CustomerData]:
|
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 = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
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:
self.sort_column = col | 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):
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.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",
)
return sorted_data
@rx.var
def customers(self) -> List[CustomerData]:
data_for_page = self._processed_customers
|
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 name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
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:
self.sort_column = column_name
self.sort_order = "asc"
self.current_pa | 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_item.get("first_name", "")
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 = 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.current_page - 1) * 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 name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
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:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(se | 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", "")
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,
reverse=self.sort_order == "desc",
)
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 _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:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
| 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 tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.