Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -313,6 +313,7 @@ def navigate_to_login():
|
|
313 |
return gr.update(visible=True), gr.update(visible=False)
|
314 |
|
315 |
# Gradio App
|
|
|
316 |
def app():
|
317 |
with gr.Blocks() as demo:
|
318 |
# Login Page
|
@@ -337,33 +338,16 @@ def app():
|
|
337 |
|
338 |
# Menu Page
|
339 |
with gr.Column(visible=False) as menu_section:
|
340 |
-
gr.Markdown("### Menu Page
|
341 |
-
selected_preference = gr.Radio(
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
with gr.Column(visible=False) as cart_section:
|
348 |
-
gr.Markdown("### Cart Details")
|
349 |
cart_output = gr.HTML(value="Your cart is empty.", elem_id="floating-cart")
|
350 |
-
submit_button = gr.Button("Submit")
|
351 |
-
back_button = gr.Button("Back")
|
352 |
-
|
353 |
-
# Dynamic Navigation
|
354 |
-
cart_button.click(lambda: (gr.update(visible=False), gr.update(visible=True)),
|
355 |
-
outputs=[menu_section, cart_section])
|
356 |
-
|
357 |
-
back_button.click(lambda: (gr.update(visible=True), gr.update(visible=False)),
|
358 |
-
outputs=[menu_section, cart_section])
|
359 |
-
|
360 |
-
submit_button.click(None, inputs=[], outputs=[], _js="submitCart")
|
361 |
|
362 |
|
363 |
-
|
364 |
-
# Final order display
|
365 |
-
final_order_output = gr.HTML(value="", elem_id="final-order")
|
366 |
-
|
367 |
# Modal window
|
368 |
modal_window = gr.HTML("""
|
369 |
<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;">
|
@@ -382,7 +366,7 @@ def app():
|
|
382 |
<label><input type="checkbox" name="biryani-extra" value="Extra Raitha" /> Extra Raitha + $1.00</label>
|
383 |
<label><input type="checkbox" name="biryani-extra" value="Extra Salan" /> Extra Salan + $2.00</label>
|
384 |
<label><input type="checkbox" name="biryani-extra" value="Extra Onion & Lemon" /> Extra Onion & Lemon + $2.00</label>
|
385 |
-
<label><input type="checkbox" name="biryani-extra" value="
|
386 |
<label><input type="checkbox" name="biryani-extra" value="Veg Manchurian" /> Veg Manchurian + $12.00</label>
|
387 |
</div>
|
388 |
<!-- Quantity and Special Instructions -->
|
@@ -413,20 +397,44 @@ def app():
|
|
413 |
inputs=[login_email, login_password],
|
414 |
outputs=[login_section, menu_section, login_error],
|
415 |
)
|
|
|
416 |
go_to_signup.click(
|
417 |
lambda: (gr.update(visible=False), gr.update(visible=True)),
|
418 |
outputs=[login_section, signup_section],
|
419 |
)
|
|
|
420 |
signup_button.click(
|
421 |
lambda name, phone, email, password: ("Signup successful! Please login.", gr.update(visible=True), gr.update(visible=False)) if save_user(name, phone, email, password) else ("Email already exists.", gr.update(visible=False), gr.update(visible=True)),
|
422 |
inputs=[signup_name, signup_phone, signup_email, signup_password],
|
423 |
outputs=[signup_message, login_section, signup_section],
|
424 |
)
|
|
|
425 |
go_to_login.click(
|
426 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|
427 |
outputs=[login_section, signup_section],
|
428 |
)
|
429 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
430 |
return demo
|
431 |
|
432 |
|
|
|
313 |
return gr.update(visible=True), gr.update(visible=False)
|
314 |
|
315 |
# Gradio App
|
316 |
+
|
317 |
def app():
|
318 |
with gr.Blocks() as demo:
|
319 |
# Login Page
|
|
|
338 |
|
339 |
# Menu Page
|
340 |
with gr.Column(visible=False) as menu_section:
|
341 |
+
gr.Markdown("### Menu Page")
|
342 |
+
selected_preference = gr.Radio(
|
343 |
+
choices=["All", "Vegetarian", "Halal/Non-Veg", "Guilt-Free"],
|
344 |
+
value="All",
|
345 |
+
label="Choose a Preference",
|
346 |
+
)
|
347 |
+
menu_output = gr.HTML(value="Menu will load here dynamically")
|
|
|
|
|
348 |
cart_output = gr.HTML(value="Your cart is empty.", elem_id="floating-cart")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
|
350 |
|
|
|
|
|
|
|
|
|
351 |
# Modal window
|
352 |
modal_window = gr.HTML("""
|
353 |
<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;">
|
|
|
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 |
<!-- Quantity and Special Instructions -->
|
|
|
397 |
inputs=[login_email, login_password],
|
398 |
outputs=[login_section, menu_section, login_error],
|
399 |
)
|
400 |
+
|
401 |
go_to_signup.click(
|
402 |
lambda: (gr.update(visible=False), gr.update(visible=True)),
|
403 |
outputs=[login_section, signup_section],
|
404 |
)
|
405 |
+
|
406 |
signup_button.click(
|
407 |
lambda name, phone, email, password: ("Signup successful! Please login.", gr.update(visible=True), gr.update(visible=False)) if save_user(name, phone, email, password) else ("Email already exists.", gr.update(visible=False), gr.update(visible=True)),
|
408 |
inputs=[signup_name, signup_phone, signup_email, signup_password],
|
409 |
outputs=[signup_message, login_section, signup_section],
|
410 |
)
|
411 |
+
|
412 |
go_to_login.click(
|
413 |
lambda: (gr.update(visible=True), gr.update(visible=False)),
|
414 |
outputs=[login_section, signup_section],
|
415 |
)
|
416 |
|
417 |
+
# Navigation to Cart Page
|
418 |
+
view_cart_button.click(
|
419 |
+
lambda: (gr.update(visible=False), gr.update(visible=True), update_cart_display()),
|
420 |
+
outputs=[menu_section, cart_section, cart_details_output],
|
421 |
+
)
|
422 |
+
|
423 |
+
# Submit Order Logic
|
424 |
+
submit_order_button.click(
|
425 |
+
lambda: generate_final_order([
|
426 |
+
{"name": "Biryani", "quantity": 2, "total_price": 20.00},
|
427 |
+
{"name": "Veg Manchurian", "quantity": 1, "total_price": 12.00},
|
428 |
+
]),
|
429 |
+
outputs=[final_order_output],
|
430 |
+
)
|
431 |
+
|
432 |
+
# Back to Menu Page from Cart Page
|
433 |
+
back_to_menu_button.click(
|
434 |
+
lambda: (gr.update(visible=True), gr.update(visible=False)),
|
435 |
+
outputs=[menu_section, cart_section],
|
436 |
+
)
|
437 |
+
|
438 |
return demo
|
439 |
|
440 |
|