Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -79,6 +79,10 @@ def update_cart():
|
|
| 79 |
cart_html += f"</ul><p><strong>Total Bill: ${total_bill:.2f}</strong></p>"
|
| 80 |
return cart_html
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
# Gradio app definition
|
| 83 |
def app():
|
| 84 |
with gr.Blocks() as demo:
|
|
@@ -94,15 +98,13 @@ def app():
|
|
| 94 |
# Output area for menu items
|
| 95 |
menu_output = gr.HTML(value=filter_menu("All"))
|
| 96 |
|
| 97 |
-
# Redirect to cart page
|
| 98 |
-
def redirect_to_cart():
|
| 99 |
-
return update_cart()
|
| 100 |
-
|
| 101 |
-
cart_page = gr.HTML(value="Your cart is empty.")
|
| 102 |
-
|
| 103 |
# Floating cart display
|
| 104 |
cart_output = gr.HTML(value="Your cart is empty.", elem_id="floating-cart")
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
# JavaScript for modal and cart behavior
|
| 107 |
modal_and_cart_js = """
|
| 108 |
<script>
|
|
@@ -216,12 +218,13 @@ def app():
|
|
| 216 |
|
| 217 |
# Interactivity
|
| 218 |
selected_preference.change(filter_menu, inputs=[selected_preference], outputs=[menu_output])
|
| 219 |
-
gr.Button("View Cart").click(fn=
|
| 220 |
|
| 221 |
# Layout
|
| 222 |
gr.Row([selected_preference])
|
| 223 |
gr.Row(menu_output)
|
| 224 |
gr.Row(cart_output)
|
|
|
|
| 225 |
gr.Row(modal_window)
|
| 226 |
gr.HTML(modal_and_cart_js)
|
| 227 |
|
|
|
|
| 79 |
cart_html += f"</ul><p><strong>Total Bill: ${total_bill:.2f}</strong></p>"
|
| 80 |
return cart_html
|
| 81 |
|
| 82 |
+
# Redirect to cart details page
|
| 83 |
+
def redirect_to_cart():
|
| 84 |
+
return update_cart()
|
| 85 |
+
|
| 86 |
# Gradio app definition
|
| 87 |
def app():
|
| 88 |
with gr.Blocks() as demo:
|
|
|
|
| 98 |
# Output area for menu items
|
| 99 |
menu_output = gr.HTML(value=filter_menu("All"))
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
# Floating cart display
|
| 102 |
cart_output = gr.HTML(value="Your cart is empty.", elem_id="floating-cart")
|
| 103 |
|
| 104 |
+
# View Cart Page
|
| 105 |
+
cart_page = gr.HTML(value="Your cart is empty.")
|
| 106 |
+
gr.Button("View Cart").click(fn=redirect_to_cart, outputs=cart_page)
|
| 107 |
+
|
| 108 |
# JavaScript for modal and cart behavior
|
| 109 |
modal_and_cart_js = """
|
| 110 |
<script>
|
|
|
|
| 218 |
|
| 219 |
# Interactivity
|
| 220 |
selected_preference.change(filter_menu, inputs=[selected_preference], outputs=[menu_output])
|
| 221 |
+
gr.Button("View Cart").click(fn=redirect_to_cart, outputs=cart_page)
|
| 222 |
|
| 223 |
# Layout
|
| 224 |
gr.Row([selected_preference])
|
| 225 |
gr.Row(menu_output)
|
| 226 |
gr.Row(cart_output)
|
| 227 |
+
gr.Row(cart_page)
|
| 228 |
gr.Row(modal_window)
|
| 229 |
gr.HTML(modal_and_cart_js)
|
| 230 |
|