Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -313,71 +313,79 @@ def app():
|
|
| 313 |
|
| 314 |
# Menu Tab
|
| 315 |
with gr.Tab("Menu Page"):
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 332 |
|
| 333 |
-
# Output area for menu items
|
| 334 |
-
menu_output = gr.HTML(value=filter_menu("All"))
|
| 335 |
-
|
| 336 |
-
# Floating cart display
|
| 337 |
-
cart_output = gr.HTML(value="Your cart is empty.", elem_id="floating-cart")
|
| 338 |
-
|
| 339 |
-
# Final order display
|
| 340 |
-
final_order_output = gr.HTML(value="", elem_id="final-order")
|
| 341 |
-
|
| 342 |
-
# Modal window
|
| 343 |
-
modal_window = gr.HTML("""
|
| 344 |
-
<div id="modal" style="display: none; position: fixed; background: white; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); padding: 20px; z-index: 1000;">
|
| 345 |
-
<div style="text-align: right;">
|
| 346 |
-
<button onclick="closeModal()" style="background: none; border: none; font-size: 18px; cursor: pointer;">×</button>
|
| 347 |
-
</div>
|
| 348 |
-
<img id="modal-image" style="width: 100%; height: auto; border-radius: 8px; margin-bottom: 20px;" />
|
| 349 |
-
<h2 id="modal-name"></h2>
|
| 350 |
-
<p id="modal-description"></p>
|
| 351 |
-
<p id="modal-price"></p>
|
| 352 |
-
<label for="biryani-extras">Biryani Extras:</label>
|
| 353 |
-
<div id="biryani-extras-options" style="display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0;">
|
| 354 |
-
<label><input type="checkbox" name="biryani-extra" value="Thums up" /> Thums up + $2.00</label>
|
| 355 |
-
<label><input type="checkbox" name="biryani-extra" value="Sprite" /> Sprite + $2.00</label>
|
| 356 |
-
<label><input type="checkbox" name="biryani-extra" value="Extra Raitha" /> Extra Raitha + $1.00</label>
|
| 357 |
-
<label><input type="checkbox" name="biryani-extra" value="Extra Salan" /> Extra Salan + $2.00</label>
|
| 358 |
-
<label><input type="checkbox" name="biryani-extra" value="Extra Onion & Lemon" /> Extra Onion & Lemon + $2.00</label>
|
| 359 |
-
<label><input type="checkbox" name="biryani-extra" value="Chilli Chicken" /> Chilli Chicken + $14.00</label>
|
| 360 |
-
<label><input type="checkbox" name="biryani-extra" value="Veg Manchurian" /> Veg Manchurian + $12.00</label>
|
| 361 |
-
</div>
|
| 362 |
-
<label for="quantity">Quantity:</label>
|
| 363 |
-
<input type="number" id="quantity" value="1" min="1" style="width: 50px;" />
|
| 364 |
-
<br><br>
|
| 365 |
-
<textarea id="special-instructions" placeholder="Add special instructions here..." style="width: 100%; height: 60px;"></textarea>
|
| 366 |
-
<br><br>
|
| 367 |
-
<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>
|
| 368 |
-
</div>
|
| 369 |
-
""")
|
| 370 |
-
|
| 371 |
-
# Update menu dynamically based on preference
|
| 372 |
-
selected_preference.change(filter_menu, inputs=[selected_preference], outputs=[menu_output])
|
| 373 |
-
|
| 374 |
-
# Layout
|
| 375 |
-
gr.Row([selected_preference])
|
| 376 |
-
gr.Row(menu_output)
|
| 377 |
-
gr.Row(cart_output)
|
| 378 |
-
gr.Row(modal_window)
|
| 379 |
-
gr.Row(final_order_output)
|
| 380 |
-
gr.HTML(modal_and_cart_js)
|
| 381 |
|
| 382 |
return demo
|
| 383 |
|
|
|
|
| 313 |
|
| 314 |
# Menu Tab
|
| 315 |
with gr.Tab("Menu Page"):
|
| 316 |
+
gr.Markdown("### Menu Page (Only for Logged-In Users)")
|
| 317 |
+
menu_username = gr.Textbox(label="Enter Username to Verify Login", placeholder="Enter your username")
|
| 318 |
+
menu_check = gr.Button("Check Login Status")
|
| 319 |
+
login_status = gr.Label()
|
| 320 |
+
menu_content = gr.HTML(value="")
|
| 321 |
+
|
| 322 |
+
def check_login_status(username):
|
| 323 |
+
if is_logged_in(username):
|
| 324 |
+
return "Welcome to the menu page!", filter_menu("All")
|
| 325 |
+
return "You are not logged in!", ""
|
| 326 |
+
|
| 327 |
+
menu_check.click(
|
| 328 |
+
check_login_status,
|
| 329 |
+
inputs=[menu_username],
|
| 330 |
+
outputs=[login_status, menu_content],
|
| 331 |
+
)
|
| 332 |
+
|
| 333 |
+
# Define Radio button for selecting preference
|
| 334 |
+
selected_preference = gr.Radio(
|
| 335 |
+
choices=["All", "Vegetarian", "Halal/Non-Veg", "Guilt-Free"],
|
| 336 |
+
value="All",
|
| 337 |
+
label="Choose a Preference",
|
| 338 |
+
)
|
| 339 |
+
|
| 340 |
+
# Output area for menu items
|
| 341 |
+
menu_output = gr.HTML(value=filter_menu("All"))
|
| 342 |
+
|
| 343 |
+
# Dynamically update the menu based on preference
|
| 344 |
+
selected_preference.change(filter_menu, inputs=[selected_preference], outputs=[menu_output])
|
| 345 |
+
|
| 346 |
+
# Floating cart display
|
| 347 |
+
cart_output = gr.HTML(value="Your cart is empty.", elem_id="floating-cart")
|
| 348 |
+
|
| 349 |
+
# Final order display
|
| 350 |
+
final_order_output = gr.HTML(value="", elem_id="final-order")
|
| 351 |
+
|
| 352 |
+
# Modal window
|
| 353 |
+
modal_window = gr.HTML("""
|
| 354 |
+
<div id="modal" style="display: none; position: fixed; background: white; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); padding: 20px; z-index: 1000;">
|
| 355 |
+
<div style="text-align: right;">
|
| 356 |
+
<button onclick="closeModal()" style="background: none; border: none; font-size: 18px; cursor: pointer;">×</button>
|
| 357 |
+
</div>
|
| 358 |
+
<img id="modal-image" style="width: 100%; height: auto; border-radius: 8px; margin-bottom: 20px;" />
|
| 359 |
+
<h2 id="modal-name"></h2>
|
| 360 |
+
<p id="modal-description"></p>
|
| 361 |
+
<p id="modal-price"></p>
|
| 362 |
+
<label for="biryani-extras">Biryani Extras:</label>
|
| 363 |
+
<div id="biryani-extras-options" style="display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0;">
|
| 364 |
+
<label><input type="checkbox" name="biryani-extra" value="Thums up" /> Thums up + $2.00</label>
|
| 365 |
+
<label><input type="checkbox" name="biryani-extra" value="Sprite" /> Sprite + $2.00</label>
|
| 366 |
+
<label><input type="checkbox" name="biryani-extra" value="Extra Raitha" /> Extra Raitha + $1.00</label>
|
| 367 |
+
<label><input type="checkbox" name="biryani-extra" value="Extra Salan" /> Extra Salan + $2.00</label>
|
| 368 |
+
<label><input type="checkbox" name="biryani-extra" value="Extra Onion & Lemon" /> Extra Onion & Lemon + $2.00</label>
|
| 369 |
+
<label><input type="checkbox" name="biryani-extra" value="Chilli Chicken" /> Chilli Chicken + $14.00</label>
|
| 370 |
+
<label><input type="checkbox" name="biryani-extra" value="Veg Manchurian" /> Veg Manchurian + $12.00</label>
|
| 371 |
+
</div>
|
| 372 |
+
<label for="quantity">Quantity:</label>
|
| 373 |
+
<input type="number" id="quantity" value="1" min="1" style="width: 50px;" />
|
| 374 |
+
<br><br>
|
| 375 |
+
<textarea id="special-instructions" placeholder="Add special instructions here..." style="width: 100%; height: 60px;"></textarea>
|
| 376 |
+
<br><br>
|
| 377 |
+
<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>
|
| 378 |
+
</div>
|
| 379 |
+
""")
|
| 380 |
+
|
| 381 |
+
# Layout for the menu page
|
| 382 |
+
gr.Row([selected_preference])
|
| 383 |
+
gr.Row(menu_output)
|
| 384 |
+
gr.Row(cart_output)
|
| 385 |
+
gr.Row(modal_window)
|
| 386 |
+
gr.Row(final_order_output)
|
| 387 |
+
gr.HTML(modal_and_cart_js)
|
| 388 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
|
| 390 |
return demo
|
| 391 |
|