Rammohan0504 commited on
Commit
09ac4f4
·
verified ·
1 Parent(s): e70dea1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -8
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("# Restaurant QR Code Ordering System")
63
 
64
  # QR Code Generator
65
  with gr.Tab("QR Code Generator"):
@@ -71,25 +71,37 @@ 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.Radio(["New Customer", "Existing Customer"], label="Select Customer Type")
75
  phone_input = gr.Textbox(label="Phone Number", placeholder="Enter your phone number")
76
- name_input = gr.Textbox(label="Name", placeholder="Enter your name (For New Customers)")
77
- email_input = gr.Textbox(label="Email", placeholder="Enter your email (For New Customers)")
78
- username_input = gr.Textbox(label="Username", placeholder="Enter your username (Existing Customers)")
79
  password_input = gr.Textbox(label="Password", placeholder="Enter your password", type="password")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  action_button = gr.Button("Submit")
82
  result_output = gr.Text(label="Status")
83
 
84
- def handle_input(customer_type, phone, name, email, username, password):
85
- is_new = customer_type == "New Customer"
86
  if not is_new:
87
  name, email = None, None # Ignore name and email for existing customers
88
  return login_or_signup(is_new, phone, name, email, password)
89
 
90
  action_button.click(
91
  handle_input,
92
- inputs=[is_new_customer, phone_input, name_input, email_input, username_input, password_input],
93
  outputs=result_output
94
  )
95
 
 
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
  # 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