Rammohan0504 commited on
Commit
291a1b4
·
verified ·
1 Parent(s): 1c87f58

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -66,7 +66,7 @@ def add_to_cart(dish_name, spice_level, selected_extras, quantity, custom_descri
66
  "quantity": quantity,
67
  "custom_description": custom_description
68
  })
69
- return update_cart(), "Your item has been added to the cart!"
70
 
71
  # Update cart display
72
  def update_cart():
@@ -96,18 +96,25 @@ with gr.Blocks() as demo:
96
  with gr.Tab("Cart"):
97
  cart_display = gr.HTML(value="<p>Your cart is empty.</p>")
98
 
99
- notification = gr.Textbox(visible=False)
100
-
101
  # Button click events
102
  btn_all.click(lambda: gr.update(value=display_dishes("ALL")), outputs=dish_display)
103
  btn_vegan.click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
104
  btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
105
 
 
 
 
 
 
 
 
 
 
106
  add_to_cart_button = gr.Button("Add to Cart", visible=False)
107
  add_to_cart_button.click(
108
  add_to_cart,
109
- inputs=[], # Inputs are handled via JavaScript popup
110
- outputs=[cart_display, notification]
111
  )
112
 
113
  gr.HTML(f"""
@@ -181,5 +188,4 @@ with gr.Blocks() as demo:
181
  </script>
182
  """)
183
 
184
-
185
  demo.launch()
 
66
  "quantity": quantity,
67
  "custom_description": custom_description
68
  })
69
+ return update_cart()
70
 
71
  # Update cart display
72
  def update_cart():
 
96
  with gr.Tab("Cart"):
97
  cart_display = gr.HTML(value="<p>Your cart is empty.</p>")
98
 
 
 
99
  # Button click events
100
  btn_all.click(lambda: gr.update(value=display_dishes("ALL")), outputs=dish_display)
101
  btn_vegan.click(lambda: gr.update(value=display_dishes("VEGAN")), outputs=dish_display)
102
  btn_halal.click(lambda: gr.update(value=display_dishes("HALAL")), outputs=dish_display)
103
 
104
+ # Add to cart button with input fields
105
+ add_to_cart_inputs = [
106
+ gr.Textbox(label="Dish Name", visible=False),
107
+ gr.Textbox(label="Spice Level", visible=False),
108
+ gr.Textbox(label="Selected Extras", visible=False),
109
+ gr.Number(label="Quantity", value=1, visible=False),
110
+ gr.Textbox(label="Custom Description", visible=False)
111
+ ]
112
+
113
  add_to_cart_button = gr.Button("Add to Cart", visible=False)
114
  add_to_cart_button.click(
115
  add_to_cart,
116
+ inputs=add_to_cart_inputs,
117
+ outputs=[cart_display]
118
  )
119
 
120
  gr.HTML(f"""
 
188
  </script>
189
  """)
190
 
 
191
  demo.launch()