instruction stringlengths 0 1k | input stringlengths 1 1k | output stringlengths 10 6.51k |
|---|---|---|
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def apply_country_filter(self):
"""Apply the temporary country filter to the main selection."""
self.selected_countries = self.temp_selected_countries.copy()
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def apply_costs_filter(self):
new_min_cost = None
new_max_cost = None
try:
if self.temp_min_cost_str:
new_min_cost = float(self.temp_min_cost_str)
except ValueError:
pass
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
|
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.tem | self.min_cost = new_min_cost |
ose_filter_dropdowns()
@rx.event
def apply_country_filter(self):
"""Apply the temporary country filter to the main selection."""
self.selected_countries = self.temp_selected_countries.copy()
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def apply_costs_filter(self):
new_min_cost = None
new_max_cost = None
try:
if self.temp_min_cost_str:
new_min_cost = float(self.temp_min_cost_str)
except ValueError:
pass
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
|
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max | self.max_cost = new_max_cost |
def apply_country_filter(self):
"""Apply the temporary country filter to the main selection."""
self.selected_countries = self.temp_selected_countries.copy()
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def apply_costs_filter(self):
new_min_cost = None
new_max_cost = None
try:
if self.temp_min_cost_str:
new_min_cost = float(self.temp_min_cost_str)
except ValueError:
pass
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
|
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column | self.show_costs_filter = False |
"""Apply the temporary country filter to the main selection."""
self.selected_countries = self.temp_selected_countries.copy()
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def apply_costs_filter(self):
new_min_cost = None
new_max_cost = None
try:
if self.temp_min_cost_str:
new_min_cost = float(self.temp_min_cost_str)
except ValueError:
pass
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
|
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_p | self.current_page = 1 |
er to the main selection."""
self.selected_countries = self.temp_selected_countries.copy()
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def apply_costs_filter(self):
new_min_cost = None
new_max_cost = None
try:
if self.temp_min_cost_str:
new_min_cost = float(self.temp_min_cost_str)
except ValueError:
pass
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
|
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = | def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set() |
ted_countries.copy()
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def apply_costs_filter(self):
new_min_cost = None
new_max_cost = None
try:
if self.temp_min_cost_str:
new_min_cost = float(self.temp_min_cost_str)
except ValueError:
pass
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
|
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = | self.temp_selected_statuses = set() |
self.close_filter_dropdowns()
@rx.event
def apply_costs_filter(self):
new_min_cost = None
new_max_cost = None
try:
if self.temp_min_cost_str:
new_min_cost = float(self.temp_min_cost_str)
except ValueError:
pass
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
|
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
| def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set() |
):
new_min_cost = None
new_max_cost = None
try:
if self.temp_min_cost_str:
new_min_cost = float(self.temp_min_cost_str)
except ValueError:
pass
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
|
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
| self.temp_selected_countries = set() |
ne
try:
if self.temp_min_cost_str:
new_min_cost = float(self.temp_min_cost_str)
except ValueError:
pass
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
|
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
| def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1 |
mp_min_cost_str:
new_min_cost = float(self.temp_min_cost_str)
except ValueError:
pass
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
|
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and | self.temp_min_cost_str = "" |
_min_cost = float(self.temp_min_cost_str)
except ValueError:
pass
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
|
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx. | self.temp_max_cost_str = "" |
_str)
except ValueError:
pass
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
|
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", d | self.min_cost = None |
or:
pass
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
|
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd | self.max_cost = None |
try:
if self.temp_max_cost_str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
|
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_dat | self.show_costs_filter = False |
str:
new_max_cost = float(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
|
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
| self.current_page = 1 |
(self.temp_max_cost_str)
except ValueError:
pass
if (
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
|
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
stream = io.StringIO()
df_display.to_csv(stream, index=False)
return rx.download(
dat | def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns() |
new_min_cost is not None
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
|
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stabilit | self.search_owner = "" |
and new_max_cost is not None
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
|
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($) | self.selected_statuses = set() |
e
and (new_min_cost > new_max_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
|
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edit | self.selected_countries = set() |
x_cost)
):
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
|
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_dis | self.min_cost = None |
self.min_cost = new_max_cost
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
|
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in c | self.max_cost = None |
t
self.max_cost = new_min_cost
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
|
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
| self.temp_selected_statuses = set() |
else:
self.min_cost = new_min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
|
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_d | self.temp_selected_countries = set() |
min_cost
self.max_cost = new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
|
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=c | self.temp_min_cost_str = "" |
new_max_cost
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
|
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
stream = io.S | self.temp_max_cost_str = "" |
s_filter = False
self.current_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
|
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
stream = io.StringIO()
df_display.to_ | self.sort_column = None |
rrent_page = 1
@rx.event
def reset_status_filter(self):
"""Reset the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
|
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
stream = io.StringIO()
df_display.to_csv(stream, index=False)
| self.current_page = 1 |
et the status filter."""
self.temp_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
|
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
stream = io.StringIO()
df_display.to_csv(stream, index=False)
return rx.download(
data=stream.getvalue(),
filename="retail_data_export.csv",
)
| def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False |
_selected_statuses = set()
@rx.event
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
|
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
stream = io.StringIO()
df_display.to_csv(stream, index=False)
return rx.download(
data=stream.getvalue(),
filename="retail_data_export.csv",
)
| self.show_status_filter = False |
t
def reset_country_filter(self):
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
|
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
stream = io.StringIO()
df_display.to_csv(stream, index=False)
return rx.download(
data=stream.getvalue(),
filename="retail_data_export.csv",
)
| self.show_country_filter = False |
"""Reset the country filter."""
self.temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
|
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
stream = io.StringIO()
df_display.to_csv(stream, index=False)
return rx.download(
data=stream.getvalue(),
filename="retail_data_export.csv",
)
| self.show_costs_filter = False |
temp_selected_countries = set()
@rx.event
def reset_costs_filter(self):
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
| def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
stream = io.StringIO()
df_display.to_csv(stream, index=False)
return rx.download(
data=stream.getvalue(),
filename="retail_data_export.csv",
) | |
f.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.min_cost = None
self.max_cost = None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
|
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
stream = io.StringIO()
df_display.to_csv(stream, index=False)
return rx.download(
data=stream.getvalue(),
filename="retail_data_export.csv",
)
| if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000) |
= None
self.show_costs_filter = False
self.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
|
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
stream = io.StringIO()
df_display.to_csv(stream, index=False)
return rx.download(
data=stream.getvalue(),
filename="retail_data_export.csv",
)
| df = pd.DataFrame(self.filtered_and_sorted_data) |
lf.current_page = 1
@rx.event
def reset_all_filters(self):
"""Reset all active filters and search."""
self.search_owner = ""
self.selected_statuses = set()
self.selected_countries = set()
self.min_cost = None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
|
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
stream = io.StringIO()
df_display.to_csv(stream, index=False)
return rx.download(
data=stream.getvalue(),
filename="retail_data_export.csv",
)
| column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
} |
= None
self.max_cost = None
self.temp_selected_statuses = set()
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
|
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
stream = io.StringIO()
df_display.to_csv(stream, index=False)
return rx.download(
data=stream.getvalue(),
filename="retail_data_export.csv",
)
| df_display_cols = [key for key in column_mapping if key in df.columns] |
self.temp_selected_countries = set()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
|
df_display = df_display.rename(columns=column_mapping)
stream = io.StringIO()
df_display.to_csv(stream, index=False)
return rx.download(
data=stream.getvalue(),
filename="retail_data_export.csv",
)
| df_display = df[df_display_cols] |
et()
self.temp_min_cost_str = ""
self.temp_max_cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
|
stream = io.StringIO()
df_display.to_csv(stream, index=False)
return rx.download(
data=stream.getvalue(),
filename="retail_data_export.csv",
)
| df_display = df_display.rename(columns=column_mapping) |
cost_str = ""
self.sort_column = None
self.current_page = 1
self.close_filter_dropdowns()
@rx.event
def close_filter_dropdowns(self):
self.show_status_filter = False
self.show_country_filter = False
self.show_costs_filter = False
@rx.event
def download_csv(self):
"""Download the filtered and sorted data as CSV."""
if not self.filtered_and_sorted_data:
return rx.toast("No data to export.", duration=3000)
df = pd.DataFrame(self.filtered_and_sorted_data)
column_mapping = {
"owner": "Owner",
"status": "Status",
"country": "Country",
"stability": "Stability (%)",
"costs": "Costs ($)",
"last_edited": "Last Edited",
}
df_display_cols = [key for key in column_mapping if key in df.columns]
df_display = df[df_display_cols]
df_display = df_display.rename(columns=column_mapping)
|
df_display.to_csv(stream, index=False)
return rx.download(
data=stream.getvalue(),
filename="retail_data_export.csv",
)
| stream = io.StringIO() |
from retention_dashboard.components.layout import layout
def index() -> rx.Component:
"""The main page of the app."""
return layout()
app = rx.App(theme=rx.theme(appearance="light"))
app.add_page(index, route="/")
| import reflex as rx | |
import reflex as rx
TooltipPropValue = Union[str, int, float, dict, bool]
TOOLTIP_PROPS: Dict[str, Dict[str, TooltipPropValue]] = {
"content_style": {
"background": "white",
"borderColor": "#E8E8E8",
"borderRadius": "0.75rem",
"boxShadow": "0px 24px 12px 0px rgba(28, 32, 36, 0.02), 0px 8px 8px 0px rgba(28, 32, 36, 0.02), 0px 2px 6px 0px rgba(28, 32, 36, 0.02)",
"fontFamily": "sans-serif",
"fontSize": "0.875rem",
"lineHeight": "1.25rem",
"fontWeight": "500",
"minWidth": "8rem",
"padding": "0.375rem 0.625rem",
},
"item_style": {
"display": "flex",
"paddingBottom": "0px",
"position": "relative",
"paddingTop": "2px",
},
"label_style": {
"color": "black",
"fontWeight": "500",
"alignSelf": "flex-end",
},
"separator": "",
}
ChartDataItem = Dict[str, Union[str, int, float]]
def donut_chart(
data: rx.Var[List[ChartDataItem]] | from typing import Dict, List, Union | |
from typing import Dict, List, Union
|
TooltipPropValue = Union[str, int, float, dict, bool]
TOOLTIP_PROPS: Dict[str, Dict[str, TooltipPropValue]] = {
"content_style": {
"background": "white",
"borderColor": "#E8E8E8",
"borderRadius": "0.75rem",
"boxShadow": "0px 24px 12px 0px rgba(28, 32, 36, 0.02), 0px 8px 8px 0px rgba(28, 32, 36, 0.02), 0px 2px 6px 0px rgba(28, 32, 36, 0.02)",
"fontFamily": "sans-serif",
"fontSize": "0.875rem",
"lineHeight": "1.25rem",
"fontWeight": "500",
"minWidth": "8rem",
"padding": "0.375rem 0.625rem",
},
"item_style": {
"display": "flex",
"paddingBottom": "0px",
"position": "relative",
"paddingTop": "2px",
},
"label_style": {
"color": "black",
"fontWeight": "500",
"alignSelf": "flex-end",
},
"separator": "",
}
ChartDataItem = Dict[str, Union[str, int, float]]
def donut_chart(
data: rx.Var[List[ChartDataItem]],
data_key: str,
| import reflex as rx |
from typing import Dict, List, Union
import reflex as rx
|
TOOLTIP_PROPS: Dict[str, Dict[str, TooltipPropValue]] = {
"content_style": {
"background": "white",
"borderColor": "#E8E8E8",
"borderRadius": "0.75rem",
"boxShadow": "0px 24px 12px 0px rgba(28, 32, 36, 0.02), 0px 8px 8px 0px rgba(28, 32, 36, 0.02), 0px 2px 6px 0px rgba(28, 32, 36, 0.02)",
"fontFamily": "sans-serif",
"fontSize": "0.875rem",
"lineHeight": "1.25rem",
"fontWeight": "500",
"minWidth": "8rem",
"padding": "0.375rem 0.625rem",
},
"item_style": {
"display": "flex",
"paddingBottom": "0px",
"position": "relative",
"paddingTop": "2px",
},
"label_style": {
"color": "black",
"fontWeight": "500",
"alignSelf": "flex-end",
},
"separator": "",
}
ChartDataItem = Dict[str, Union[str, int, float]]
def donut_chart(
data: rx.Var[List[ChartDataItem]],
data_key: str,
name_key: str,
title: str,
total_value: rx. | TooltipPropValue = Union[str, int, float, dict, bool] |
from typing import Dict, List, Union
import reflex as rx
TooltipPropValue = Union[str, int, float, dict, bool]
TOOLTIP_PROPS: Dict[str, Dict[str, TooltipPropValue]] = {
"content_style": {
"background": "white",
"borderColor": "#E8E8E8",
"borderRadius": "0.75rem",
"boxShadow": "0px 24px 12px 0px rgba(28, 32, 36, 0.02), 0px 8px 8px 0px rgba(28, 32, 36, 0.02), 0px 2px 6px 0px rgba(28, 32, 36, 0.02)",
"fontFamily": "sans-serif",
"fontSize": "0.875rem",
"lineHeight": "1.25rem",
"fontWeight": "500",
"minWidth": "8rem",
"padding": "0.375rem 0.625rem",
},
"item_style": {
"display": "flex",
"paddingBottom": "0px",
"position": "relative",
"paddingTop": "2px",
},
"label_style": {
"color": "black",
"fontWeight": "500",
"alignSelf": "flex-end",
},
"separator": "",
}
|
def donut_chart(
data: rx.Var[List[ChartDataItem]],
data_key: str,
name_key: str,
title: str,
total_value: rx.Var[int],
percentage: rx.Var[float],
) -> rx.Component:
"""Creates a reusable donut chart component."""
return rx.el.div(
rx.el.p(
title,
class_name="text-sm font-medium text-gray-600 text-center mb-2",
),
rx.el.div(
rx.recharts.pie_chart(
rx.recharts.graphing_tooltip(**TOOLTIP_PROPS),
rx.recharts.pie(
rx.recharts.cell(fill=rx.Var.create(f"{data[0]['fill']}")),
data=data,
data_key=data_key,
name_key=name_key,
cx="50%",
cy="50%",
inner_radius="70%",
outer_radius="100%",
padding_angle=0,
stroke="none",
),
width="100%",
| ChartDataItem = Dict[str, Union[str, int, float]] |
from retention_dashboard.components.retention import retention_component
from retention_dashboard.components.workflow import workflow_component
from retention_dashboard.states.dashboard_state import DashboardState
def nav_button(text: str, is_active: rx.Var[bool]) -> rx.Component:
"""Creates a navigation button."""
return rx.el.button(
text,
on_click=lambda: DashboardState.set_active_tab(text),
class_name=rx.cond(
is_active,
"px-4 py-2 text-sm font-medium text-blue-700 bg-blue-100 rounded-md",
"px-4 py-2 text-sm font-medium text-gray-600 hover:bg-gray-100 rounded-md",
),
)
def placeholder_component(title: str) -> rx.Component:
"""A placeholder component for inactive tabs."""
return rx.el.div(
rx.el.h2(
title,
class_name="text-2xl font-semibold text-gray-800 mb-2",
),
rx.el.p(
f"Content for {title} goes here.",
class_name=" | import reflex as rx | |
import reflex as rx
|
from retention_dashboard.components.workflow import workflow_component
from retention_dashboard.states.dashboard_state import DashboardState
def nav_button(text: str, is_active: rx.Var[bool]) -> rx.Component:
"""Creates a navigation button."""
return rx.el.button(
text,
on_click=lambda: DashboardState.set_active_tab(text),
class_name=rx.cond(
is_active,
"px-4 py-2 text-sm font-medium text-blue-700 bg-blue-100 rounded-md",
"px-4 py-2 text-sm font-medium text-gray-600 hover:bg-gray-100 rounded-md",
),
)
def placeholder_component(title: str) -> rx.Component:
"""A placeholder component for inactive tabs."""
return rx.el.div(
rx.el.h2(
title,
class_name="text-2xl font-semibold text-gray-800 mb-2",
),
rx.el.p(
f"Content for {title} goes here.",
class_name="text-gray-600",
),
class_name="p-6 bg-white rounded-lg sha | from retention_dashboard.components.retention import retention_component |
import reflex as rx
from retention_dashboard.components.retention import retention_component
|
from retention_dashboard.states.dashboard_state import DashboardState
def nav_button(text: str, is_active: rx.Var[bool]) -> rx.Component:
"""Creates a navigation button."""
return rx.el.button(
text,
on_click=lambda: DashboardState.set_active_tab(text),
class_name=rx.cond(
is_active,
"px-4 py-2 text-sm font-medium text-blue-700 bg-blue-100 rounded-md",
"px-4 py-2 text-sm font-medium text-gray-600 hover:bg-gray-100 rounded-md",
),
)
def placeholder_component(title: str) -> rx.Component:
"""A placeholder component for inactive tabs."""
return rx.el.div(
rx.el.h2(
title,
class_name="text-2xl font-semibold text-gray-800 mb-2",
),
rx.el.p(
f"Content for {title} goes here.",
class_name="text-gray-600",
),
class_name="p-6 bg-white rounded-lg shadow h-96 flex items-center justify-center",
)
def layout() -> rx. | from retention_dashboard.components.workflow import workflow_component |
import reflex as rx
from retention_dashboard.components.retention import retention_component
from retention_dashboard.components.workflow import workflow_component
|
def nav_button(text: str, is_active: rx.Var[bool]) -> rx.Component:
"""Creates a navigation button."""
return rx.el.button(
text,
on_click=lambda: DashboardState.set_active_tab(text),
class_name=rx.cond(
is_active,
"px-4 py-2 text-sm font-medium text-blue-700 bg-blue-100 rounded-md",
"px-4 py-2 text-sm font-medium text-gray-600 hover:bg-gray-100 rounded-md",
),
)
def placeholder_component(title: str) -> rx.Component:
"""A placeholder component for inactive tabs."""
return rx.el.div(
rx.el.h2(
title,
class_name="text-2xl font-semibold text-gray-800 mb-2",
),
rx.el.p(
f"Content for {title} goes here.",
class_name="text-gray-600",
),
class_name="p-6 bg-white rounded-lg shadow h-96 flex items-center justify-center",
)
def layout() -> rx.Component:
"""The main layout for the dashboard."""
return rx. | from retention_dashboard.states.dashboard_state import DashboardState |
from retention_dashboard.states.retention_state import (
RetentionState,
RetentionWeekData,
)
def retention_cell(
week_data: rx.Var[RetentionWeekData], index: rx.Var[int]
) -> rx.Component:
"""Renders a single cell in the retention table."""
percentage = week_data["value"]
count = week_data["count"]
base_classes = "p-3 text-center "
color_class = rx.cond(
percentage.is_not_none(),
rx.cond(
percentage >= 80,
"bg-blue-600 text-white rounded-lg",
rx.cond(
percentage >= 60,
"bg-blue-500 text-white rounded-lg",
rx.cond(
percentage >= 40,
"bg-blue-400 text-gray-800 rounded-lg",
rx.cond(
percentage >= 20,
"bg-blue-300 text-gray-800 rounded-lg",
rx.cond(
percentage > 0,
"bg-b | import reflex as rx | |
import reflex as rx
|
def retention_cell(
week_data: rx.Var[RetentionWeekData], index: rx.Var[int]
) -> rx.Component:
"""Renders a single cell in the retention table."""
percentage = week_data["value"]
count = week_data["count"]
base_classes = "p-3 text-center "
color_class = rx.cond(
percentage.is_not_none(),
rx.cond(
percentage >= 80,
"bg-blue-600 text-white rounded-lg",
rx.cond(
percentage >= 60,
"bg-blue-500 text-white rounded-lg",
rx.cond(
percentage >= 40,
"bg-blue-400 text-gray-800 rounded-lg",
rx.cond(
percentage >= 20,
"bg-blue-300 text-gray-800 rounded-lg",
rx.cond(
percentage > 0,
"bg-blue-200 text-gray-800 rounded-lg",
"bg-gray-50 text-gray-400 rounded-lg",
| from retention_dashboard.states.retention_state import (
RetentionState,
RetentionWeekData,
) |
import reflex as rx
from retention_dashboard.states.retention_state import (
RetentionState,
RetentionWeekData,
)
def retention_cell(
week_data: rx.Var[RetentionWeekData], index: rx.Var[int]
) -> rx.Component:
"""Renders a single cell in the retention table."""
|
count = week_data["count"]
base_classes = "p-3 text-center "
color_class = rx.cond(
percentage.is_not_none(),
rx.cond(
percentage >= 80,
"bg-blue-600 text-white rounded-lg",
rx.cond(
percentage >= 60,
"bg-blue-500 text-white rounded-lg",
rx.cond(
percentage >= 40,
"bg-blue-400 text-gray-800 rounded-lg",
rx.cond(
percentage >= 20,
"bg-blue-300 text-gray-800 rounded-lg",
rx.cond(
percentage > 0,
"bg-blue-200 text-gray-800 rounded-lg",
"bg-gray-50 text-gray-400 rounded-lg",
),
),
),
),
),
"bg-gray-50 text-gray-400",
)
return rx.el.td(
rx.el.div(
rx.con | percentage = week_data["value"] |
import reflex as rx
from retention_dashboard.states.retention_state import (
RetentionState,
RetentionWeekData,
)
def retention_cell(
week_data: rx.Var[RetentionWeekData], index: rx.Var[int]
) -> rx.Component:
"""Renders a single cell in the retention table."""
percentage = week_data["value"]
|
base_classes = "p-3 text-center "
color_class = rx.cond(
percentage.is_not_none(),
rx.cond(
percentage >= 80,
"bg-blue-600 text-white rounded-lg",
rx.cond(
percentage >= 60,
"bg-blue-500 text-white rounded-lg",
rx.cond(
percentage >= 40,
"bg-blue-400 text-gray-800 rounded-lg",
rx.cond(
percentage >= 20,
"bg-blue-300 text-gray-800 rounded-lg",
rx.cond(
percentage > 0,
"bg-blue-200 text-gray-800 rounded-lg",
"bg-gray-50 text-gray-400 rounded-lg",
),
),
),
),
),
"bg-gray-50 text-gray-400",
)
return rx.el.td(
rx.el.div(
rx.cond(
percentage.i | count = week_data["count"] |
import reflex as rx
from retention_dashboard.states.retention_state import (
RetentionState,
RetentionWeekData,
)
def retention_cell(
week_data: rx.Var[RetentionWeekData], index: rx.Var[int]
) -> rx.Component:
"""Renders a single cell in the retention table."""
percentage = week_data["value"]
count = week_data["count"]
|
color_class = rx.cond(
percentage.is_not_none(),
rx.cond(
percentage >= 80,
"bg-blue-600 text-white rounded-lg",
rx.cond(
percentage >= 60,
"bg-blue-500 text-white rounded-lg",
rx.cond(
percentage >= 40,
"bg-blue-400 text-gray-800 rounded-lg",
rx.cond(
percentage >= 20,
"bg-blue-300 text-gray-800 rounded-lg",
rx.cond(
percentage > 0,
"bg-blue-200 text-gray-800 rounded-lg",
"bg-gray-50 text-gray-400 rounded-lg",
),
),
),
),
),
"bg-gray-50 text-gray-400",
)
return rx.el.td(
rx.el.div(
rx.cond(
percentage.is_not_none(),
rx.el.di | base_classes = "p-3 text-center " |
from retention_dashboard.components.charts import donut_chart
from retention_dashboard.states.workflow_state import WorkflowState
def workflow_component() -> rx.Component:
"""The Workflow tab UI."""
return rx.el.div(
rx.el.h2(
"Workflow",
class_name="text-2xl font-semibold text-gray-800 mb-2",
),
rx.el.p(
"Analyze case testing efficiency and simulate cost impacts across departments",
class_name="text-sm text-gray-600 mb-6",
),
rx.el.div(
rx.el.div(
rx.el.label(
"Test Quota (%)",
class_name="block text-sm font-medium text-gray-700 mb-2",
),
rx.el.input(
type="range",
min="0",
max="100",
default_value=WorkflowState.test_quota.to_string(),
on_change=WorkflowState.set_test_quota,
| import reflex as rx | |
import reflex as rx
|
from retention_dashboard.states.workflow_state import WorkflowState
def workflow_component() -> rx.Component:
"""The Workflow tab UI."""
return rx.el.div(
rx.el.h2(
"Workflow",
class_name="text-2xl font-semibold text-gray-800 mb-2",
),
rx.el.p(
"Analyze case testing efficiency and simulate cost impacts across departments",
class_name="text-sm text-gray-600 mb-6",
),
rx.el.div(
rx.el.div(
rx.el.label(
"Test Quota (%)",
class_name="block text-sm font-medium text-gray-700 mb-2",
),
rx.el.input(
type="range",
min="0",
max="100",
default_value=WorkflowState.test_quota.to_string(),
on_change=WorkflowState.set_test_quota,
class_name="w-full h-2 bg-gray-200 rounded-lg appearance-n | from retention_dashboard.components.charts import donut_chart |
import reflex as rx
from retention_dashboard.components.charts import donut_chart
|
def workflow_component() -> rx.Component:
"""The Workflow tab UI."""
return rx.el.div(
rx.el.h2(
"Workflow",
class_name="text-2xl font-semibold text-gray-800 mb-2",
),
rx.el.p(
"Analyze case testing efficiency and simulate cost impacts across departments",
class_name="text-sm text-gray-600 mb-6",
),
rx.el.div(
rx.el.div(
rx.el.label(
"Test Quota (%)",
class_name="block text-sm font-medium text-gray-700 mb-2",
),
rx.el.input(
type="range",
min="0",
max="100",
default_value=WorkflowState.test_quota.to_string(),
on_change=WorkflowState.set_test_quota,
class_name="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-blue-600",
),
| from retention_dashboard.states.workflow_state import WorkflowState |
import reflex as rx
class DashboardState(rx.State):
"""State to manage the active tab in the dashboard."""
active_tab: Literal["Support", "Retention", "Workflow", "Agents"] = "Retention"
@rx.event
def set_active_tab(
self,
tab: Literal["Support", "Retention", "Workflow", "Agents"],
):
"""Sets the active tab."""
self.active_tab = tab
| from typing import Literal | |
from typing import Literal
|
class DashboardState(rx.State):
"""State to manage the active tab in the dashboard."""
active_tab: Literal["Support", "Retention", "Workflow", "Agents"] = "Retention"
@rx.event
def set_active_tab(
self,
tab: Literal["Support", "Retention", "Workflow", "Agents"],
):
"""Sets the active tab."""
self.active_tab = tab
| import reflex as rx |
from typing import Literal
import reflex as rx
class DashboardState(rx.State):
"""State to manage the active tab in the dashboard."""
active_tab: Literal["Support", "Retention", "Workflow", "Agents"] = "Retention"
@rx.event
def set_active_tab(
self,
tab: Literal["Support", "Retention", "Workflow", "Agents"],
):
"""Sets the active tab."""
| self.active_tab = tab | |
import reflex as rx
from retention_dashboard.states.data import retention_data_raw
class RetentionWeekData(TypedDict):
value: Optional[float]
count: Optional[int]
class RetentionCohortData(TypedDict):
cohort: str
initial_customers: int
weeks: List[RetentionWeekData]
class RetentionState(rx.State):
"""State for the Cohort Retention tab."""
column_headers: list[str] = [
"Cohort",
"Week 0",
"Week 1",
"Week 2",
"Week 3",
"Week 4",
"Week 5",
"Week 6",
"Week 7",
"Week 8",
"Week 9",
]
retention_data: list[RetentionCohortData] = retention_data_raw
def get_cell_color(self, percentage: float) -> str:
"""Returns background color based on percentage."""
if percentage >= 80:
return "bg-blue-600"
elif percentage >= 60:
return "bg-blue-500"
elif percentage >= 40:
return "bg-blue-400"
elif | from typing import List, Optional, TypedDict | |
from typing import List, Optional, TypedDict
|
from retention_dashboard.states.data import retention_data_raw
class RetentionWeekData(TypedDict):
value: Optional[float]
count: Optional[int]
class RetentionCohortData(TypedDict):
cohort: str
initial_customers: int
weeks: List[RetentionWeekData]
class RetentionState(rx.State):
"""State for the Cohort Retention tab."""
column_headers: list[str] = [
"Cohort",
"Week 0",
"Week 1",
"Week 2",
"Week 3",
"Week 4",
"Week 5",
"Week 6",
"Week 7",
"Week 8",
"Week 9",
]
retention_data: list[RetentionCohortData] = retention_data_raw
def get_cell_color(self, percentage: float) -> str:
"""Returns background color based on percentage."""
if percentage >= 80:
return "bg-blue-600"
elif percentage >= 60:
return "bg-blue-500"
elif percentage >= 40:
return "bg-blue-400"
elif percentage >= 20:
| import reflex as rx |
from typing import List, Optional, TypedDict
import reflex as rx
|
class RetentionWeekData(TypedDict):
value: Optional[float]
count: Optional[int]
class RetentionCohortData(TypedDict):
cohort: str
initial_customers: int
weeks: List[RetentionWeekData]
class RetentionState(rx.State):
"""State for the Cohort Retention tab."""
column_headers: list[str] = [
"Cohort",
"Week 0",
"Week 1",
"Week 2",
"Week 3",
"Week 4",
"Week 5",
"Week 6",
"Week 7",
"Week 8",
"Week 9",
]
retention_data: list[RetentionCohortData] = retention_data_raw
def get_cell_color(self, percentage: float) -> str:
"""Returns background color based on percentage."""
if percentage >= 80:
return "bg-blue-600"
elif percentage >= 60:
return "bg-blue-500"
elif percentage >= 40:
return "bg-blue-400"
elif percentage >= 20:
return "bg-blue-300"
elif percentage > 0:
| from retention_dashboard.states.data import retention_data_raw |
from typing import List, Optional, TypedDict
import reflex as rx
from retention_dashboard.states.data import retention_data_raw
|
class RetentionCohortData(TypedDict):
cohort: str
initial_customers: int
weeks: List[RetentionWeekData]
class RetentionState(rx.State):
"""State for the Cohort Retention tab."""
column_headers: list[str] = [
"Cohort",
"Week 0",
"Week 1",
"Week 2",
"Week 3",
"Week 4",
"Week 5",
"Week 6",
"Week 7",
"Week 8",
"Week 9",
]
retention_data: list[RetentionCohortData] = retention_data_raw
def get_cell_color(self, percentage: float) -> str:
"""Returns background color based on percentage."""
if percentage >= 80:
return "bg-blue-600"
elif percentage >= 60:
return "bg-blue-500"
elif percentage >= 40:
return "bg-blue-400"
elif percentage >= 20:
return "bg-blue-300"
elif percentage > 0:
return "bg-blue-200"
return "bg-gray-100"
| class RetentionWeekData(TypedDict):
value: Optional[float]
count: Optional[int] |
from typing import List, Optional, TypedDict
import reflex as rx
from retention_dashboard.states.data import retention_data_raw
class RetentionWeekData(TypedDict):
value: Optional[float]
count: Optional[int]
|
class RetentionState(rx.State):
"""State for the Cohort Retention tab."""
column_headers: list[str] = [
"Cohort",
"Week 0",
"Week 1",
"Week 2",
"Week 3",
"Week 4",
"Week 5",
"Week 6",
"Week 7",
"Week 8",
"Week 9",
]
retention_data: list[RetentionCohortData] = retention_data_raw
def get_cell_color(self, percentage: float) -> str:
"""Returns background color based on percentage."""
if percentage >= 80:
return "bg-blue-600"
elif percentage >= 60:
return "bg-blue-500"
elif percentage >= 40:
return "bg-blue-400"
elif percentage >= 20:
return "bg-blue-300"
elif percentage > 0:
return "bg-blue-200"
return "bg-gray-100"
| class RetentionCohortData(TypedDict):
cohort: str
initial_customers: int
weeks: List[RetentionWeekData] |
dDict
import reflex as rx
from retention_dashboard.states.data import retention_data_raw
class RetentionWeekData(TypedDict):
value: Optional[float]
count: Optional[int]
class RetentionCohortData(TypedDict):
cohort: str
initial_customers: int
weeks: List[RetentionWeekData]
class RetentionState(rx.State):
"""State for the Cohort Retention tab."""
column_headers: list[str] = [
"Cohort",
"Week 0",
"Week 1",
"Week 2",
"Week 3",
"Week 4",
"Week 5",
"Week 6",
"Week 7",
"Week 8",
"Week 9",
]
retention_data: list[RetentionCohortData] = retention_data_raw
def get_cell_color(self, percentage: float) -> str:
"""Returns background color based on percentage."""
if percentage >= 80:
return "bg-blue-600"
elif percentage >= 60:
return "bg-blue-500"
elif percentage >= 40:
return "bg-blue-400"
|
return "bg-gray-100"
| elif percentage >= 20:
return "bg-blue-300"
elif percentage > 0:
return "bg-blue-200" |
import retention_data_raw
class RetentionWeekData(TypedDict):
value: Optional[float]
count: Optional[int]
class RetentionCohortData(TypedDict):
cohort: str
initial_customers: int
weeks: List[RetentionWeekData]
class RetentionState(rx.State):
"""State for the Cohort Retention tab."""
column_headers: list[str] = [
"Cohort",
"Week 0",
"Week 1",
"Week 2",
"Week 3",
"Week 4",
"Week 5",
"Week 6",
"Week 7",
"Week 8",
"Week 9",
]
retention_data: list[RetentionCohortData] = retention_data_raw
def get_cell_color(self, percentage: float) -> str:
"""Returns background color based on percentage."""
if percentage >= 80:
return "bg-blue-600"
elif percentage >= 60:
return "bg-blue-500"
elif percentage >= 40:
return "bg-blue-400"
elif percentage >= 20:
return "bg-blue-300"
|
return "bg-gray-100"
| elif percentage > 0:
return "bg-blue-200" |
from typing import Dict, List, TypedDict
|
class ChartData(TypedDict):
name: str
value: int
percentage: float
fill: str
class WorkflowState(rx.State):
"""State for the Workflow tab."""
test_quota: int = 34
departments: List[str] = [
"Customer Service",
"Technical Support",
"Billing Support",
"Claims Processing",
"Account Management",
"Sales Support",
]
excluded_departments: Dict[str, bool] = {dept: False for dept in departments}
completed_cases_data: list[ChartData] = [
{
"name": "Completed",
"value": 11327,
"percentage": 100.0,
"fill": "#3b82f6",
}
]
test_results_data_tested: list[ChartData] = [
{
"name": "Tested",
"value": 3874,
"percentage": 34.2,
"fill": "#3b82f6",
}
]
test_results_data_untested: list[ChartData] = [
{
"name": "Untested",
"value": 7453,
| import reflex as rx |
from typing import Dict, List, TypedDict
import reflex as rx
|
class WorkflowState(rx.State):
"""State for the Workflow tab."""
test_quota: int = 34
departments: List[str] = [
"Customer Service",
"Technical Support",
"Billing Support",
"Claims Processing",
"Account Management",
"Sales Support",
]
excluded_departments: Dict[str, bool] = {dept: False for dept in departments}
completed_cases_data: list[ChartData] = [
{
"name": "Completed",
"value": 11327,
"percentage": 100.0,
"fill": "#3b82f6",
}
]
test_results_data_tested: list[ChartData] = [
{
"name": "Tested",
"value": 3874,
"percentage": 34.2,
"fill": "#3b82f6",
}
]
test_results_data_untested: list[ChartData] = [
{
"name": "Untested",
"value": 7453,
"percentage": 65.8,
"fill": "#d1d5db",
}
]
impact_data_error_ | class ChartData(TypedDict):
name: str
value: int
percentage: float
fill: str |
completed_cases_data: list[ChartData] = [
{
"name": "Completed",
"value": 11327,
"percentage": 100.0,
"fill": "#3b82f6",
}
]
test_results_data_tested: list[ChartData] = [
{
"name": "Tested",
"value": 3874,
"percentage": 34.2,
"fill": "#3b82f6",
}
]
test_results_data_untested: list[ChartData] = [
{
"name": "Untested",
"value": 7453,
"percentage": 65.8,
"fill": "#d1d5db",
}
]
impact_data_error_free: list[ChartData] = [
{
"name": "Error-free",
"value": 3413,
"percentage": 30.1,
"fill": "#10b981",
}
]
impact_data_corrected: list[ChartData] = [
{
"name": "Corrected",
"value": 461,
"percentage": 4.1,
"fill": "#ef4444",
}
]
@rx.event
|
@rx.event
def toggle_department(self, dept_name: str):
"""Toggles the exclusion status of a department."""
self.excluded_departments[dept_name] = not self.excluded_departments[dept_name]
| def set_test_quota(self, value: str):
"""Sets the test quota value from the slider."""
self.test_quota = int(value) |
"name": "Tested",
"value": 3874,
"percentage": 34.2,
"fill": "#3b82f6",
}
]
test_results_data_untested: list[ChartData] = [
{
"name": "Untested",
"value": 7453,
"percentage": 65.8,
"fill": "#d1d5db",
}
]
impact_data_error_free: list[ChartData] = [
{
"name": "Error-free",
"value": 3413,
"percentage": 30.1,
"fill": "#10b981",
}
]
impact_data_corrected: list[ChartData] = [
{
"name": "Corrected",
"value": 461,
"percentage": 4.1,
"fill": "#ef4444",
}
]
@rx.event
def set_test_quota(self, value: str):
"""Sets the test quota value from the slider."""
self.test_quota = int(value)
@rx.event
def toggle_department(self, dept_name: str):
"""Toggles the exclusion status of a department."""
| self.excluded_departments[dept_name] = not self.excluded_departments[dept_name] | |
from .backend.backend import State
from .views.email import email_gen_ui
from .views.navbar import navbar
from .views.table import main_table
def index() -> rx.Component:
return rx.vstack(
navbar(),
rx.flex(
rx.box(main_table(), width=["100%", "100%", "100%", "60%"]),
email_gen_ui(),
spacing="6",
width="100%",
flex_direction=["column", "column", "column", "row"],
),
height="100vh",
bg=rx.color("accent", 1),
width="100%",
spacing="6",
padding_x=["1.5em", "1.5em", "3em"],
padding_y=["1em", "1em", "2em"],
)
app = rx.App(
theme=rx.theme(
appearance="light", has_background=True, radius="large", accent_color="blue"
),
)
app.add_page(
index,
on_load=State.load_entries,
title="Sales App",
description="Generate personalized sales emails.",
)
| import reflex as rx | |
import reflex as rx
|
from .views.email import email_gen_ui
from .views.navbar import navbar
from .views.table import main_table
def index() -> rx.Component:
return rx.vstack(
navbar(),
rx.flex(
rx.box(main_table(), width=["100%", "100%", "100%", "60%"]),
email_gen_ui(),
spacing="6",
width="100%",
flex_direction=["column", "column", "column", "row"],
),
height="100vh",
bg=rx.color("accent", 1),
width="100%",
spacing="6",
padding_x=["1.5em", "1.5em", "3em"],
padding_y=["1em", "1em", "2em"],
)
app = rx.App(
theme=rx.theme(
appearance="light", has_background=True, radius="large", accent_color="blue"
),
)
app.add_page(
index,
on_load=State.load_entries,
title="Sales App",
description="Generate personalized sales emails.",
)
| from .backend.backend import State |
import reflex as rx
from .backend.backend import State
|
from .views.navbar import navbar
from .views.table import main_table
def index() -> rx.Component:
return rx.vstack(
navbar(),
rx.flex(
rx.box(main_table(), width=["100%", "100%", "100%", "60%"]),
email_gen_ui(),
spacing="6",
width="100%",
flex_direction=["column", "column", "column", "row"],
),
height="100vh",
bg=rx.color("accent", 1),
width="100%",
spacing="6",
padding_x=["1.5em", "1.5em", "3em"],
padding_y=["1em", "1em", "2em"],
)
app = rx.App(
theme=rx.theme(
appearance="light", has_background=True, radius="large", accent_color="blue"
),
)
app.add_page(
index,
on_load=State.load_entries,
title="Sales App",
description="Generate personalized sales emails.",
)
| from .views.email import email_gen_ui |
import reflex as rx
from .backend.backend import State
from .views.email import email_gen_ui
|
from .views.table import main_table
def index() -> rx.Component:
return rx.vstack(
navbar(),
rx.flex(
rx.box(main_table(), width=["100%", "100%", "100%", "60%"]),
email_gen_ui(),
spacing="6",
width="100%",
flex_direction=["column", "column", "column", "row"],
),
height="100vh",
bg=rx.color("accent", 1),
width="100%",
spacing="6",
padding_x=["1.5em", "1.5em", "3em"],
padding_y=["1em", "1em", "2em"],
)
app = rx.App(
theme=rx.theme(
appearance="light", has_background=True, radius="large", accent_color="blue"
),
)
app.add_page(
index,
on_load=State.load_entries,
title="Sales App",
description="Generate personalized sales emails.",
)
| from .views.navbar import navbar |
import reflex as rx
from .backend.backend import State
from .views.email import email_gen_ui
from .views.navbar import navbar
|
def index() -> rx.Component:
return rx.vstack(
navbar(),
rx.flex(
rx.box(main_table(), width=["100%", "100%", "100%", "60%"]),
email_gen_ui(),
spacing="6",
width="100%",
flex_direction=["column", "column", "column", "row"],
),
height="100vh",
bg=rx.color("accent", 1),
width="100%",
spacing="6",
padding_x=["1.5em", "1.5em", "3em"],
padding_y=["1em", "1em", "2em"],
)
app = rx.App(
theme=rx.theme(
appearance="light", has_background=True, radius="large", accent_color="blue"
),
)
app.add_page(
index,
on_load=State.load_entries,
title="Sales App",
description="Generate personalized sales emails.",
)
| from .views.table import main_table |
import os
|
import reflex as rx
from sqlmodel import asc, desc, func, or_, select
from .models import Customer
products: dict[str, dict] = {
"T-shirt": {
"description": "A plain white t-shirt made of 100% cotton.",
"price": 10.99,
},
"Jeans": {
"description": "A pair of blue denim jeans with a straight leg fit.",
"price": 24.99,
},
"Hoodie": {
"description": "A black hoodie made of a cotton and polyester blend.",
"price": 34.99,
},
"Cardigan": {
"description": "A grey cardigan with a V-neck and long sleeves.",
"price": 36.99,
},
"Joggers": {
"description": "A pair of black joggers made of a cotton and polyester blend.",
"price": 44.99,
},
"Dress": {"description": "A black dress made of 100% polyester.", "price": 49.99},
"Jacket": {
"description": "A navy blue jacket made of 100% cotton.",
"price": 55.99,
},
"Skirt": {
"description": "A b | import openai |
import os
import openai
|
from sqlmodel import asc, desc, func, or_, select
from .models import Customer
products: dict[str, dict] = {
"T-shirt": {
"description": "A plain white t-shirt made of 100% cotton.",
"price": 10.99,
},
"Jeans": {
"description": "A pair of blue denim jeans with a straight leg fit.",
"price": 24.99,
},
"Hoodie": {
"description": "A black hoodie made of a cotton and polyester blend.",
"price": 34.99,
},
"Cardigan": {
"description": "A grey cardigan with a V-neck and long sleeves.",
"price": 36.99,
},
"Joggers": {
"description": "A pair of black joggers made of a cotton and polyester blend.",
"price": 44.99,
},
"Dress": {"description": "A black dress made of 100% polyester.", "price": 49.99},
"Jacket": {
"description": "A navy blue jacket made of 100% cotton.",
"price": 55.99,
},
"Skirt": {
"description": "A brown skirt made of a | import reflex as rx |
import os
import openai
import reflex as rx
|
from .models import Customer
products: dict[str, dict] = {
"T-shirt": {
"description": "A plain white t-shirt made of 100% cotton.",
"price": 10.99,
},
"Jeans": {
"description": "A pair of blue denim jeans with a straight leg fit.",
"price": 24.99,
},
"Hoodie": {
"description": "A black hoodie made of a cotton and polyester blend.",
"price": 34.99,
},
"Cardigan": {
"description": "A grey cardigan with a V-neck and long sleeves.",
"price": 36.99,
},
"Joggers": {
"description": "A pair of black joggers made of a cotton and polyester blend.",
"price": 44.99,
},
"Dress": {"description": "A black dress made of 100% polyester.", "price": 49.99},
"Jacket": {
"description": "A navy blue jacket made of 100% cotton.",
"price": 55.99,
},
"Skirt": {
"description": "A brown skirt made of a cotton and polyester blend.",
"price": 29 | from sqlmodel import asc, desc, func, or_, select |
import os
import openai
import reflex as rx
from sqlmodel import asc, desc, func, or_, select
|
products: dict[str, dict] = {
"T-shirt": {
"description": "A plain white t-shirt made of 100% cotton.",
"price": 10.99,
},
"Jeans": {
"description": "A pair of blue denim jeans with a straight leg fit.",
"price": 24.99,
},
"Hoodie": {
"description": "A black hoodie made of a cotton and polyester blend.",
"price": 34.99,
},
"Cardigan": {
"description": "A grey cardigan with a V-neck and long sleeves.",
"price": 36.99,
},
"Joggers": {
"description": "A pair of black joggers made of a cotton and polyester blend.",
"price": 44.99,
},
"Dress": {"description": "A black dress made of 100% polyester.", "price": 49.99},
"Jacket": {
"description": "A navy blue jacket made of 100% cotton.",
"price": 55.99,
},
"Skirt": {
"description": "A brown skirt made of a cotton and polyester blend.",
"price": 29.99,
},
"Shorts": {
| from .models import Customer |
"price": 24.99,
},
"Hoodie": {
"description": "A black hoodie made of a cotton and polyester blend.",
"price": 34.99,
},
"Cardigan": {
"description": "A grey cardigan with a V-neck and long sleeves.",
"price": 36.99,
},
"Joggers": {
"description": "A pair of black joggers made of a cotton and polyester blend.",
"price": 44.99,
},
"Dress": {"description": "A black dress made of 100% polyester.", "price": 49.99},
"Jacket": {
"description": "A navy blue jacket made of 100% cotton.",
"price": 55.99,
},
"Skirt": {
"description": "A brown skirt made of a cotton and polyester blend.",
"price": 29.99,
},
"Shorts": {
"description": "A pair of black shorts made of a cotton and polyester blend.",
"price": 19.99,
},
"Sweater": {
"description": "A white sweater with a crew neck and long sleeves.",
"price": 39.99,
},
}
|
def get_openai_client():
global _client
if _client is None:
_client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
return _client
class State(rx.State):
"""The app state."""
current_user: Customer = Customer()
users: list[Customer] = []
products: dict[str, str] = {}
email_content_data: str = (
"Click 'Generate Email' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = | _client = None |
.99,
},
"Hoodie": {
"description": "A black hoodie made of a cotton and polyester blend.",
"price": 34.99,
},
"Cardigan": {
"description": "A grey cardigan with a V-neck and long sleeves.",
"price": 36.99,
},
"Joggers": {
"description": "A pair of black joggers made of a cotton and polyester blend.",
"price": 44.99,
},
"Dress": {"description": "A black dress made of 100% polyester.", "price": 49.99},
"Jacket": {
"description": "A navy blue jacket made of 100% cotton.",
"price": 55.99,
},
"Skirt": {
"description": "A brown skirt made of a cotton and polyester blend.",
"price": 29.99,
},
"Shorts": {
"description": "A pair of black shorts made of a cotton and polyester blend.",
"price": 19.99,
},
"Sweater": {
"description": "A white sweater with a crew neck and long sleeves.",
"price": 39.99,
},
}
_client = None
|
class State(rx.State):
"""The app state."""
current_user: Customer = Customer()
users: list[Customer] = []
products: dict[str, str] = {}
email_content_data: str = (
"Click 'Generate Email' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getat | def get_openai_client():
global _client
if _client is None:
_client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
return _client |
": "A black hoodie made of a cotton and polyester blend.",
"price": 34.99,
},
"Cardigan": {
"description": "A grey cardigan with a V-neck and long sleeves.",
"price": 36.99,
},
"Joggers": {
"description": "A pair of black joggers made of a cotton and polyester blend.",
"price": 44.99,
},
"Dress": {"description": "A black dress made of 100% polyester.", "price": 49.99},
"Jacket": {
"description": "A navy blue jacket made of 100% cotton.",
"price": 55.99,
},
"Skirt": {
"description": "A brown skirt made of a cotton and polyester blend.",
"price": 29.99,
},
"Shorts": {
"description": "A pair of black shorts made of a cotton and polyester blend.",
"price": 19.99,
},
"Sweater": {
"description": "A white sweater with a crew neck and long sleeves.",
"price": 39.99,
},
}
_client = None
def get_openai_client():
global _client
|
return _client
class State(rx.State):
"""The app state."""
current_user: Customer = Customer()
users: list[Customer] = []
products: dict[str, str] = {}
email_content_data: str = (
"Click 'Generate Email' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
| if _client is None:
_client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"]) |
cotton and polyester blend.",
"price": 34.99,
},
"Cardigan": {
"description": "A grey cardigan with a V-neck and long sleeves.",
"price": 36.99,
},
"Joggers": {
"description": "A pair of black joggers made of a cotton and polyester blend.",
"price": 44.99,
},
"Dress": {"description": "A black dress made of 100% polyester.", "price": 49.99},
"Jacket": {
"description": "A navy blue jacket made of 100% cotton.",
"price": 55.99,
},
"Skirt": {
"description": "A brown skirt made of a cotton and polyester blend.",
"price": 29.99,
},
"Shorts": {
"description": "A pair of black shorts made of a cotton and polyester blend.",
"price": 19.99,
},
"Sweater": {
"description": "A white sweater with a crew neck and long sleeves.",
"price": 39.99,
},
}
_client = None
def get_openai_client():
global _client
if _client is None:
|
return _client
class State(rx.State):
"""The app state."""
current_user: Customer = Customer()
users: list[Customer] = []
products: dict[str, str] = {}
email_content_data: str = (
"Click 'Generate Email' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
| _client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"]) |
black dress made of 100% polyester.", "price": 49.99},
"Jacket": {
"description": "A navy blue jacket made of 100% cotton.",
"price": 55.99,
},
"Skirt": {
"description": "A brown skirt made of a cotton and polyester blend.",
"price": 29.99,
},
"Shorts": {
"description": "A pair of black shorts made of a cotton and polyester blend.",
"price": 19.99,
},
"Sweater": {
"description": "A white sweater with a crew neck and long sleeves.",
"price": 39.99,
},
}
_client = None
def get_openai_client():
global _client
if _client is None:
_client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
return _client
class State(rx.State):
"""The app state."""
current_user: Customer = Customer()
users: list[Customer] = []
products: dict[str, str] = {}
email_content_data: str = (
"Click 'Generate Email' to generate a personalized sales email."
)
|
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self. | gen_response = False |
Skirt": {
"description": "A brown skirt made of a cotton and polyester blend.",
"price": 29.99,
},
"Shorts": {
"description": "A pair of black shorts made of a cotton and polyester blend.",
"price": 19.99,
},
"Sweater": {
"description": "A white sweater with a crew neck and long sleeves.",
"price": 39.99,
},
}
_client = None
def get_openai_client():
global _client
if _client is None:
_client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
return _client
class State(rx.State):
"""The app state."""
current_user: Customer = Customer()
users: list[Customer] = []
products: dict[str, str] = {}
email_content_data: str = (
"Click 'Generate Email' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
|
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_ | def set_tone(self, value: str):
self.tone = value |
n skirt made of a cotton and polyester blend.",
"price": 29.99,
},
"Shorts": {
"description": "A pair of black shorts made of a cotton and polyester blend.",
"price": 19.99,
},
"Sweater": {
"description": "A white sweater with a crew neck and long sleeves.",
"price": 39.99,
},
}
_client = None
def get_openai_client():
global _client
if _client is None:
_client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
return _client
class State(rx.State):
"""The app state."""
current_user: Customer = Customer()
users: list[Customer] = []
products: dict[str, str] = {}
email_content_data: str = (
"Click 'Generate Email' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
|
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_ | self.tone = value |
r blend.",
"price": 29.99,
},
"Shorts": {
"description": "A pair of black shorts made of a cotton and polyester blend.",
"price": 19.99,
},
"Sweater": {
"description": "A white sweater with a crew neck and long sleeves.",
"price": 39.99,
},
}
_client = None
def get_openai_client():
global _client
if _client is None:
_client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
return _client
class State(rx.State):
"""The app state."""
current_user: Customer = Customer()
users: list[Customer] = []
products: dict[str, str] = {}
email_content_data: str = (
"Click 'Generate Email' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
|
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_ | def set_length(self, value: list[int | float]):
self.length = int(value[0]) |
{
"description": "A pair of black shorts made of a cotton and polyester blend.",
"price": 19.99,
},
"Sweater": {
"description": "A white sweater with a crew neck and long sleeves.",
"price": 39.99,
},
}
_client = None
def get_openai_client():
global _client
if _client is None:
_client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
return _client
class State(rx.State):
"""The app state."""
current_user: Customer = Customer()
users: list[Customer] = []
products: dict[str, str] = {}
email_content_data: str = (
"Click 'Generate Email' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
|
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_ | self.length = int(value[0]) |
ater with a crew neck and long sleeves.",
"price": 39.99,
},
}
_client = None
def get_openai_client():
global _client
if _client is None:
_client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
return _client
class State(rx.State):
"""The app state."""
current_user: Customer = Customer()
users: list[Customer] = []
products: dict[str, str] = {}
email_content_data: str = (
"Click 'Generate Email' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
|
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_column))
)
query = query.order_by(order)
self.users = session.exec(query).all()
def sort_values(self, sort_value: s | query = select(Customer) |
s.",
"price": 39.99,
},
}
_client = None
def get_openai_client():
global _client
if _client is None:
_client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
return _client
class State(rx.State):
"""The app state."""
current_user: Customer = Customer()
users: list[Customer] = []
products: dict[str, str] = {}
email_content_data: str = (
"Click 'Generate Email' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
|
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_column))
)
query = query.order_by(order)
self.users = session.exec(query).all()
def sort_values(self, sort_value: str):
self.sort_value = sort_value
self.load_entries()
def toggle_sort(self):
self.sort_reverse = not self.sort_reverse
self.load_entries()
def filter_values(self, search_value):
self.search_value = search_value
self.load_entries()
def get_user(self, user: Customer):
self.current_user = user
def add_customer_to_db(self | if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
) |
_client = None
def get_openai_client():
global _client
if _client is None:
_client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
return _client
class State(rx.State):
"""The app state."""
current_user: Customer = Customer()
users: list[Customer] = []
products: dict[str, str] = {}
email_content_data: str = (
"Click 'Generate Email' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
|
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_column))
)
query = query.order_by(order)
self.users = session.exec(query).all()
def sort_values(self, sort_value: str):
self.sort_value = sort_value
self.load_entries()
def toggle_sort(self):
| search_value = f"%{str(self.search_value).lower()}%" |
_client is None:
_client = openai.OpenAI(api_key=os.environ["OPENAI_API_KEY"])
return _client
class State(rx.State):
"""The app state."""
current_user: Customer = Customer()
users: list[Customer] = []
products: dict[str, str] = {}
email_content_data: str = (
"Click 'Generate Email' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
|
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_column))
)
query = query.order_by(order)
self.users = session.exec(query).all()
def sort_values(self, sort_value: str):
self.sort_value = sort_value
self.load_entries()
def toggle_sort(self):
self.sort_reverse = not self.sort_reverse
self.load_entries()
def filter_values(self, search_value):
self.search_value = search_value
self.load_entries()
def get_user(self, user: Customer):
self.current_user = user
def add_customer_to_db(self | query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
) |
r = (
"Click 'Generate Email' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
|
self.users = session.exec(query).all()
def sort_values(self, sort_value: str):
self.sort_value = sort_value
self.load_entries()
def toggle_sort(self):
self.sort_reverse = not self.sort_reverse
self.load_entries()
def filter_values(self, search_value):
self.search_value = search_value
self.load_entries()
def get_user(self, user: Customer):
self.current_user = user
def add_customer_to_db(self, form_data: dict):
self.current_user = Customer(**form_data)
with rx.session() as session:
if session.exec(
select(Customer).where(Customer.email == self.current_user.email)
).first():
return rx.window_alert("User with this email already exists")
session.add(self.current_user)
session.commit()
session.refresh(self.current_user)
self.load_entries()
return rx.toast.info(
f" | if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_column))
)
query = query.order_by(order) |
' to generate a personalized sales email."
)
gen_response = False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
|
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_column))
)
query = query.order_by(order)
self.users = session.exec(query).all()
def sort_values(self, sort_value: str):
self.sort_value = sort_value
self.load_entries()
def toggle_sort(self):
self.sort_reverse = not self.sort_reverse
self.load_entries()
def filter_values(self, search_value):
self.search_value = search_value
self.load_entries()
def get_user(self, user: Customer):
self.current_user = user
def add_customer_to_db(self, form_data: dict):
self.current_user = Customer(**form_data)
with rx.session() a | sort_column = getattr(Customer, self.sort_value) |
= False
tone: str = "π Formal"
length: int = 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
|
query = query.order_by(order)
self.users = session.exec(query).all()
def sort_values(self, sort_value: str):
self.sort_value = sort_value
self.load_entries()
def toggle_sort(self):
self.sort_reverse = not self.sort_reverse
self.load_entries()
def filter_values(self, search_value):
self.search_value = search_value
self.load_entries()
def get_user(self, user: Customer):
self.current_user = user
def add_customer_to_db(self, form_data: dict):
self.current_user = Customer(**form_data)
with rx.session() as session:
if session.exec(
select(Customer).where(Customer.email == self.current_user.email)
).first():
return rx.window_alert("User with this email already exists")
session.add(self.current_user)
session.commit()
session.refresh(self.current_user)
self.load_entries( | if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_column))
) |
= 1000
search_value: str = ""
sort_value: str = ""
sort_reverse: bool = False
@rx.event
def set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
|
else:
order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_column))
)
query = query.order_by(order)
self.users = session.exec(query).all()
def sort_values(self, sort_value: str):
self.sort_value = sort_value
self.load_entries()
def toggle_sort(self):
self.sort_reverse = not self.sort_reverse
self.load_entries()
def filter_values(self, search_value):
self.search_value = search_value
self.load_entries()
def get_user(self, user: Customer):
self.current_user = user
def add_customer_to_db(self, form_data: dict):
self.current_user = Customer(**form_data)
with rx.session() as session:
if session.exec(
select(Customer).where(Customer.email == self.current_user.email)
).f | order = desc(sort_column) if self.sort_reverse else asc(sort_column) |
f set_tone(self, value: str):
self.tone = value
@rx.event
def set_length(self, value: list[int | float]):
self.length = int(value[0])
def load_entries(self) -> list[Customer]:
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
|
query = query.order_by(order)
self.users = session.exec(query).all()
def sort_values(self, sort_value: str):
self.sort_value = sort_value
self.load_entries()
def toggle_sort(self):
self.sort_reverse = not self.sort_reverse
self.load_entries()
def filter_values(self, search_value):
self.search_value = search_value
self.load_entries()
def get_user(self, user: Customer):
self.current_user = user
def add_customer_to_db(self, form_data: dict):
self.current_user = Customer(**form_data)
with rx.session() as session:
if session.exec(
select(Customer).where(Customer.email == self.current_user.email)
).first():
return rx.window_alert("User with this email already exists")
session.add(self.current_user)
session.commit()
session.refresh(self.current_user)
self.load_entries( | order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_column))
) |
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_column))
)
|
self.users = session.exec(query).all()
def sort_values(self, sort_value: str):
self.sort_value = sort_value
self.load_entries()
def toggle_sort(self):
self.sort_reverse = not self.sort_reverse
self.load_entries()
def filter_values(self, search_value):
self.search_value = search_value
self.load_entries()
def get_user(self, user: Customer):
self.current_user = user
def add_customer_to_db(self, form_data: dict):
self.current_user = Customer(**form_data)
with rx.session() as session:
if session.exec(
select(Customer).where(Customer.email == self.current_user.email)
).first():
return rx.window_alert("User with this email already exists")
session.add(self.current_user)
session.commit()
session.refresh(self.current_user)
self.load_entries()
return rx.toast.info(
f" | query = query.order_by(order) |
."""
with rx.session() as session:
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_column))
)
query = query.order_by(order)
|
def sort_values(self, sort_value: str):
self.sort_value = sort_value
self.load_entries()
def toggle_sort(self):
self.sort_reverse = not self.sort_reverse
self.load_entries()
def filter_values(self, search_value):
self.search_value = search_value
self.load_entries()
def get_user(self, user: Customer):
self.current_user = user
def add_customer_to_db(self, form_data: dict):
self.current_user = Customer(**form_data)
with rx.session() as session:
if session.exec(
select(Customer).where(Customer.email == self.current_user.email)
).first():
return rx.window_alert("User with this email already exists")
session.add(self.current_user)
session.commit()
session.refresh(self.current_user)
self.load_entries()
return rx.toast.info(
f"User {self.current_user.customer_name} has been adde | self.users = session.exec(query).all() |
query = select(Customer)
if self.search_value:
search_value = f"%{str(self.search_value).lower()}%"
query = query.where(
or_(
*[
getattr(Customer, field).ilike(search_value)
for field in Customer.get_fields()
],
)
)
if self.sort_value:
sort_column = getattr(Customer, self.sort_value)
if self.sort_value == "salary":
order = desc(sort_column) if self.sort_reverse else asc(sort_column)
else:
order = (
desc(func.lower(sort_column))
if self.sort_reverse
else asc(func.lower(sort_column))
)
query = query.order_by(order)
self.users = session.exec(query).all()
|
def toggle_sort(self):
self.sort_reverse = not self.sort_reverse
self.load_entries()
def filter_values(self, search_value):
self.search_value = search_value
self.load_entries()
def get_user(self, user: Customer):
self.current_user = user
def add_customer_to_db(self, form_data: dict):
self.current_user = Customer(**form_data)
with rx.session() as session:
if session.exec(
select(Customer).where(Customer.email == self.current_user.email)
).first():
return rx.window_alert("User with this email already exists")
session.add(self.current_user)
session.commit()
session.refresh(self.current_user)
self.load_entries()
return rx.toast.info(
f"User {self.current_user.customer_name} has been added.",
position="bottom-right",
)
def update_customer_to_db(self, form_data: dict):
| def sort_values(self, sort_value: str):
self.sort_value = sort_value
self.load_entries() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.