Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -58,7 +58,7 @@ def app():
|
|
58 |
choices=[],
|
59 |
interactive=True,
|
60 |
)
|
61 |
-
|
62 |
|
63 |
# Dish details view
|
64 |
detailed_view = gr.Column(visible=False)
|
@@ -81,11 +81,11 @@ def app():
|
|
81 |
)
|
82 |
add_button = gr.Button("Add to Cart")
|
83 |
back_button = gr.Button("Back to Menu")
|
84 |
-
cart_view = gr.HTML(value="Your cart is empty.")
|
85 |
|
86 |
-
#
|
87 |
def update_menu(preference):
|
88 |
-
|
|
|
89 |
|
90 |
# Show dish details
|
91 |
def show_dish_details(dish_name):
|
@@ -107,14 +107,11 @@ def app():
|
|
107 |
)
|
108 |
return updated_cart, cart_html
|
109 |
|
110 |
-
#
|
111 |
-
|
112 |
-
|
113 |
-
inputs=["All"],
|
114 |
-
outputs=[menu_view()],
|
115 |
-
)
|
116 |
|
117 |
-
#
|
118 |
menu_dropdown.change(
|
119 |
show_dish_details,
|
120 |
inputs=[menu_dropdown],
|
@@ -127,8 +124,6 @@ def app():
|
|
127 |
dish_price,
|
128 |
],
|
129 |
)
|
130 |
-
|
131 |
-
# Handle adding items to the cart
|
132 |
add_button.click(
|
133 |
handle_add_to_cart,
|
134 |
inputs=[
|
@@ -141,10 +136,8 @@ def app():
|
|
141 |
],
|
142 |
outputs=[cart_state, cart_view],
|
143 |
)
|
144 |
-
|
145 |
-
# Back button to return to menu
|
146 |
back_button.click(
|
147 |
-
|
148 |
outputs=[menu_dropdown, detailed_view],
|
149 |
)
|
150 |
|
|
|
58 |
choices=[],
|
59 |
interactive=True,
|
60 |
)
|
61 |
+
cart_view = gr.HTML(value="Your cart is empty.", interactive=False)
|
62 |
|
63 |
# Dish details view
|
64 |
detailed_view = gr.Column(visible=False)
|
|
|
81 |
)
|
82 |
add_button = gr.Button("Add to Cart")
|
83 |
back_button = gr.Button("Back to Menu")
|
|
|
84 |
|
85 |
+
# Update menu with dish options
|
86 |
def update_menu(preference):
|
87 |
+
menu_choices = render_menu(preference)
|
88 |
+
return gr.update(choices=[choice["label"] for choice in menu_choices])
|
89 |
|
90 |
# Show dish details
|
91 |
def show_dish_details(dish_name):
|
|
|
107 |
)
|
108 |
return updated_cart, cart_html
|
109 |
|
110 |
+
# Switch back to menu
|
111 |
+
def back_to_menu():
|
112 |
+
return gr.update(visible=True), gr.update(visible=False)
|
|
|
|
|
|
|
113 |
|
114 |
+
# Interactions
|
115 |
menu_dropdown.change(
|
116 |
show_dish_details,
|
117 |
inputs=[menu_dropdown],
|
|
|
124 |
dish_price,
|
125 |
],
|
126 |
)
|
|
|
|
|
127 |
add_button.click(
|
128 |
handle_add_to_cart,
|
129 |
inputs=[
|
|
|
136 |
],
|
137 |
outputs=[cart_state, cart_view],
|
138 |
)
|
|
|
|
|
139 |
back_button.click(
|
140 |
+
back_to_menu,
|
141 |
outputs=[menu_dropdown, detailed_view],
|
142 |
)
|
143 |
|