nagasurendra commited on
Commit
aa367a6
·
verified ·
1 Parent(s): f2ee33b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -6
app.py CHANGED
@@ -143,6 +143,22 @@ def create_modal_window():
143
  <textarea id="special-instructions" placeholder="Add your special instructions here..." style="width: 100%; height: 60px;"></textarea>
144
  <button style="background-color: #28a745; color: white; border: none; padding: 10px 20px; font-size: 14px; border-radius: 5px; cursor: pointer;" onclick="addToCart()">Add to Cart</button>
145
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  """
147
  return modal_html
148
 
@@ -248,13 +264,15 @@ def modal_js():
248
  ${item.name} (x${item.quantity}) - $${item.totalCost.toFixed(2)}
249
  Extras: ${item.extras.map(extra => extra.name).join(', ') || 'None'}
250
  Instructions: ${item.instructions || 'None'}
251
- `).join('\n');
252
 
253
- // Show an alert with the cart summary
254
- alert(`Proceeding to checkout...\n\nCart Summary:\n\n${cartSummary}\n\nTotal Cost: $${totalCartCost.toFixed(2)}`);
255
- }
256
 
257
-
 
 
258
  // Reset all selected add-ons when opening a new item modal
259
  function resetAddOns() {
260
  const checkboxes = document.querySelectorAll('input[name="biryani-extra"]');
@@ -292,7 +310,7 @@ with gr.Blocks() as app:
292
  preference = gr.Radio(choices=["All", "Veg", "Non-Veg"], label="Filter Preference", value="All")
293
  menu_output = gr.HTML()
294
  gr.HTML("<div id='cart-button' style='position: fixed; top: 20px; right: 20px; background: #28a745; color: white; padding: 10px 20px; border-radius: 30px; cursor: pointer; z-index: 1000;' onclick='openCartModal()'>View Cart</div>")
295
- gr.HTML("<div id='cart-modal' style='display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: white; z-index: 1000; overflow-y: auto;'><div style='padding: 20px;'><div style='text-align: right;'><button onclick='closeCartModal()' style='background: none; border: none; font-size: 24px; cursor: pointer;'>&times;</button></div><h1>Your Cart</h1><div id='cart-items'></div><p id='cart-total-cost' style='font-size: 1.2em; font-weight: bold;'>Total Cart Cost: $0.00</p><button style='background: #ff5722; color: white; padding: 10px 20px; border-radius: 5px; border: none; cursor: pointer;' onclick='proceedToCheckout()'>Proceed to Checkout</button></div></div>")
296
  gr.HTML(create_modal_window())
297
  gr.HTML(modal_js())
298
 
 
143
  <textarea id="special-instructions" placeholder="Add your special instructions here..." style="width: 100%; height: 60px;"></textarea>
144
  <button style="background-color: #28a745; color: white; border: none; padding: 10px 20px; font-size: 14px; border-radius: 5px; cursor: pointer;" onclick="addToCart()">Add to Cart</button>
145
  </div>
146
+ <div id="cart-modal" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: white; z-index: 1000; overflow-y: auto;">
147
+ <div style="padding: 20px;">
148
+ <div style="text-align: right;">
149
+ <button onclick="closeCartModal()" style="background: none; border: none; font-size: 24px; cursor: pointer;">&times;</button>
150
+ </div>
151
+ <h1>Your Cart</h1>
152
+ <div id="cart-items"></div>
153
+ <p id="cart-total-cost" style="font-size: 1.2em; font-weight: bold;">Total Cart Cost: $0.00</p>
154
+ <div id="order-summary" style="margin-top: 20px;">
155
+ <h2>Final Order Summary:</h2>
156
+ <div id="final-order-summary"></div>
157
+ <p><strong>Total Bill: $<span id="total-bill"></span></strong></p>
158
+ </div>
159
+ <button style="background: #ff5722; color: white; padding: 10px 20px; border-radius: 5px; border: none; cursor: pointer;" onclick="proceedToCheckout()">Proceed to Checkout</button>
160
+ </div>
161
+ </div>
162
  """
163
  return modal_html
164
 
 
264
  ${item.name} (x${item.quantity}) - $${item.totalCost.toFixed(2)}
265
  Extras: ${item.extras.map(extra => extra.name).join(', ') || 'None'}
266
  Instructions: ${item.instructions || 'None'}
267
+ `).join('<br>');
268
 
269
+ // Insert the summary into the modal
270
+ document.getElementById('final-order-summary').innerHTML = cartSummary;
271
+ document.getElementById('total-bill').innerText = totalCartCost.toFixed(2);
272
 
273
+ // Show the cart modal with the summary
274
+ openCartModal();
275
+ }
276
  // Reset all selected add-ons when opening a new item modal
277
  function resetAddOns() {
278
  const checkboxes = document.querySelectorAll('input[name="biryani-extra"]');
 
310
  preference = gr.Radio(choices=["All", "Veg", "Non-Veg"], label="Filter Preference", value="All")
311
  menu_output = gr.HTML()
312
  gr.HTML("<div id='cart-button' style='position: fixed; top: 20px; right: 20px; background: #28a745; color: white; padding: 10px 20px; border-radius: 30px; cursor: pointer; z-index: 1000;' onclick='openCartModal()'>View Cart</div>")
313
+ gr.HTML("<div id='cart-modal' style='display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: white; z-index: 1000; overflow-y: auto;'><div style='padding: 20px;'><div style='text-align: right;'><button onclick='closeCartModal()' style='background: none; border: none; font-size: 24px; cursor: pointer;'>&times;</button></div><h1>Your Cart</h1><div id='cart-items'></div><p id='cart-total-cost' style='font-size: 1.2em; font-weight: bold;'>Total Cart Cost: $0.00</p><div id='order-summary'><h2>Final Order Summary:</h2><div id='final-order-summary'></div><p><strong>Total Bill: $<span id='total-bill'></span></strong></p></div><button style='background: #ff5722; color: white; padding: 10px 20px; border-radius: 5px; border: none; cursor: pointer;' onclick='proceedToCheckout()'>Proceed to Checkout</button></div></div>")
314
  gr.HTML(create_modal_window())
315
  gr.HTML(modal_js())
316