Update templates/reward_status.html
Browse files- templates/reward_status.html +92 -138
templates/reward_status.html
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
-
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Reward Status</title>
|
7 |
<style>
|
@@ -54,7 +54,6 @@
|
|
54 |
color: #888;
|
55 |
margin-bottom: 20px;
|
56 |
}
|
57 |
-
/* Reward progress bar styling */
|
58 |
.points-bar {
|
59 |
width: 100%;
|
60 |
height: 20px;
|
@@ -74,80 +73,19 @@
|
|
74 |
font-size: 0.9em;
|
75 |
color: #333;
|
76 |
}
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
display: flex;
|
81 |
-
align-items: center;
|
82 |
-
justify-content: space-between;
|
83 |
-
margin-top: 20px;
|
84 |
}
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
height: 150px;
|
89 |
-
object-fit: cover;
|
90 |
-
border-radius: 8px;
|
91 |
}
|
92 |
-
|
93 |
-
.ingredient-card {
|
94 |
display: flex;
|
95 |
justify-content: space-between;
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
.ingredient {
|
100 |
-
text-align: center;
|
101 |
-
cursor: pointer;
|
102 |
-
}
|
103 |
-
|
104 |
-
.ingredient img {
|
105 |
-
width: 100px;
|
106 |
-
height: 100px;
|
107 |
-
object-fit: cover;
|
108 |
-
border-radius: 8px;
|
109 |
-
}
|
110 |
-
|
111 |
-
/* Modal styling for ingredient details */
|
112 |
-
.modal {
|
113 |
-
display: none;
|
114 |
-
position: fixed;
|
115 |
-
z-index: 1;
|
116 |
-
left: 0;
|
117 |
-
top: 0;
|
118 |
-
width: 100%;
|
119 |
-
height: 100%;
|
120 |
-
background-color: rgba(0, 0, 0, 0.5);
|
121 |
-
overflow: auto;
|
122 |
-
padding-top: 60px;
|
123 |
-
}
|
124 |
-
|
125 |
-
.modal-content {
|
126 |
-
background-color: #fff;
|
127 |
-
margin: 5% auto;
|
128 |
-
padding: 20px;
|
129 |
-
border: 1px solid #888;
|
130 |
-
width: 50%;
|
131 |
-
border-radius: 8px;
|
132 |
-
}
|
133 |
-
|
134 |
-
.modal-header {
|
135 |
-
font-size: 1.5em;
|
136 |
-
margin-bottom: 15px;
|
137 |
-
}
|
138 |
-
|
139 |
-
.modal-body p {
|
140 |
-
font-size: 1em;
|
141 |
-
margin: 10px 0;
|
142 |
-
}
|
143 |
-
|
144 |
-
.close {
|
145 |
-
color: #aaa;
|
146 |
-
font-size: 1.5em;
|
147 |
-
position: absolute;
|
148 |
-
right: 10px;
|
149 |
-
top: 10px;
|
150 |
-
cursor: pointer;
|
151 |
}
|
152 |
</style>
|
153 |
</head>
|
@@ -162,82 +100,98 @@
|
|
162 |
<div class="reward-status">
|
163 |
<div class="badge">{{ current_tier }} Status</div>
|
164 |
<div class="valid-through">Valid through December 2024</div>
|
165 |
-
|
166 |
<div class="points-info">
|
167 |
<div class="points">You have <strong>{{ user_points }}</strong> points</div>
|
168 |
</div>
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
{
|
173 |
-
<div>
|
174 |
-
<img class="item-image" src="{{ item.image_url }}" alt="{{ item.name }}" onerror="this.src='/static/placeholder.jpg';">
|
175 |
-
<h3>{{ item.name }}</h3>
|
176 |
-
<p>Price: ${{ "%.2f"|format(item.price) }}</p>
|
177 |
-
</div>
|
178 |
-
|
179 |
-
<div class="ingredient-card">
|
180 |
-
{% for ingredient in item.ingredients %}
|
181 |
-
{% if ingredient.name %}
|
182 |
-
<div class="ingredient" onclick="showIngredientDetails('{{ ingredient.name }}')">
|
183 |
-
<img src="{{ ingredient.image }}" alt="{{ ingredient.name }}" onerror="this.src='/static/placeholder.jpg';">
|
184 |
-
<p>{{ ingredient.name }}</p>
|
185 |
-
</div>
|
186 |
-
{% endif %}
|
187 |
-
{% endfor %}
|
188 |
-
</div>
|
189 |
-
{% endfor %}
|
190 |
</div>
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
<!-- Ingredient Modal -->
|
196 |
-
<div id="ingredientModal" class="modal">
|
197 |
-
<div class="modal-content">
|
198 |
-
<span class="close" onclick="closeModal()">×</span>
|
199 |
-
<div class="modal-header">
|
200 |
-
<h2 id="ingredientName"></h2>
|
201 |
</div>
|
202 |
-
|
203 |
-
|
204 |
-
<
|
205 |
-
<
|
206 |
-
<h3>Fun Facts:</h3>
|
207 |
-
<p id="funFacts"></p>
|
208 |
</div>
|
209 |
</div>
|
210 |
</div>
|
211 |
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
}
|
240 |
-
</script>
|
241 |
|
242 |
-
|
243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
+
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Reward Status</title>
|
7 |
<style>
|
|
|
54 |
color: #888;
|
55 |
margin-bottom: 20px;
|
56 |
}
|
|
|
57 |
.points-bar {
|
58 |
width: 100%;
|
59 |
height: 20px;
|
|
|
73 |
font-size: 0.9em;
|
74 |
color: #333;
|
75 |
}
|
76 |
+
.points {
|
77 |
+
font-size: 1.1em;
|
78 |
+
font-weight: bold;
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
+
.next-tier {
|
81 |
+
font-size: 1.1em;
|
82 |
+
font-weight: bold;
|
|
|
|
|
|
|
83 |
}
|
84 |
+
.points-bar-info {
|
|
|
85 |
display: flex;
|
86 |
justify-content: space-between;
|
87 |
+
font-size: 0.9em;
|
88 |
+
color: #333;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
90 |
</style>
|
91 |
</head>
|
|
|
100 |
<div class="reward-status">
|
101 |
<div class="badge">{{ current_tier }} Status</div>
|
102 |
<div class="valid-through">Valid through December 2024</div>
|
103 |
+
|
104 |
<div class="points-info">
|
105 |
<div class="points">You have <strong>{{ user_points }}</strong> points</div>
|
106 |
</div>
|
107 |
|
108 |
+
<div class="points-bar-info">
|
109 |
+
<div>{{ start_point }}</div> <!-- Start of the range -->
|
110 |
+
<div>{{ end_point }}</div> <!-- End of the range -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
</div>
|
112 |
|
113 |
+
<div class="points-bar">
|
114 |
+
<div class="progress"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
</div>
|
116 |
+
|
117 |
+
<div class="points-info">
|
118 |
+
<div class="points">You need <strong>{{ points_needed_for_next_tier }}</strong> more points</div>
|
119 |
+
<div class="next-tier">Next tier: {{ next_tier }}</div>
|
|
|
|
|
120 |
</div>
|
121 |
</div>
|
122 |
</div>
|
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 |
+
)
|