Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -34,26 +34,27 @@ def verify_username(username):
|
|
34 |
inquiry_section: gr.update(visible=False)
|
35 |
}
|
36 |
|
37 |
-
def submit_inquiry(username, product_desc, purchase_qty, annual_amount, deadline, export_country):
|
38 |
"""Submit inquiry information to Google Sheet"""
|
39 |
try:
|
40 |
# Try to get the Inquiry worksheet, create it if it doesn't exist
|
41 |
try:
|
42 |
inquiry_sheet = sheet.worksheet('Inquiry')
|
43 |
except gspread.WorksheetNotFound:
|
44 |
-
inquiry_sheet = sheet.add_worksheet('Inquiry', 1000,
|
45 |
# Add headers
|
46 |
inquiry_sheet.append_row([
|
47 |
-
'Timestamp', 'Username', '
|
48 |
-
'
|
49 |
-
'
|
|
|
50 |
])
|
51 |
|
52 |
# Prepare the row data
|
53 |
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
54 |
row_data = [
|
55 |
-
timestamp, username,
|
56 |
-
purchase_qty, annual_amount,
|
57 |
deadline, export_country
|
58 |
]
|
59 |
|
@@ -84,16 +85,24 @@ with gr.Blocks() as app:
|
|
84 |
# Inquiry Form Section
|
85 |
with gr.Group(visible=False) as inquiry_section:
|
86 |
gr.Markdown("### 2. Inquiry Details")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
product_desc = gr.Textbox(
|
88 |
label="Product Description",
|
89 |
placeholder="Enter product description",
|
90 |
lines=3
|
91 |
)
|
92 |
-
purchase_qty = gr.
|
93 |
label="Purchase Quantity",
|
94 |
placeholder="Enter quantity"
|
95 |
)
|
96 |
-
annual_amount = gr.
|
97 |
label="Estimated Annual Purchase Amount (USD)",
|
98 |
placeholder="Enter amount in USD"
|
99 |
)
|
@@ -120,6 +129,8 @@ with gr.Blocks() as app:
|
|
120 |
fn=submit_inquiry,
|
121 |
inputs=[
|
122 |
username_input,
|
|
|
|
|
123 |
product_desc,
|
124 |
purchase_qty,
|
125 |
annual_amount,
|
|
|
34 |
inquiry_section: gr.update(visible=False)
|
35 |
}
|
36 |
|
37 |
+
def submit_inquiry(username, company_name, phone_number, product_desc, purchase_qty, annual_amount, deadline, export_country):
|
38 |
"""Submit inquiry information to Google Sheet"""
|
39 |
try:
|
40 |
# Try to get the Inquiry worksheet, create it if it doesn't exist
|
41 |
try:
|
42 |
inquiry_sheet = sheet.worksheet('Inquiry')
|
43 |
except gspread.WorksheetNotFound:
|
44 |
+
inquiry_sheet = sheet.add_worksheet('Inquiry', 1000, 9) # Increased columns for new fields
|
45 |
# Add headers
|
46 |
inquiry_sheet.append_row([
|
47 |
+
'Timestamp', 'Username', 'Company Name', 'Phone Number',
|
48 |
+
'Product Description', 'Purchase Quantity',
|
49 |
+
'Annual Amount (USD)', 'Purchase Deadline',
|
50 |
+
'Export Country'
|
51 |
])
|
52 |
|
53 |
# Prepare the row data
|
54 |
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
55 |
row_data = [
|
56 |
+
timestamp, username, company_name, phone_number,
|
57 |
+
product_desc, purchase_qty, annual_amount,
|
58 |
deadline, export_country
|
59 |
]
|
60 |
|
|
|
85 |
# Inquiry Form Section
|
86 |
with gr.Group(visible=False) as inquiry_section:
|
87 |
gr.Markdown("### 2. Inquiry Details")
|
88 |
+
company_name = gr.Textbox(
|
89 |
+
label="Full Company Name",
|
90 |
+
placeholder="Enter your company's full name"
|
91 |
+
)
|
92 |
+
phone_number = gr.Textbox(
|
93 |
+
label="Phone Number",
|
94 |
+
placeholder="Enter your phone number"
|
95 |
+
)
|
96 |
product_desc = gr.Textbox(
|
97 |
label="Product Description",
|
98 |
placeholder="Enter product description",
|
99 |
lines=3
|
100 |
)
|
101 |
+
purchase_qty = gr.Number(
|
102 |
label="Purchase Quantity",
|
103 |
placeholder="Enter quantity"
|
104 |
)
|
105 |
+
annual_amount = gr.Number(
|
106 |
label="Estimated Annual Purchase Amount (USD)",
|
107 |
placeholder="Enter amount in USD"
|
108 |
)
|
|
|
129 |
fn=submit_inquiry,
|
130 |
inputs=[
|
131 |
username_input,
|
132 |
+
company_name,
|
133 |
+
phone_number,
|
134 |
product_desc,
|
135 |
purchase_qty,
|
136 |
annual_amount,
|