Update app.py
Browse files
app.py
CHANGED
@@ -5,9 +5,9 @@ from simple_salesforce import Salesforce
|
|
5 |
|
6 |
# Salesforce Connection
|
7 |
sf = Salesforce(
|
8 |
-
username='
|
9 |
-
password='
|
10 |
-
security_token='
|
11 |
)
|
12 |
|
13 |
# Sample Menu Data in JSON Format
|
@@ -97,7 +97,6 @@ def load_menu(preference):
|
|
97 |
<h3>{item['name']}</h3>
|
98 |
<p>{item['description']}</p>
|
99 |
<p>Price: ${item['price']}</p>
|
100 |
-
<button onclick="addToCart('{item['name']}', {item['price']})">Add to Cart</button>
|
101 |
</div>
|
102 |
"""
|
103 |
return html
|
@@ -123,8 +122,13 @@ with gr.Blocks() as app:
|
|
123 |
menu_display = gr.HTML()
|
124 |
|
125 |
with gr.Row():
|
126 |
-
|
127 |
total_cost = gr.Textbox(label="Total Cost")
|
|
|
|
|
|
|
|
|
|
|
128 |
add_item_button = gr.Button("Add to Cart")
|
129 |
|
130 |
with gr.Row():
|
@@ -143,14 +147,14 @@ with gr.Blocks() as app:
|
|
143 |
lambda name, price, quantity, extras, instructions: add_to_cart(
|
144 |
name, price, quantity, extras, instructions
|
145 |
),
|
146 |
-
inputs=[
|
147 |
-
outputs=[
|
148 |
)
|
149 |
|
150 |
# Checkout and Save to Salesforce
|
151 |
checkout_button.click(
|
152 |
-
lambda
|
153 |
-
inputs=[
|
154 |
outputs=checkout_status,
|
155 |
)
|
156 |
|
|
|
5 |
|
6 |
# Salesforce Connection
|
7 |
sf = Salesforce(
|
8 |
+
username='your_username',
|
9 |
+
password='your_password',
|
10 |
+
security_token='your_security_token'
|
11 |
)
|
12 |
|
13 |
# Sample Menu Data in JSON Format
|
|
|
97 |
<h3>{item['name']}</h3>
|
98 |
<p>{item['description']}</p>
|
99 |
<p>Price: ${item['price']}</p>
|
|
|
100 |
</div>
|
101 |
"""
|
102 |
return html
|
|
|
122 |
menu_display = gr.HTML()
|
123 |
|
124 |
with gr.Row():
|
125 |
+
cart_items = gr.JSON(label="Cart Items")
|
126 |
total_cost = gr.Textbox(label="Total Cost")
|
127 |
+
item_name = gr.Textbox(label="Item Name")
|
128 |
+
item_price = gr.Number(label="Price")
|
129 |
+
item_quantity = gr.Number(label="Quantity", value=1)
|
130 |
+
extras = gr.JSON(value=sample_add_ons, label="Add-Ons")
|
131 |
+
instructions = gr.Textbox(label="Special Instructions")
|
132 |
add_item_button = gr.Button("Add to Cart")
|
133 |
|
134 |
with gr.Row():
|
|
|
147 |
lambda name, price, quantity, extras, instructions: add_to_cart(
|
148 |
name, price, quantity, extras, instructions
|
149 |
),
|
150 |
+
inputs=[item_name, item_price, item_quantity, extras, instructions],
|
151 |
+
outputs=[cart_items, total_cost],
|
152 |
)
|
153 |
|
154 |
# Checkout and Save to Salesforce
|
155 |
checkout_button.click(
|
156 |
+
lambda cart, total: save_cart_to_salesforce(cart, total),
|
157 |
+
inputs=[cart_items, total_cost],
|
158 |
outputs=checkout_status,
|
159 |
)
|
160 |
|