Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
-
from utils.database_handler import check_credentials, save_user # Ensure these functions are implemented
|
| 4 |
|
| 5 |
# Initialize global cart
|
| 6 |
cart_items = []
|
|
@@ -36,7 +35,7 @@ def filter_menu(preference):
|
|
| 36 |
</div>
|
| 37 |
<div style="flex-shrink: 0; text-align: center;">
|
| 38 |
<img src="{item['Image URL']}" alt="{item['Dish Name']}" style="width: 100px; height: 100px; border-radius: 8px; object-fit: cover; margin-bottom: 10px;">
|
| 39 |
-
<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 ($)']}')">
|
| 40 |
</div>
|
| 41 |
</div>
|
| 42 |
"""
|
|
@@ -72,58 +71,44 @@ def add_to_cart(name, price, quantity):
|
|
| 72 |
# Main Gradio App Interface
|
| 73 |
def app_interface():
|
| 74 |
with gr.Blocks() as app:
|
| 75 |
-
#
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
email = gr.Textbox(label="Email", placeholder="Enter your email")
|
| 79 |
-
password = gr.Textbox(label="Password", placeholder="Enter your password", type="password")
|
| 80 |
-
error_box = gr.Markdown("", visible=False)
|
| 81 |
-
login_btn = gr.Button("Login")
|
| 82 |
-
create_account_btn = gr.Button("Create an Account")
|
| 83 |
-
|
| 84 |
-
# Sign-Up Section
|
| 85 |
-
with gr.Column(visible=False) as signup_section:
|
| 86 |
-
gr.Markdown("# Sign Up Page")
|
| 87 |
-
name = gr.Textbox(label="Name", placeholder="Enter your full name")
|
| 88 |
-
phone = gr.Textbox(label="Phone", placeholder="Enter your phone number")
|
| 89 |
-
signup_email = gr.Textbox(label="Email", placeholder="Enter your email")
|
| 90 |
-
signup_password = gr.Textbox(label="Password", placeholder="Enter a password", type="password")
|
| 91 |
-
signup_btn = gr.Button("Sign Up")
|
| 92 |
-
back_to_login_btn = gr.Button("Back to Login")
|
| 93 |
|
| 94 |
# Menu Section
|
| 95 |
-
with gr.Column(
|
| 96 |
-
gr.Markdown("#
|
| 97 |
preference = gr.Radio(choices=["All", "Vegetarian", "Halal/Non-Veg", "Guilt-Free"], label="Filter Menu")
|
| 98 |
-
menu_output = gr.HTML()
|
| 99 |
cart_output = gr.HTML(value="Your cart is empty.")
|
| 100 |
|
| 101 |
# Update menu dynamically based on preference
|
| 102 |
preference.change(filter_menu, inputs=[preference], outputs=[menu_output])
|
| 103 |
|
| 104 |
-
#
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
|
| 123 |
# Layout for Menu Section
|
| 124 |
gr.Row([preference])
|
| 125 |
gr.Row(menu_output)
|
| 126 |
gr.Row(cart_output)
|
|
|
|
| 127 |
|
| 128 |
return app
|
| 129 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
|
|
|
| 3 |
|
| 4 |
# Initialize global cart
|
| 5 |
cart_items = []
|
|
|
|
| 35 |
</div>
|
| 36 |
<div style="flex-shrink: 0; text-align: center;">
|
| 37 |
<img src="{item['Image URL']}" alt="{item['Dish Name']}" style="width: 100px; height: 100px; border-radius: 8px; object-fit: cover; margin-bottom: 10px;">
|
| 38 |
+
<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['Image URL']}', '{item['Description']}', '{item['Price ($)']}')">View Details</button>
|
| 39 |
</div>
|
| 40 |
</div>
|
| 41 |
"""
|
|
|
|
| 71 |
# Main Gradio App Interface
|
| 72 |
def app_interface():
|
| 73 |
with gr.Blocks() as app:
|
| 74 |
+
# Header Section
|
| 75 |
+
gr.Markdown("<h1 style='text-align: center; font-size: 36px;'>Dynamic Menu System</h1>")
|
| 76 |
+
gr.Markdown("<p style='text-align: center; font-size: 18px; color: gray;'>Select your preferences and explore the menu</p>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
# Menu Section
|
| 79 |
+
with gr.Column() as menu_section:
|
| 80 |
+
gr.Markdown("# Menu")
|
| 81 |
preference = gr.Radio(choices=["All", "Vegetarian", "Halal/Non-Veg", "Guilt-Free"], label="Filter Menu")
|
| 82 |
+
menu_output = gr.HTML(value=filter_menu("All"))
|
| 83 |
cart_output = gr.HTML(value="Your cart is empty.")
|
| 84 |
|
| 85 |
# Update menu dynamically based on preference
|
| 86 |
preference.change(filter_menu, inputs=[preference], outputs=[menu_output])
|
| 87 |
|
| 88 |
+
# Modal Pop-up Section
|
| 89 |
+
modal_window = gr.HTML("""
|
| 90 |
+
<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; width: 40%; top: 20%; left: 30%; transform: translate(-50%, -50%);">
|
| 91 |
+
<div style="text-align: right;">
|
| 92 |
+
<button onclick="closeModal()" style="background: none; border: none; font-size: 18px; cursor: pointer;">×</button>
|
| 93 |
+
</div>
|
| 94 |
+
<img id="modal-image" style="width: 100%; height: auto; border-radius: 8px; margin-bottom: 20px;" />
|
| 95 |
+
<h2 id="modal-name" style="text-align: center;"></h2>
|
| 96 |
+
<p id="modal-description" style="color: gray; text-align: center;"></p>
|
| 97 |
+
<p id="modal-price" style="font-size: 20px; text-align: center;"></p>
|
| 98 |
+
<label for="quantity">Quantity:</label>
|
| 99 |
+
<input type="number" id="quantity" value="1" min="1" style="width: 50px; margin-bottom: 20px;" />
|
| 100 |
+
<br><br>
|
| 101 |
+
<textarea id="special-instructions" placeholder="Add special instructions here..." style="width: 100%; height: 60px; border-radius: 5px;"></textarea>
|
| 102 |
+
<br><br>
|
| 103 |
+
<button style="background-color: #28a745; color: white; border: none; padding: 10px 20px; font-size: 16px; border-radius: 5px; cursor: pointer; width: 100%;" onclick="addToCart()">Add to Cart</button>
|
| 104 |
+
</div>
|
| 105 |
+
""")
|
| 106 |
|
| 107 |
# Layout for Menu Section
|
| 108 |
gr.Row([preference])
|
| 109 |
gr.Row(menu_output)
|
| 110 |
gr.Row(cart_output)
|
| 111 |
+
gr.Row(modal_window)
|
| 112 |
|
| 113 |
return app
|
| 114 |
|