Update app.py
Browse files
app.py
CHANGED
|
@@ -31,8 +31,9 @@ def authenticate_user(email, password):
|
|
| 31 |
if result['totalSize'] == 0:
|
| 32 |
return "Invalid Login Details", None, None, gr.update(visible=False), gr.update(visible=False)
|
| 33 |
|
|
|
|
| 34 |
customer = result['records'][0]
|
| 35 |
-
reward_points = customer
|
| 36 |
|
| 37 |
return f"Welcome, you have {reward_points} points. Proceed to rewards.", customer['Id'], reward_points, gr.update(visible=True), gr.update(visible=True)
|
| 38 |
except Exception as e:
|
|
@@ -41,8 +42,9 @@ def authenticate_user(email, password):
|
|
| 41 |
# Function to handle reward points logic
|
| 42 |
def handle_rewards(customer_id, bill_amount, apply_rewards):
|
| 43 |
try:
|
|
|
|
| 44 |
customer = sf.Customer_Login__c.get(customer_id)
|
| 45 |
-
points = customer
|
| 46 |
gst = 0.18 * bill_amount
|
| 47 |
|
| 48 |
if points >= 500 and apply_rewards:
|
|
|
|
| 31 |
if result['totalSize'] == 0:
|
| 32 |
return "Invalid Login Details", None, None, gr.update(visible=False), gr.update(visible=False)
|
| 33 |
|
| 34 |
+
# Ensure we get the correct record
|
| 35 |
customer = result['records'][0]
|
| 36 |
+
reward_points = customer.get('Reward_Points__c', 0) # Default to 0 if not available
|
| 37 |
|
| 38 |
return f"Welcome, you have {reward_points} points. Proceed to rewards.", customer['Id'], reward_points, gr.update(visible=True), gr.update(visible=True)
|
| 39 |
except Exception as e:
|
|
|
|
| 42 |
# Function to handle reward points logic
|
| 43 |
def handle_rewards(customer_id, bill_amount, apply_rewards):
|
| 44 |
try:
|
| 45 |
+
# Ensure the customer exists in Salesforce
|
| 46 |
customer = sf.Customer_Login__c.get(customer_id)
|
| 47 |
+
points = customer.get('Reward_Points__c', 0)
|
| 48 |
gst = 0.18 * bill_amount
|
| 49 |
|
| 50 |
if points >= 500 and apply_rewards:
|