nagasurendra commited on
Commit
5506cf6
·
verified ·
1 Parent(s): e749bc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -97,11 +97,15 @@ modal_and_cart_js = """
97
  cart.forEach((item, index) => {
98
  totalBill += item.itemTotal;
99
  const extras = item.extras.join(', ');
100
- cartHTML += `<li>${item.name} (x${item.quantity}, Spice: ${item.spiceLevel}, Extras: ${extras}, Instructions: ${item.instructions}) - $${item.itemTotal.toFixed(2)}</li>`;
101
  });
102
  cartHTML += `</ul><p><strong>Total Bill: $${totalBill.toFixed(2)}</strong></p>`;
103
  document.getElementById('floating-cart').innerHTML = cartHTML;
104
  }
 
 
 
 
105
  function finalizeOrder() {
106
  if (cart.length === 0) {
107
  alert("Your cart is empty. Please add items before finalizing.");
@@ -117,7 +121,7 @@ modal_and_cart_js = """
117
  });
118
  finalOrderHTML += `</ul><p><strong>Total Bill: $${totalBill.toFixed(2)}</strong></p>`;
119
  finalOrderHTML += `<p style='color: green; font-size: 18px;'>Your final order has been placed. Thank you!</p>`;
120
- document.getElementById('final-order').innerHTML = finalOrderHTML;
121
  }
122
  </script>
123
  """
@@ -141,7 +145,7 @@ def app():
141
  cart_output = gr.HTML(value="Your cart is empty.", elem_id="floating-cart")
142
 
143
  # Final order display
144
- final_order_output = gr.HTML(value="", elem_id="final-order")
145
 
146
  # Modal window
147
  modal_window = gr.HTML("""
@@ -188,6 +192,9 @@ def app():
188
  # Finalize Order Button
189
  finalize_button = gr.Button("Finalize Order")
190
 
 
 
 
191
  # Update menu dynamically based on preference
192
  selected_preference.change(filter_menu, inputs=[selected_preference], outputs=[menu_output])
193
 
 
97
  cart.forEach((item, index) => {
98
  totalBill += item.itemTotal;
99
  const extras = item.extras.join(', ');
100
+ cartHTML += `<li><input type='checkbox' id='cart-item-${index}' value='${index}' checked onclick='removeItem(${index})'> ${item.name} (x${item.quantity}, Spice: ${item.spiceLevel}, Extras: ${extras}, Instructions: ${item.instructions}) - $${item.itemTotal.toFixed(2)}</li>`;
101
  });
102
  cartHTML += `</ul><p><strong>Total Bill: $${totalBill.toFixed(2)}</strong></p>`;
103
  document.getElementById('floating-cart').innerHTML = cartHTML;
104
  }
105
+ function removeItem(index) {
106
+ cart.splice(index, 1);
107
+ updateCartDisplay();
108
+ }
109
  function finalizeOrder() {
110
  if (cart.length === 0) {
111
  alert("Your cart is empty. Please add items before finalizing.");
 
121
  });
122
  finalOrderHTML += `</ul><p><strong>Total Bill: $${totalBill.toFixed(2)}</strong></p>`;
123
  finalOrderHTML += `<p style='color: green; font-size: 18px;'>Your final order has been placed. Thank you!</p>`;
124
+ document.getElementById('final-page').innerHTML = finalOrderHTML;
125
  }
126
  </script>
127
  """
 
145
  cart_output = gr.HTML(value="Your cart is empty.", elem_id="floating-cart")
146
 
147
  # Final order display
148
+ final_order_output = gr.HTML(value="", elem_id="final-page")
149
 
150
  # Modal window
151
  modal_window = gr.HTML("""
 
192
  # Finalize Order Button
193
  finalize_button = gr.Button("Finalize Order")
194
 
195
+ # Finalize order button click event
196
+ finalize_button.click(lambda: "Order finalized!", outputs=[final_order_output])
197
+
198
  # Update menu dynamically based on preference
199
  selected_preference.change(filter_menu, inputs=[selected_preference], outputs=[menu_output])
200