dschandra commited on
Commit
cbf0cb6
·
verified ·
1 Parent(s): b316f59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -80,7 +80,7 @@ def place_order():
80
  cart.clear()
81
  return "Order placed successfully!"
82
 
83
- # Set up Gradio interface
84
  menu_items = fetch_menu_items()
85
  menu_html = generate_menu_html(menu_items)
86
 
@@ -93,9 +93,12 @@ with gr.Blocks() as demo:
93
 
94
  with gr.Row():
95
  cart_display = gr.HTML(value=view_cart())
 
 
 
96
  place_order_button = gr.Button("Place Order")
97
 
98
- menu_display.change(update_cart, inputs=["item_id", "quantity"], outputs=cart_display)
99
  place_order_button.click(place_order, inputs=[], outputs=cart_display)
100
 
101
  # Launch the app
 
80
  cart.clear()
81
  return "Order placed successfully!"
82
 
83
+ # Fetch menu and initialize UI components
84
  menu_items = fetch_menu_items()
85
  menu_html = generate_menu_html(menu_items)
86
 
 
93
 
94
  with gr.Row():
95
  cart_display = gr.HTML(value=view_cart())
96
+ item_id_input = gr.Textbox(placeholder="Item ID")
97
+ quantity_input = gr.Number(label="Quantity", value=1, interactive=True)
98
+ add_to_cart_button = gr.Button("Add to Cart")
99
  place_order_button = gr.Button("Place Order")
100
 
101
+ add_to_cart_button.click(update_cart, inputs=[item_id_input, quantity_input], outputs=cart_display)
102
  place_order_button.click(place_order, inputs=[], outputs=cart_display)
103
 
104
  # Launch the app