instruction stringlengths 0 1k | input stringlengths 1 1k | output stringlengths 10 6.51k |
|---|---|---|
def get_sort_value(customer_data_item: CustomerData):
if self.sort_column == "name":
first = customer_data_item.get("first_name", "")
last = customer_data_item.get("last_name", "")
return (first.lower(), last.lower())
sort_val = customer_data_item.get(self.sort_column)
if isinstance(sort_val, str):
return sort_val.lower()
return sort_val
sorted_data = sorted(
data_to_process,
key=get_sort_value,
reverse=self.sort_order == "desc",
)
return sorted_data
@rx.var
def customers(self) -> List[CustomerData]:
data_for_page = self._processed_customers
start_index = (self.current_page - 1) * self.items_per_page
end_index = start_index + self.items_per_page
return data_for_page[start_index:end_index]
def _parse_tags_string(self, tags_str: str | None) -> List[str]:
|
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
ta | if not tags_str:
return [] |
CustomerData):
if self.sort_column == "name":
first = customer_data_item.get("first_name", "")
last = customer_data_item.get("last_name", "")
return (first.lower(), last.lower())
sort_val = customer_data_item.get(self.sort_column)
if isinstance(sort_val, str):
return sort_val.lower()
return sort_val
sorted_data = sorted(
data_to_process,
key=get_sort_value,
reverse=self.sort_order == "desc",
)
return sorted_data
@rx.var
def customers(self) -> List[CustomerData]:
data_for_page = self._processed_customers
start_index = (self.current_page - 1) * self.items_per_page
end_index = start_index + self.items_per_page
return data_for_page[start_index:end_index]
def _parse_tags_string(self, tags_str: str | None) -> List[str]:
if not tags_str:
return []
|
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_c | tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
] |
return (first.lower(), last.lower())
sort_val = customer_data_item.get(self.sort_column)
if isinstance(sort_val, str):
return sort_val.lower()
return sort_val
sorted_data = sorted(
data_to_process,
key=get_sort_value,
reverse=self.sort_order == "desc",
)
return sorted_data
@rx.var
def customers(self) -> List[CustomerData]:
data_for_page = self._processed_customers
start_index = (self.current_page - 1) * self.items_per_page
end_index = start_index + self.items_per_page
return data_for_page[start_index:end_index]
def _parse_tags_string(self, tags_str: str | None) -> List[str]:
if not tags_str:
return []
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
|
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
| for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag) |
wer())
sort_val = customer_data_item.get(self.sort_column)
if isinstance(sort_val, str):
return sort_val.lower()
return sort_val
sorted_data = sorted(
data_to_process,
key=get_sort_value,
reverse=self.sort_order == "desc",
)
return sorted_data
@rx.var
def customers(self) -> List[CustomerData]:
data_for_page = self._processed_customers
start_index = (self.current_page - 1) * self.items_per_page
end_index = start_index + self.items_per_page
return data_for_page[start_index:end_index]
def _parse_tags_string(self, tags_str: str | None) -> List[str]:
if not tags_str:
return []
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
|
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
| if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag) |
turn sort_val.lower()
return sort_val
sorted_data = sorted(
data_to_process,
key=get_sort_value,
reverse=self.sort_order == "desc",
)
return sorted_data
@rx.var
def customers(self) -> List[CustomerData]:
data_for_page = self._processed_customers
start_index = (self.current_page - 1) * self.items_per_page
end_index = start_index + self.items_per_page
return data_for_page[start_index:end_index]
def _parse_tags_string(self, tags_str: str | None) -> List[str]:
if not tags_str:
return []
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
|
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Char | def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list) |
ey=get_sort_value,
reverse=self.sort_order == "desc",
)
return sorted_data
@rx.var
def customers(self) -> List[CustomerData]:
data_for_page = self._processed_customers
start_index = (self.current_page - 1) * self.items_per_page
end_index = start_index + self.items_per_page
return data_for_page[start_index:end_index]
def _parse_tags_string(self, tags_str: str | None) -> List[str]:
if not tags_str:
return []
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
|
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
| def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1 |
er == "desc",
)
return sorted_data
@rx.var
def customers(self) -> List[CustomerData]:
data_for_page = self._processed_customers
start_index = (self.current_page - 1) * self.items_per_page
end_index = start_index + self.items_per_page
return data_for_page[start_index:end_index]
def _parse_tags_string(self, tags_str: str | None) -> List[str]:
if not tags_str:
return []
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
|
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
| if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc" |
ta
@rx.var
def customers(self) -> List[CustomerData]:
data_for_page = self._processed_customers
start_index = (self.current_page - 1) * self.items_per_page
end_index = start_index + self.items_per_page
return data_for_page[start_index:end_index]
def _parse_tags_string(self, tags_str: str | None) -> List[str]:
if not tags_str:
return []
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
|
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
| self.sort_order = "desc" if self.sort_order == "asc" else "asc" |
f._processed_customers
start_index = (self.current_page - 1) * self.items_per_page
end_index = start_index + self.items_per_page
return data_for_page[start_index:end_index]
def _parse_tags_string(self, tags_str: str | None) -> List[str]:
if not tags_str:
return []
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
|
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Joh | self.sort_column = column_name |
.items_per_page
end_index = start_index + self.items_per_page
return data_for_page[start_index:end_index]
def _parse_tags_string(self, tags_str: str | None) -> List[str]:
if not tags_str:
return []
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
|
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
| self.current_page = 1 |
rn data_for_page[start_index:end_index]
def _parse_tags_string(self, tags_str: str | None) -> List[str]:
if not tags_str:
return []
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
|
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
| self.loading = True |
:end_index]
def _parse_tags_string(self, tags_str: str | None) -> List[str]:
if not tags_str:
return []
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
|
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
| self.error_message = "" |
_string(self, tags_str: str | None) -> List[str]:
if not tags_str:
return []
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
|
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
| self.all_selected = False |
) -> List[str]:
if not tags_str:
return []
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
|
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.cho | target_email = self._target_customer_email_for_tags |
[]
tag_names_from_input = [
name.strip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
|
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.cho | target_tag_str = self._target_customer_tag_str |
rip() for name in tags_str.split(",") if name.strip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
|
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_ | target_role = self._target_customer_role |
ip()
]
unique_tags: List[str] = []
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
|
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,9 | self._target_customer_email_for_tags = None |
seen_tags: Set[str] = set()
for tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
|
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = | self._target_customer_tag_str = None |
r tag in tag_names_from_input:
if tag not in seen_tags:
unique_tags.append(tag)
seen_tags.add(tag)
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
|
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timede | self._target_customer_role = None |
return unique_tags
def _format_tags_list_to_string(self, tags_list: List[str]) -> str:
return ", ".join(tags_list)
@rx.event
def sort_by_column(self, column_name: str):
if self.sort_column == column_name:
self.sort_order = "desc" if self.sort_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
|
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, l | first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
] |
_order == "asc" else "asc"
else:
self.sort_column = column_name
self.sort_order = "asc"
self.current_page = 1
@rx.event
async def fetch_customers(self):
self.loading = True
self.error_message = ""
self.all_selected = False
target_email = self._target_customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
|
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
tags = random.sample(self.available_tags, num_tags)
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
if tar | last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
] |
customer_email_for_tags
target_tag_str = self._target_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
|
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
tags = random.sample(self.available_tags, num_tags)
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
if target_email and email == target_email:
if target_tag_str is not None:
| first_name = random.choice(first_names) |
arget_customer_tag_str
target_role = self._target_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
|
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
tags = random.sample(self.available_tags, num_tags)
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
if target_email and email == target_email:
if target_tag_str is not None:
tags = self._parse_tags_string | last_name = random.choice(last_names) |
get_customer_role
self._target_customer_email_for_tags = None
self._target_customer_tag_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
|
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
tags = random.sample(self.available_tags, num_tags)
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
if target_email and email == target_email:
if target_tag_str is not None:
tags = self._parse_tags_string(target_tag_str)
if target_role is not None:
role = target | email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com" |
g_str = None
self._target_customer_role = None
if not self._all_customers_data:
fake_customers_temp: List[CustomerData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
|
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
tags = random.sample(self.available_tags, num_tags)
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
if target_email and email == target_email:
if target_tag_str is not None:
tags = self._parse_tags_string(target_tag_str)
if target_role is not None:
role = target_role
fake_customers_temp.append(
CustomerData(
customer_id=self._next_customer_ | created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
) |
erData] = []
first_names = [
"John",
"Jane",
"Alice",
"Bob",
"Charlie",
"David",
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
|
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
tags = random.sample(self.available_tags, num_tags)
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
if target_email and email == target_email:
if target_tag_str is not None:
tags = self._parse_tags_string(target_tag_str)
if target_role is not None:
role = target_role
fake_customers_temp.append(
CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
| updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
) |
"Eve",
"Fiona",
"George",
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
|
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
if target_email and email == target_email:
if target_tag_str is not None:
tags = self._parse_tags_string(target_tag_str)
if target_role is not None:
role = target_role
fake_customers_temp.append(
CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice | if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
tags = random.sample(self.available_tags, num_tags) |
"Hannah",
]
last_names = [
"Doe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
|
tags = random.sample(self.available_tags, num_tags)
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
if target_email and email == target_email:
if target_tag_str is not None:
tags = self._parse_tags_string(target_tag_str)
if target_role is not None:
role = target_role
fake_customers_temp.append(
CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None | num_tags = random.randint(1, min(3, len(self.available_tags))) |
oe",
"Smith",
"Johnson",
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
|
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
if target_email and email == target_email:
if target_tag_str is not None:
tags = self._parse_tags_string(target_tag_str)
if target_role is not None:
role = target_role
fake_customers_temp.append(
CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice | tags = random.sample(self.available_tags, num_tags) |
"Brown",
"Williams",
"Jones",
"Davis",
"Miller",
"Wilson",
"Moore",
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
tags = random.sample(self.available_tags, num_tags)
|
if target_email and email == target_email:
if target_tag_str is not None:
tags = self._parse_tags_string(target_tag_str)
if target_role is not None:
role = target_role
fake_customers_temp.append(
CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
crea | role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
) |
]
for _ in range(25):
first_name = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
tags = random.sample(self.available_tags, num_tags)
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
|
fake_customers_temp.append(
CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
| if target_email and email == target_email:
if target_tag_str is not None:
tags = self._parse_tags_string(target_tag_str)
if target_role is not None:
role = target_role |
me = random.choice(first_names)
last_name = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
tags = random.sample(self.available_tags, num_tags)
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
if target_email and email == target_email:
|
if target_role is not None:
role = target_role
fake_customers_temp.append(
CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
| if target_tag_str is not None:
tags = self._parse_tags_string(target_tag_str) |
me = random.choice(last_names)
email = f"{first_name.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
tags = random.sample(self.available_tags, num_tags)
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
if target_email and email == target_email:
if target_tag_str is not None:
|
if target_role is not None:
role = target_role
fake_customers_temp.append(
CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
| tags = self._parse_tags_string(target_tag_str) |
e.lower()}.{last_name.lower()}{random.randint(1,99)}@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
tags = random.sample(self.available_tags, num_tags)
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
if target_email and email == target_email:
if target_tag_str is not None:
tags = self._parse_tags_string(target_tag_str)
|
fake_customers_temp.append(
CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
| if target_role is not None:
role = target_role |
@example.com"
created_at = datetime.datetime.now() - datetime.timedelta(
days=random.randint(0, 365)
)
updated_at = created_at + datetime.timedelta(
days=random.randint(0, (datetime.datetime.now() - created_at).days)
)
tags = []
if self.available_tags and random.random() > 0.3:
num_tags = random.randint(1, min(3, len(self.available_tags)))
tags = random.sample(self.available_tags, num_tags)
role = (
random.choice(self.available_roles)
if self.available_roles
else "N/A"
)
if target_email and email == target_email:
if target_tag_str is not None:
tags = self._parse_tags_string(target_tag_str)
if target_role is not None:
|
fake_customers_temp.append(
CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
| role = target_role |
one:
role = target_role
fake_customers_temp.append(
CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
|
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@ | self._all_customers_data = fake_customers_temp |
tomers_temp.append(
CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
|
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
| if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break |
CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
|
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
| for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break |
omer_id,
first_name=first_name,
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
|
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
| if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break |
last_name=last_name,
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
|
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
| if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
) |
email=email,
phone=(
f"555-{random.randint(100,999)}-{random.randint(1000,9999)}"
if random.random() > 0.2
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
|
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
| self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
) |
if random.random() > 0.2
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
|
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
| if target_role is not None:
self._all_customers_data[i]["role"] = target_role |
else None
),
status=random.choice(self.customer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
|
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
| self._all_customers_data[i]["role"] = target_role |
ustomer_statuses),
avatar_url="/favicon.ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
|
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tag | self.total_db_customers = len(self._all_customers_data) |
ico",
role=role,
tags=tags,
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
|
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
| if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1 |
created_at=created_at.isoformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
|
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
| self.current_page = self.total_pages |
soformat(),
updated_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
|
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
| elif self.current_page < 1:
self.current_page = 1 |
ted_at=updated_at.isoformat(),
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
|
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
| self.current_page = 1 |
selected=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
|
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_ed | self.loading = False |
cted=False,
)
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
|
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.er | self.error_message = "" |
)
self._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
|
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit | def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1 |
._next_customer_id += 1
self._all_customers_data = fake_customers_temp
else:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
|
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit | if self.current_page < self.total_pages:
self.current_page += 1 |
:
if target_email:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
|
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self. | def prev_page(self):
if self.current_page > 1:
self.current_page -= 1 |
:
for i, cust in enumerate(self._all_customers_data):
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
|
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self. | if self.current_page > 1:
self.current_page -= 1 |
if cust["email"] == target_email:
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
|
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
| def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = "" |
if target_tag_str is not None:
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
|
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.e | self.form_customer_id = customer["customer_id"] |
self._all_customers_data[i]["tags"] = (
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
|
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
| self.form_first_name = customer["first_name"] |
self._parse_tags_string(target_tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
|
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_f | self.form_last_name = customer["last_name"] |
tag_str)
)
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
|
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = | self.form_email = customer["email"] |
if target_role is not None:
self._all_customers_data[i]["role"] = target_role
break
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
|
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.av | self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
) |
self.total_db_customers = len(self._all_customers_data)
if self.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
|
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self | self.form_tags = self._format_tags_list_to_string(customer["tags"]) |
elf.current_page > self.total_pages and self.total_pages > 0:
self.current_page = self.total_pages
elif self.current_page < 1:
self.current_page = 1
self.loading = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
|
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
| self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
) |
ding = False
self.error_message = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
|
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = " | self.show_edit_dialog = True |
ge = ""
@rx.event
def next_page(self):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
|
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
| self.error_message = "" |
lf):
if self.current_page < self.total_pages:
self.current_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
|
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last | def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = "" |
rent_page += 1
@rx.event
def prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
|
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
| self.show_edit_dialog = True |
prev_page(self):
if self.current_page > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
|
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last | self.error_message = "" |
age > 1:
self.current_page -= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
|
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role | def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = "" |
-= 1
@rx.event
def select_customer_for_edit(self, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
|
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data | self.show_edit_dialog = not self.show_edit_dialog |
, customer: CustomerData):
self.form_customer_id = customer["customer_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
|
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_d | if not self.show_edit_dialog:
self._reset_form_fields() |
r_id"]
self.form_first_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
|
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role | self.error_message = "" |
t_name = customer["first_name"]
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
|
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
| def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else "" |
self.form_last_name = customer["last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
|
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
i | self.form_customer_id = 0 |
last_name"]
self.form_email = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
|
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name | self.form_first_name = "" |
l = customer["email"]
self.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
|
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
| self.form_last_name = "" |
f.form_status = (
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
|
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "Firs | self.form_email = "" |
customer["status"]
if customer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
|
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are req | self.form_status = "Active" |
ustomer["status"] in self.customer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
|
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
| self.form_tags = "" |
stomer_statuses
else "Active"
)
self.form_tags = self._format_tags_list_to_string(customer["tags"])
self.form_role = (
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
|
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
| self.form_role = self.available_roles[0] if self.available_roles else "" |
customer["role"]
if customer["role"] in self.available_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
|
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
| customer_id_str = form_data.get("customer_id", "0") |
e_roles
else (self.available_roles[0] if self.available_roles else "")
)
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
|
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from | customer_id = int(customer_id_str) |
how_edit_dialog = True
self.error_message = ""
@rx.event
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
|
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerDat | self.error_message = "Invalid Customer ID." |
def prepare_add_customer(self):
self._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
|
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
| is_add_operation = customer_id == 0 |
lf._reset_form_fields()
self.show_edit_dialog = True
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
|
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_ | first_name = form_data.get("first_name", "").strip() |
self.error_message = ""
@rx.event
def toggle_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
|
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
| last_name = form_data.get("last_name", "").strip() |
le_edit_dialog(self):
self.show_edit_dialog = not self.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
|
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status | email_from_form = form_data.get("email", "").strip() |
f.show_edit_dialog
if not self.show_edit_dialog:
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
|
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=r | status = form_data.get("status", self.form_status).strip() |
self._reset_form_fields()
self.error_message = ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
|
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_st | tags_str_from_form = form_data.get("tags", "") |
= ""
def _reset_form_fields(self):
self.form_customer_id = 0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
|
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime. | role_from_form = form_data.get("role", self.form_role).strip() |
0
self.form_first_name = ""
self.form_last_name = ""
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
|
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(),
selected=False,
)
self._all_customers_data.app | if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return |
self.form_email = ""
self.form_status = "Active"
self.form_tags = ""
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
|
return
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(),
selected=False,
)
self._all | self.error_message = "First name, last name, and email are required." |
self.form_role = self.available_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
|
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(),
selected=False,
)
self._all_customers_data.append(new_customer)
sel | self.error_message = "" |
_roles[0] if self.available_roles else ""
@rx.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
|
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(),
selected=False,
)
self._all_customers_data.append(new_customer)
self._next_customer_id += 1
toast_message = "User added successfully!"
else:
customer_found = False
for i, cust in enumerate(self._all_customers_data):
if cust["customer_id"] == customer_id:
self._all_customers_dat | for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return |
.event
async def handle_edit_customer(self, form_data: dict):
customer_id_str = form_data.get("customer_id", "0")
try:
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
|
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(),
selected=False,
)
self._all_customers_data.append(new_customer)
self._next_customer_id += 1
toast_message = "User added successfully!"
else:
customer_found = False
for i, cust in enumerate(self._all_customers_data):
if cust["customer_id"] == customer_id:
self._all_customers_dat | if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return |
customer_id = int(customer_id_str)
except ValueError:
async with self:
self.error_message = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
|
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(),
selected=False,
)
self._all_customers_data.append(new_customer)
self._next_customer_id += 1
toast_message = "User added successfully!"
else:
customer_found = False
for i, cust in enumerate(self._all_customers_data):
if cust["customer_id"] == customer_id:
| self.error_message = f"Email '{email_from_form}' already exists." |
e = "Invalid Customer ID."
return
is_add_operation = customer_id == 0
first_name = form_data.get("first_name", "").strip()
last_name = form_data.get("last_name", "").strip()
email_from_form = form_data.get("email", "").strip()
status = form_data.get("status", self.form_status).strip()
tags_str_from_form = form_data.get("tags", "")
role_from_form = form_data.get("role", self.form_role).strip()
if not first_name or not last_name or not email_from_form:
self.error_message = "First name, last name, and email are required."
return
self.error_message = ""
for cust in self._all_customers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
|
self._all_customers_data.append(new_customer)
self._next_customer_id += 1
toast_message = "User added successfully!"
else:
customer_found = False
for i, cust in enumerate(self._all_customers_data):
if cust["customer_id"] == customer_id:
self._all_customers_data[i]["first_name"] = first_name
self._all_customers_data[i]["last_name"] = last_name
self._all_customers_data[i]["email"] = email_from_form
self._all_customers_data[i]["status"] = status
self._all_customers_data[i]["role"] = role_from_form
self._all_customers_data[i]["tags"] = self._parse_tags_string(
tags_str_from_form
)
self._all_customers_data[i]["updated_at"] = (
datetime.datetime.now().isoformat()
)
| new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(),
selected=False,
) |
ers_data:
if cust["email"] == email_from_form and (
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(),
selected=False,
)
self._all_customers_data.append(new_customer)
self._next_customer_id += 1
|
else:
customer_found = False
for i, cust in enumerate(self._all_customers_data):
if cust["customer_id"] == customer_id:
self._all_customers_data[i]["first_name"] = first_name
self._all_customers_data[i]["last_name"] = last_name
self._all_customers_data[i]["email"] = email_from_form
self._all_customers_data[i]["status"] = status
self._all_customers_data[i]["role"] = role_from_form
self._all_customers_data[i]["tags"] = self._parse_tags_string(
tags_str_from_form
)
self._all_customers_data[i]["updated_at"] = (
datetime.datetime.now().isoformat()
)
customer_found = True
break
if not customer_found:
self.error_message = f"Customer with ID {customer_id} | toast_message = "User added successfully!" |
is_add_operation or cust["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(),
selected=False,
)
self._all_customers_data.append(new_customer)
self._next_customer_id += 1
toast_message = "User added successfully!"
else:
|
for i, cust in enumerate(self._all_customers_data):
if cust["customer_id"] == customer_id:
self._all_customers_data[i]["first_name"] = first_name
self._all_customers_data[i]["last_name"] = last_name
self._all_customers_data[i]["email"] = email_from_form
self._all_customers_data[i]["status"] = status
self._all_customers_data[i]["role"] = role_from_form
self._all_customers_data[i]["tags"] = self._parse_tags_string(
tags_str_from_form
)
self._all_customers_data[i]["updated_at"] = (
datetime.datetime.now().isoformat()
)
customer_found = True
break
if not customer_found:
self.error_message = f"Customer with ID {customer_id} not found."
return
t | customer_found = False |
["customer_id"] != customer_id
):
self.error_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(),
selected=False,
)
self._all_customers_data.append(new_customer)
self._next_customer_id += 1
toast_message = "User added successfully!"
else:
customer_found = False
|
if not customer_found:
self.error_message = f"Customer with ID {customer_id} not found."
return
toast_message = "User updated successfully!"
self._target_customer_email_for_tags = email_from_form
self._target_customer_tag_str = tags_str_from_form
self._target_customer_role = role_from_form
self.show_edit_dialog = False
self._reset_form_fields()
self.total_db_customers = len(self._all_customers_data)
yield CustomerState.fetch_customers
yield rx.toast(toast_message, duration=3000)
@rx.event
def set_form_status(self, status: str):
self.form_status = status
@rx.event
def set_form_tags(self, tags: str):
self.form_tags = tags
@rx.event
def set_form_role(self, role: str):
self.form_role = role
@rx.event
def toggle_select_all(self):
self.all_selected = not self.all_selected
for i in range(len(self | for i, cust in enumerate(self._all_customers_data):
if cust["customer_id"] == customer_id:
self._all_customers_data[i]["first_name"] = first_name
self._all_customers_data[i]["last_name"] = last_name
self._all_customers_data[i]["email"] = email_from_form
self._all_customers_data[i]["status"] = status
self._all_customers_data[i]["role"] = role_from_form
self._all_customers_data[i]["tags"] = self._parse_tags_string(
tags_str_from_form
)
self._all_customers_data[i]["updated_at"] = (
datetime.datetime.now().isoformat()
)
customer_found = True
break |
rror_message = f"Email '{email_from_form}' already exists."
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(),
selected=False,
)
self._all_customers_data.append(new_customer)
self._next_customer_id += 1
toast_message = "User added successfully!"
else:
customer_found = False
for i, cust in enumerate(self._all_customers_data):
|
if not customer_found:
self.error_message = f"Customer with ID {customer_id} not found."
return
toast_message = "User updated successfully!"
self._target_customer_email_for_tags = email_from_form
self._target_customer_tag_str = tags_str_from_form
self._target_customer_role = role_from_form
self.show_edit_dialog = False
self._reset_form_fields()
self.total_db_customers = len(self._all_customers_data)
yield CustomerState.fetch_customers
yield rx.toast(toast_message, duration=3000)
@rx.event
def set_form_status(self, status: str):
self.form_status = status
@rx.event
def set_form_tags(self, tags: str):
self.form_tags = tags
@rx.event
def set_form_role(self, role: str):
self.form_role = role
@rx.event
def toggle_select_all(self):
self.all_selected = not self.all_selected
for i in range(len(self | if cust["customer_id"] == customer_id:
self._all_customers_data[i]["first_name"] = first_name
self._all_customers_data[i]["last_name"] = last_name
self._all_customers_data[i]["email"] = email_from_form
self._all_customers_data[i]["status"] = status
self._all_customers_data[i]["role"] = role_from_form
self._all_customers_data[i]["tags"] = self._parse_tags_string(
tags_str_from_form
)
self._all_customers_data[i]["updated_at"] = (
datetime.datetime.now().isoformat()
)
customer_found = True
break |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.