nagasurendra commited on
Commit
96338bc
·
verified ·
1 Parent(s): beadadb

Update templates/reward_status.html

Browse files
Files changed (1) hide show
  1. templates/reward_status.html +0 -71
templates/reward_status.html CHANGED
@@ -123,75 +123,4 @@
123
 
124
  </body>
125
  </html>
126
- observe this code
127
- @app.route('/reward_status')
128
- def reward_status():
129
- # Get the user email from session (assuming the session is already set during checkout)
130
- email = session.get('user_email')
131
-
132
- if not email:
133
- return "User not logged in", 400
134
 
135
- # Query Salesforce to fetch the user's reward points
136
- try:
137
- # Query the Customer_Login__c object based on the user's email
138
- query = f"SELECT Id, Reward_Points__c FROM Customer_Login__c WHERE Email__c = '{email}'"
139
- user_data = sf.query(query)
140
-
141
- # Check if the user record was found
142
- if not user_data.get("records"):
143
- return "User not found", 400
144
-
145
- # Get the user's reward points from Salesforce
146
- user_points = user_data["records"][0].get("Reward_Points__c", 0)
147
-
148
- except Exception as e:
149
- return f"Error querying Salesforce: {str(e)}", 500
150
-
151
- # Define point ranges for each tier
152
- tiers = {
153
- "Bronze": 100, # Example: 0 to 100 for Bronze
154
- "Silver": 200, # Example: 100 to 200 for Silver
155
- "Gold": 300, # Example: 200 to 300 for Gold
156
- "Platinum": 500
157
- }
158
-
159
- # Logic for calculating the next tier's range and current progress
160
- current_tier = "Silver" # Example, dynamically determine this
161
-
162
- # Calculate the range for the current tier
163
- if current_tier == "Silver":
164
- start_point = 100 # Silver starts at 100
165
- end_point = 200 # Silver ends at 200
166
- elif current_tier == "Gold":
167
- start_point = 200 # Gold starts at 200
168
- end_point = 300 # Gold ends at 300
169
- else:
170
- start_point = 0 # Default start point for other tiers
171
- end_point = 100 # Default end point for other tiers
172
-
173
- # Calculate progress as a percentage
174
- if user_points >= start_point:
175
- progress_percentage = ((user_points - start_point) / (end_point - start_point)) * 100
176
- else:
177
- progress_percentage = 0
178
-
179
- # Calculate points to next tier
180
- points_needed_for_next_tier = end_point - user_points
181
- next_tier = "Gold" # Next tier name (you can dynamically calculate this)
182
- # Round the points before passing to the template
183
- user_points = round(user_points)
184
- points_needed_for_next_tier = round(points_needed_for_next_tier)
185
-
186
- # Pass these values to your template
187
- return render_template(
188
- 'reward_status.html',
189
- user_points=user_points,
190
- current_tier=current_tier,
191
- progress_percentage=progress_percentage,
192
- points_needed_for_next_tier=points_needed_for_next_tier,
193
- start_point=start_point,
194
- end_point=end_point,
195
- next_tier=next_tier,
196
- tiers=tiers
197
- )
 
123
 
124
  </body>
125
  </html>
 
 
 
 
 
 
 
 
126