Spaces:
Running
Running
DSatishchandra
commited on
Commit
•
a5cfc16
1
Parent(s):
957896c
Update app.py
Browse files
app.py
CHANGED
@@ -29,15 +29,25 @@ def login(phone):
|
|
29 |
return "Customer not found. Please register."
|
30 |
|
31 |
def display_menu():
|
32 |
-
|
|
|
|
|
|
|
|
|
33 |
|
34 |
def add_to_cart(item_id, quantity):
|
|
|
|
|
|
|
35 |
cart = session_data.get('cart', [])
|
36 |
cart.append({"item_id": item_id, "quantity": quantity})
|
37 |
session_data['cart'] = cart
|
38 |
return f"Item added to cart. Cart has {len(cart)} item(s)."
|
39 |
|
40 |
def view_cart():
|
|
|
|
|
|
|
41 |
cart = session_data.get('cart', [])
|
42 |
cart_items = []
|
43 |
total_price = 0
|
@@ -49,6 +59,9 @@ def view_cart():
|
|
49 |
return "\n".join(cart_items) + f"\nTotal Price: ${total_price}"
|
50 |
|
51 |
def proceed_to_order(table_number):
|
|
|
|
|
|
|
52 |
order_id = str(uuid.uuid4()) # Generate unique order ID
|
53 |
cart = session_data.get('cart', [])
|
54 |
order_details = {
|
@@ -70,4 +83,3 @@ order_interface = gr.Interface(fn=proceed_to_order, inputs="text", outputs="text
|
|
70 |
# Launch Gradio app
|
71 |
demo = gr.TabbedInterface([login_interface, menu_interface, cart_interface, order_interface], ["Login", "Menu", "Cart", "Order"])
|
72 |
demo.launch()
|
73 |
-
|
|
|
29 |
return "Customer not found. Please register."
|
30 |
|
31 |
def display_menu():
|
32 |
+
if 'customer_id' not in session_data:
|
33 |
+
return "Please log in first to view the menu."
|
34 |
+
|
35 |
+
menu = "\n".join([f"{item['id']}. {item['name']} - ${item['price']}" for item in menu_items])
|
36 |
+
return f"Welcome, {session_data['customer_name']}! Here is the menu:\n\n{menu}"
|
37 |
|
38 |
def add_to_cart(item_id, quantity):
|
39 |
+
if 'customer_id' not in session_data:
|
40 |
+
return "Please log in first to add items to your cart."
|
41 |
+
|
42 |
cart = session_data.get('cart', [])
|
43 |
cart.append({"item_id": item_id, "quantity": quantity})
|
44 |
session_data['cart'] = cart
|
45 |
return f"Item added to cart. Cart has {len(cart)} item(s)."
|
46 |
|
47 |
def view_cart():
|
48 |
+
if 'customer_id' not in session_data:
|
49 |
+
return "Please log in first to view your cart."
|
50 |
+
|
51 |
cart = session_data.get('cart', [])
|
52 |
cart_items = []
|
53 |
total_price = 0
|
|
|
59 |
return "\n".join(cart_items) + f"\nTotal Price: ${total_price}"
|
60 |
|
61 |
def proceed_to_order(table_number):
|
62 |
+
if 'customer_id' not in session_data:
|
63 |
+
return "Please log in first to proceed with your order."
|
64 |
+
|
65 |
order_id = str(uuid.uuid4()) # Generate unique order ID
|
66 |
cart = session_data.get('cart', [])
|
67 |
order_details = {
|
|
|
83 |
# Launch Gradio app
|
84 |
demo = gr.TabbedInterface([login_interface, menu_interface, cart_interface, order_interface], ["Login", "Menu", "Cart", "Order"])
|
85 |
demo.launch()
|
|