Skip to content

Commit

Permalink
small updates to change function names
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Gotsman committed May 31, 2024
1 parent abb8c56 commit 917720c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions customer_data_app/customer_data_app/customer_data_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def handle_update_submit(self, form_data: dict):
self.current_user.update(form_data)

def load_entries(self) -> list[Customer]:
"""Get all items from the database."""
"""Get all users from the database."""
with rx.session() as session:
query = select(Customer)

Expand Down Expand Up @@ -66,7 +66,7 @@ def filter_values(self, search_value):
def get_user(self, user: Customer):
self.current_user = user

def add_customer(self):
def add_customer_to_db(self):
"""Add a customer to the database."""
with rx.session() as session:
if session.exec(
Expand All @@ -78,7 +78,7 @@ def add_customer(self):
self.load_entries()
return rx.window_alert(f"User {self.current_user["name"]} has been added.")

def update_customer(self):
def update_customer_to_db(self):
"""Update a customer in the database."""
with rx.session() as session:
customer = session.exec(
Expand All @@ -99,9 +99,6 @@ def delete_customer(self, id: int):
session.commit()
self.load_entries()

def on_load(self):
self.load_entries()


def add_fields(field):
return rx.flex(
Expand Down Expand Up @@ -195,7 +192,7 @@ def add_customer():
rx.dialog.close(
rx.button(
"Submit Customer",
on_click=State.add_customer,
on_click=State.add_customer_to_db,
variant="solid",
),
),
Expand Down Expand Up @@ -263,7 +260,7 @@ def update_customer(user):
rx.dialog.close(
rx.button(
"Submit Customer",
on_click=State.update_customer,
on_click=State.update_customer_to_db,
variant="solid",
),
),
Expand Down Expand Up @@ -367,6 +364,7 @@ def content():
rx.table.body(rx.foreach(State.users, show_customer)),
size="3",
width="100%",
on_mount=State.load_entries,
),
),
)
Expand All @@ -393,7 +391,7 @@ def index() -> rx.Component:
)
app.add_page(
index,
on_load=State.on_load,
#on_load=State.on_load,
title="Customer Data App",
description="A simple app to manage customer data.",
)

0 comments on commit 917720c

Please sign in to comment.