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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -23
app.py CHANGED
@@ -78,8 +78,6 @@ def filter_menu(preference):
78
  """
79
  return html_content
80
  # Preserving your JavaScript for modal and cart functionality (Your original JavaScript logic)
81
-
82
-
83
  modal_and_cart_js = """
84
  <style>
85
  .cart-container {
@@ -285,15 +283,6 @@ button {
285
  document.getElementById('final-order').innerHTML = finalOrderHTML;
286
  alert("Your final order has been submitted!");
287
  }
288
- function navigateToCart() {
289
- // Hide the menu section and show the cart section
290
- document.querySelector(".gr-Column.menu_section").style.display = "none";
291
- document.querySelector(".gr-Column.cart_section").style.display = "block";
292
-
293
- // Scroll to the top of the page
294
- window.scrollTo({ top: 0, behavior: 'smooth' });
295
- }
296
-
297
  </script>
298
  """
299
  # Authentication and Navigation Logic
@@ -318,13 +307,6 @@ def navigate_to_login():
318
  # Gradio App
319
  def app():
320
  with gr.Blocks() as demo:
321
- scroll_js = """
322
- <script>
323
- function smoothScrollToTop() {
324
- window.scrollTo({top: 0, behavior: 'smooth'});
325
- }
326
- </script>
327
- """
328
  # Login Page
329
  with gr.Column(visible=True) as login_section:
330
  gr.Markdown("# Login Page")
@@ -348,6 +330,8 @@ def app():
348
  # Menu Page
349
  with gr.Column(visible=False) as menu_section:
350
  gr.Markdown("### Menu Page (Accessible Only After Login)")
 
 
351
 
352
  # View Cart Button (Top Position)
353
  view_cart_button_top = gr.Button("View Cart")
@@ -413,6 +397,7 @@ def app():
413
  # Cart & Final Order Page
414
  with gr.Column(visible=False) as cart_section:
415
  gr.Markdown("### Cart & Final Order Page")
 
416
 
417
  # Floating cart display
418
  cart_output = gr.HTML(value="Your cart is empty.", elem_id="floating-cart")
@@ -450,7 +435,6 @@ def app():
450
  outputs=[login_section, signup_section],
451
  )
452
  # Navigate to Cart Page (Both Buttons Use the Same Logic)
453
- # Top View Cart Button
454
  view_cart_button_top.click(
455
  lambda: (gr.update(visible=False), gr.update(visible=True)),
456
  outputs=[menu_section, cart_section],
@@ -459,10 +443,6 @@ def app():
459
  lambda: (gr.update(visible=False), gr.update(visible=True)),
460
  outputs=[menu_section, cart_section],
461
  )
462
- view_cart_button_bottom.click(None, _js="smoothScrollToTop")
463
-
464
-
465
-
466
  # Navigate Back to Menu Page
467
  back_to_menu_button.click(
468
  lambda: (gr.update(visible=True), gr.update(visible=False)),
 
78
  """
79
  return html_content
80
  # Preserving your JavaScript for modal and cart functionality (Your original JavaScript logic)
 
 
81
  modal_and_cart_js = """
82
  <style>
83
  .cart-container {
 
283
  document.getElementById('final-order').innerHTML = finalOrderHTML;
284
  alert("Your final order has been submitted!");
285
  }
 
 
 
 
 
 
 
 
 
286
  </script>
287
  """
288
  # Authentication and Navigation Logic
 
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")
 
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")
 
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")
 
435
  outputs=[login_section, signup_section],
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],
 
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)),