Rammohan0504 commited on
Commit
2f96421
·
verified ·
1 Parent(s): 78b574e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -17
app.py CHANGED
@@ -59,7 +59,7 @@ def login_or_signup(is_new_customer, phone_number, name=None, email=None, passwo
59
 
60
  def main():
61
  with gr.Blocks() as demo:
62
- gr.Markdown("# Welcome to Biryani Hub")
63
 
64
  # QR Code Generator
65
  with gr.Tab("QR Code Generator"):
@@ -71,37 +71,39 @@ def main():
71
  # Login or Signup
72
  with gr.Tab("Login / Signup"):
73
  gr.Markdown("## Are you a new or existing customer?")
74
- is_new_customer = gr.Checkbox(label="New Customer", value=True)
 
 
75
  phone_input = gr.Textbox(label="Phone Number", placeholder="Enter your phone number")
76
- name_input = gr.Textbox(label="Name", placeholder="Enter your name", visible=True)
77
- email_input = gr.Textbox(label="Email", placeholder="Enter your email", visible=True)
78
- password_input = gr.Textbox(label="Password", placeholder="Enter your password", type="password")
79
- username_input = gr.Textbox(label="Username", placeholder="Enter your username", visible=False)
 
80
 
 
81
  def toggle_fields(is_new):
82
- return (
83
- is_new, # Show name input
84
- is_new, # Show email input
85
- not is_new # Show username input for existing customers
86
- )
87
 
88
  is_new_customer.change(
89
  toggle_fields,
90
  inputs=[is_new_customer],
91
- outputs=[name_input, email_input, username_input]
92
  )
93
 
 
94
  action_button = gr.Button("Submit")
95
  result_output = gr.Text(label="Status")
96
 
97
- def handle_input(is_new, phone, name, email, password, username):
98
- if not is_new:
99
- name, email = None, None # Ignore name and email for existing customers
100
- return login_or_signup(is_new, phone, name, email, password)
 
101
 
102
  action_button.click(
103
  handle_input,
104
- inputs=[is_new_customer, phone_input, name_input, email_input, password_input, username_input],
105
  outputs=result_output
106
  )
107
 
 
59
 
60
  def main():
61
  with gr.Blocks() as demo:
62
+ gr.Markdown("# Restaurant QR Code Ordering System")
63
 
64
  # QR Code Generator
65
  with gr.Tab("QR Code Generator"):
 
71
  # Login or Signup
72
  with gr.Tab("Login / Signup"):
73
  gr.Markdown("## Are you a new or existing customer?")
74
+ is_new_customer = gr.Checkbox(label="Check if you are a new customer")
75
+
76
+ # Input fields
77
  phone_input = gr.Textbox(label="Phone Number", placeholder="Enter your phone number")
78
+ name_input = gr.Textbox(label="Name (For New Customers)", placeholder="Enter your name", visible=False)
79
+ email_input = gr.Textbox(label="Email (For New Customers)", placeholder="Enter your email", visible=False)
80
+ password_input_new = gr.Textbox(label="Password (For New Customers)", placeholder="Enter your password", type="password", visible=False)
81
+ username_input = gr.Textbox(label="Username (For Existing Customers)", placeholder="Enter your username", visible=False)
82
+ password_input_existing = gr.Textbox(label="Password (For Existing Customers)", placeholder="Enter your password", type="password", visible=False)
83
 
84
+ # Visibility logic
85
  def toggle_fields(is_new):
86
+ return (is_new, is_new, is_new, not is_new, not is_new)
 
 
 
 
87
 
88
  is_new_customer.change(
89
  toggle_fields,
90
  inputs=[is_new_customer],
91
+ outputs=[name_input, email_input, password_input_new, username_input, password_input_existing]
92
  )
93
 
94
+ # Action button
95
  action_button = gr.Button("Submit")
96
  result_output = gr.Text(label="Status")
97
 
98
+ def handle_input(is_new, phone, name, email, password, username, existing_password):
99
+ if is_new:
100
+ return login_or_signup(is_new, phone, name, email, password)
101
+ else:
102
+ return login_or_signup(is_new, phone, name=username, password=existing_password)
103
 
104
  action_button.click(
105
  handle_input,
106
+ inputs=[is_new_customer, phone_input, name_input, email_input, password_input_new, username_input, password_input_existing],
107
  outputs=result_output
108
  )
109