nagasurendra commited on
Commit
4a01f9e
·
verified ·
1 Parent(s): 1072bca

Update cart.py

Browse files
Files changed (1) hide show
  1. cart.py +4 -10
cart.py CHANGED
@@ -375,7 +375,7 @@ def checkout():
375
  def get_loyalty_data():
376
  email = session.get('user_email')
377
  if not email:
378
- return jsonify({"success": False, "message": "User not logged in"})
379
 
380
  try:
381
  # Fetch customer loyalty data
@@ -385,7 +385,7 @@ def get_loyalty_data():
385
  """)
386
  customer = customer_record.get("records", [])[0] if customer_record["records"] else None
387
  if not customer:
388
- return jsonify({"success": False, "message": "Customer not found"})
389
 
390
  # Define available rewards
391
  rewards = [
@@ -401,13 +401,7 @@ def get_loyalty_data():
401
  "badge": customer.get("Badge__c", "Newbie"),
402
  "available_rewards": rewards
403
  }
404
- return jsonify({"success": True, "data": loyalty_data})
405
 
406
  except Exception as e:
407
- return jsonify({"success": False, "error": str(e)})
408
- @cart_blueprint.route("/loyalty_page", methods=["GET"])
409
- def loyalty_page():
410
- email = session.get('user_email')
411
- if not email:
412
- return redirect(url_for('login')) # Redirect to login if not authenticated
413
- return render_template("loyalty.html") # Render the loyalty page
 
375
  def get_loyalty_data():
376
  email = session.get('user_email')
377
  if not email:
378
+ return redirect(url_for('login')) # Redirect to login if not authenticated
379
 
380
  try:
381
  # Fetch customer loyalty data
 
385
  """)
386
  customer = customer_record.get("records", [])[0] if customer_record["records"] else None
387
  if not customer:
388
+ return "Customer not found", 404
389
 
390
  # Define available rewards
391
  rewards = [
 
401
  "badge": customer.get("Badge__c", "Newbie"),
402
  "available_rewards": rewards
403
  }
404
+ return render_template("loyalty.html", loyalty_data=loyalty_data)
405
 
406
  except Exception as e:
407
+ return f"Error: {str(e)}", 500