Spaces:
Build error
Build error
Update app.py
Browse files32 unmodified lines3334353637383928 unmodified lines68697071727374757677787980818283848537 unmodified lines1231241251261271287 unmodified lines13613713813914014132 unmodified lines</div><div style=\"flex-shrink: 0; text-align: center;\"><img src=\"{item['Image URL']}\" alt=\"{item['Dish Name']}\" style=\"width: 100px; height: 100px; border-radius: 8px; object-fit: cover; margin-bottom: 10px;\"><button style=\"background-color: #28a745; color: white; border: none; padding: 8px 15px; font-size: 14px; border-radius: 5px; cursor: pointer;\" onclick=\"addItemToCart('{item['Dish Name']}', '{item['Price ($)']}', '{item['Description']}')\">Add</button></div></div>"""28 unmodified lines"Extra Onion & Lemon": 2,"Extra Fried Onion 4oz": 2};function addItemToCart(name, price, description) {const item = {name: name,price: parseFloat(price),spiceLevel: "Not Selected",quantity: 1,instructions: "",extras: [],itemTotal: parseFloat(price)};cart.push(item);updateCartDisplay();}function updateCartDisplay() {let totalBill = 0;37 unmodified lines# Final order displayfinal_order_output = gr.HTML(value="", elem_id="final-page")# Finalize Order Buttonfinalize_button = gr.Button("Finalize Order")7 unmodified linesgr.Row([selected_preference])gr.Row(menu_output)gr.Row(cart_output)gr.Row(finalize_button)gr.Row(final_order_output)gr.HTML(modal_and_cart_js)32 unmodified lines3334353637383928 unmodified lines686970717273747576777879808182838485868788899091929394959697989910010110210337 unmodified lines1411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871887 unmodified lines19619719819920020120232 unmodified lines</div><div style=\"flex-shrink: 0; text-align: center;\"><img src=\"{item['Image URL']}\" alt=\"{item['Dish Name']}\" style=\"width: 100px; height: 100px; border-radius: 8px; object-fit: cover; margin-bottom: 10px;\"><button style=\"background-color: #28a745; color: white; border: none; padding: 8px 15px; font-size: 14px; border-radius: 5px; cursor: pointer;\" onclick=\"openModal('{item['Dish Name']}', '{item['Price ($)']}', '{item['Description']}')\">Add</button></div></div>"""28 unmodified lines"Extra Onion & Lemon": 2,"Extra Fried Onion 4oz": 2};function openModal(name, price, description) {document.getElementById('modal').style.display = 'block';document.getElementById('modal-name').innerText = name;document.getElementById('modal-price').innerText = price;document.getElementById('modal-description').innerText = description;document.getElementById('modal-image').src = "";const spiceLevelInputs = document.querySelectorAll('input[name="spice-level"]');spiceLevelInputs.forEach(input => input.checked = false);const extrasInputs = document.querySelectorAll('input[name="biryani-extra"]');extrasInputs.forEach(input => input.checked = false);document.getElementById('quantity').value = 1;document.getElementById('special-instructions').value = '';}function closeModal() {document.getElementById('modal').style.display = 'none';}function addToCart() {const name = document.getElementById('modal-name').innerText;const price = parseFloat(document.getElementById('modal-price').innerText.replace('$', ''));const spiceLevel = document.querySelector('input[name="spice-level"]:checked')?.value || "Not Selected";const quantity = parseInt(document.getElementById('quantity').value) || 1;const instructions = document.getElementById('special-instructions').value;const extras = Array.from(document.querySelectorAll('input[name="biryani-extra"]:checked')).map(extra => extra.value);const extrasCost = extras.reduce((sum, extra) => sum + (extrasPrices[extra] || 0), 0);const itemTotal = (price + extrasCost) * quantity;const cartItem = { name, price, spiceLevel, quantity, instructions, extras, itemTotal };cart.push(cartItem);updateCartDisplay();closeModal();}function updateCartDisplay() {let totalBill = 0;37 unmodified lines# Final order displayfinal_order_output = gr.HTML(value="", elem_id="final-page")# Modal window for item customizationmodal_window = gr.HTML("""<div id="modal" style="display: none; position: fixed; top: 40%; left: 50%; transform: translate(-50%, -40%); width: 50%; background: white; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); padding: 20px; z-index: 1000;"><div style="text-align: right;"><button onclick="closeModal()" style="background: none; border: none; font-size: 18px; cursor: pointer;">×</button></div><img id="modal-image" style="width: 100%; height: auto; border-radius: 8px; margin-bottom: 20px;" /><h2 id="modal-name"></h2><p id="modal-description"></p><p id="modal-price"></p><!-- Spice Levels --><label for="spice-level">Choose a Spice Level (Required):</label><div id="spice-level-options" style="display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0;"><label><input type="radio" name="spice-level" value="American Mild" /> American Mild</label><label><input type="radio" name="spice-level" value="American Medium" /> American Medium</label><label><input type="radio" name="spice-level" value="American Spicy" /> American Spicy</label><label><input type="radio" name="spice-level" value="Indian Mild" /> Indian Mild</label><label><input type="radio" name="spice-level" value="Indian Medium" /> Indian Medium</label><label><input type="radio" name="spice-level" value="Indian Very Spicy" /> Indian Very Spicy</label></div><!-- Biryani Extras --><label for="biryani-extras">Biryani Extras (Optional - Choose as many as you like):</label><div id="biryani-extras-options" style="display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0;"><label><input type="checkbox" name="biryani-extra" value="Extra Raitha 4oz" /> Extra Raitha 4oz + $1.00</label><label><input type="checkbox" name="biryani-extra" value="Extra Raitha 8oz" /> Extra Raitha 8oz + $2.00</label><label><input type="checkbox" name="biryani-extra" value="Extra Salan 4oz" /> Extra Salan 4oz + $1.00</label><label><input type="checkbox" name="biryani-extra" value="Extra Salan 8oz" /> Extra Salan 8oz + $2.00</label><label><input type="checkbox" name="biryani-extra" value="Extra Onion" /> Extra Onion + $1.00</label><label><input type="checkbox" name="biryani-extra" value="Extra Onion & Lemon" /> Extra Onion & Lemon + $2.00</label><label><input type="checkbox" name="biryani-extra" value="Extra Fried Onion 4oz" /> Extra Fried Onion 4oz + $2.00</label></div><!-- Quantity and Special Instructions --><label for="quantity">Quantity:</label><input type="number" id="quantity" value="1" min="1" style="width: 50px;" /><br><br><textarea id="special-instructions" placeholder="Add special instructions here..." style="width: 100%; height: 60px;"></textarea><br><br><!-- Add to Cart Button --><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></div>""")# Finalize Order Buttonfinalize_button = gr.Button("Finalize Order")7 unmodified linesgr.Row([selected_preference])gr.Row(menu_output)gr.Row(cart_output)gr.Row(modal_window)gr.Row(finalize_button)gr.Row(final_order_output)gr.HTML(modal_and_cart_js)
app.py+73-12