Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -259,28 +259,29 @@ modal_and_cart_js = """
|
|
| 259 |
def app():
|
| 260 |
with gr.Blocks() as demo:
|
| 261 |
# State to track the current page
|
| 262 |
-
current_page = gr.State("login") # Default page is
|
| 263 |
|
| 264 |
-
#
|
| 265 |
-
with gr.Row(
|
| 266 |
gr.Markdown("### Login Page")
|
| 267 |
login_email = gr.Textbox(label="Email")
|
| 268 |
login_password = gr.Textbox(label="Password", type="password")
|
| 269 |
login_btn = gr.Button("Login")
|
| 270 |
login_message = gr.Label()
|
| 271 |
|
|
|
|
| 272 |
def login(email, password):
|
| 273 |
-
message,
|
| 274 |
-
return message,
|
| 275 |
|
| 276 |
login_btn.click(
|
| 277 |
login,
|
| 278 |
inputs=[login_email, login_password],
|
| 279 |
-
outputs=[login_message, current_page], # Update message and page
|
| 280 |
)
|
| 281 |
|
| 282 |
-
#
|
| 283 |
-
with gr.Row(
|
| 284 |
gr.Markdown("### Signup Page")
|
| 285 |
name = gr.Textbox(label="Name")
|
| 286 |
phone = gr.Textbox(label="Phone Number")
|
|
@@ -289,20 +290,20 @@ def app():
|
|
| 289 |
signup_btn = gr.Button("Signup")
|
| 290 |
signup_message = gr.Label()
|
| 291 |
|
|
|
|
| 292 |
def signup(name, phone, email, password):
|
| 293 |
-
message,
|
| 294 |
-
return message,
|
| 295 |
|
| 296 |
signup_btn.click(
|
| 297 |
signup,
|
| 298 |
inputs=[name, phone, email, password],
|
| 299 |
-
outputs=[signup_message, current_page], # Update message and page
|
| 300 |
)
|
| 301 |
|
| 302 |
-
#
|
| 303 |
-
with gr.Row(
|
| 304 |
gr.Markdown("### Menu Page")
|
| 305 |
-
|
| 306 |
# Radio button for selecting preference
|
| 307 |
selected_preference = gr.Radio(
|
| 308 |
choices=["All", "Vegetarian", "Halal/Non-Veg", "Guilt-Free"],
|
|
|
|
| 259 |
def app():
|
| 260 |
with gr.Blocks() as demo:
|
| 261 |
# State to track the current page
|
| 262 |
+
current_page = gr.State("login") # Default page is login
|
| 263 |
|
| 264 |
+
# Login Page
|
| 265 |
+
with gr.Row(visible=lambda x: x == "login", inputs=[current_page]):
|
| 266 |
gr.Markdown("### Login Page")
|
| 267 |
login_email = gr.Textbox(label="Email")
|
| 268 |
login_password = gr.Textbox(label="Password", type="password")
|
| 269 |
login_btn = gr.Button("Login")
|
| 270 |
login_message = gr.Label()
|
| 271 |
|
| 272 |
+
# Function to handle login
|
| 273 |
def login(email, password):
|
| 274 |
+
message, next_page = validate_login(email, password)
|
| 275 |
+
return message, next_page
|
| 276 |
|
| 277 |
login_btn.click(
|
| 278 |
login,
|
| 279 |
inputs=[login_email, login_password],
|
| 280 |
+
outputs=[login_message, current_page], # Update message and redirect to the next page
|
| 281 |
)
|
| 282 |
|
| 283 |
+
# Signup Page
|
| 284 |
+
with gr.Row(visible=lambda x: x == "signup", inputs=[current_page]):
|
| 285 |
gr.Markdown("### Signup Page")
|
| 286 |
name = gr.Textbox(label="Name")
|
| 287 |
phone = gr.Textbox(label="Phone Number")
|
|
|
|
| 290 |
signup_btn = gr.Button("Signup")
|
| 291 |
signup_message = gr.Label()
|
| 292 |
|
| 293 |
+
# Function to handle signup
|
| 294 |
def signup(name, phone, email, password):
|
| 295 |
+
message, next_page = signup_user(name, phone, email, password)
|
| 296 |
+
return message, next_page
|
| 297 |
|
| 298 |
signup_btn.click(
|
| 299 |
signup,
|
| 300 |
inputs=[name, phone, email, password],
|
| 301 |
+
outputs=[signup_message, current_page], # Update message and redirect to the next page
|
| 302 |
)
|
| 303 |
|
| 304 |
+
# Menu Page
|
| 305 |
+
with gr.Row(visible=lambda x: x == "menu", inputs=[current_page]):
|
| 306 |
gr.Markdown("### Menu Page")
|
|
|
|
| 307 |
# Radio button for selecting preference
|
| 308 |
selected_preference = gr.Radio(
|
| 309 |
choices=["All", "Vegetarian", "Halal/Non-Veg", "Guilt-Free"],
|