nagasurendra commited on
Commit
753f99d
·
verified ·
1 Parent(s): a2f647a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -27
app.py CHANGED
@@ -304,9 +304,24 @@ def create_account(name, phone, email, password):
304
  def navigate_to_login():
305
  return gr.update(visible=True), gr.update(visible=False)
306
 
307
- # Gradio App
308
  def app():
309
  with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  # Login Page
311
  with gr.Column(visible=True) as login_section:
312
  gr.Markdown("# Login Page")
@@ -327,11 +342,9 @@ def app():
327
  signup_button = gr.Button("Sign Up")
328
  go_to_login = gr.Button("Back to Login")
329
 
330
- # Menu Page
331
  with gr.Column(visible=False) as menu_section:
332
  gr.Markdown("### Menu Page (Accessible Only After Login)")
333
- view_cart_button_bottom = gr.Button("View Cart")
334
-
335
 
336
  # View Cart Button (Top Position)
337
  view_cart_button_top = gr.Button("View Cart")
@@ -394,23 +407,6 @@ def app():
394
  gr.Row(modal_window)
395
  gr.HTML(modal_and_cart_js)
396
 
397
- # Cart & Final Order Page
398
- with gr.Column(visible=False) as cart_section:
399
- gr.Markdown("### Cart & Final Order Page")
400
- back_to_menu_button = gr.Button("Back to Menu")
401
-
402
- # Floating cart display
403
- cart_output = gr.HTML(value="Your cart is empty.", elem_id="floating-cart")
404
-
405
- # Final order display
406
- final_order_output = gr.HTML(value="", elem_id="final-order")
407
-
408
- # Button to navigate back to Menu Page
409
- back_to_menu_button = gr.Button("Back to Menu")
410
-
411
- gr.Row(cart_output)
412
- gr.Row(final_order_output)
413
-
414
  # Button Bindings
415
  # Login Button
416
  login_button.click(
@@ -436,20 +432,21 @@ def app():
436
  )
437
  # Navigate to Cart Page (Both Buttons Use the Same Logic)
438
  view_cart_button_top.click(
439
- lambda: (gr.update(visible=False), gr.update(visible=True)),
440
- outputs=[menu_section, cart_section],
441
  )
442
  view_cart_button_bottom.click(
443
- lambda: (gr.update(visible=False), gr.update(visible=True)),
444
- outputs=[menu_section, cart_section],
445
  )
446
  # Navigate Back to Menu Page
447
  back_to_menu_button.click(
448
- lambda: (gr.update(visible=True), gr.update(visible=False)),
449
- outputs=[menu_section, cart_section],
450
  )
451
 
452
  return demo
453
 
 
454
  if __name__ == "__main__":
455
  app().launch()
 
304
  def navigate_to_login():
305
  return gr.update(visible=True), gr.update(visible=False)
306
 
 
307
  def app():
308
  with gr.Blocks() as demo:
309
+ # Cart & Final Order Page (Always at the Top)
310
+ with gr.Column(visible=False) as cart_section:
311
+ gr.Markdown("### Cart & Final Order Page")
312
+
313
+ # Floating cart display
314
+ cart_output = gr.HTML(value="Your cart is empty.", elem_id="floating-cart")
315
+
316
+ # Final order display
317
+ final_order_output = gr.HTML(value="", elem_id="final-order")
318
+
319
+ # Button to navigate back to Menu Page
320
+ back_to_menu_button = gr.Button("Back to Menu")
321
+
322
+ gr.Row(cart_output)
323
+ gr.Row(final_order_output)
324
+
325
  # Login Page
326
  with gr.Column(visible=True) as login_section:
327
  gr.Markdown("# Login Page")
 
342
  signup_button = gr.Button("Sign Up")
343
  go_to_login = gr.Button("Back to Login")
344
 
345
+ # Menu Page (Below Cart Section)
346
  with gr.Column(visible=False) as menu_section:
347
  gr.Markdown("### Menu Page (Accessible Only After Login)")
 
 
348
 
349
  # View Cart Button (Top Position)
350
  view_cart_button_top = gr.Button("View Cart")
 
407
  gr.Row(modal_window)
408
  gr.HTML(modal_and_cart_js)
409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  # Button Bindings
411
  # Login Button
412
  login_button.click(
 
432
  )
433
  # Navigate to Cart Page (Both Buttons Use the Same Logic)
434
  view_cart_button_top.click(
435
+ lambda: (gr.update(visible=True), gr.update(visible=False)),
436
+ outputs=[cart_section, menu_section],
437
  )
438
  view_cart_button_bottom.click(
439
+ lambda: (gr.update(visible=True), gr.update(visible=False)),
440
+ outputs=[cart_section, menu_section],
441
  )
442
  # Navigate Back to Menu Page
443
  back_to_menu_button.click(
444
+ lambda: (gr.update(visible=False), gr.update(visible=True)),
445
+ outputs=[cart_section, menu_section],
446
  )
447
 
448
  return demo
449
 
450
+
451
  if __name__ == "__main__":
452
  app().launch()