Spaces:
Runtime error
Runtime error
Create loyalty.html
Browse files- templates/loyalty.html +41 -0
templates/loyalty.html
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<title>Loyalty Program</title>
|
5 |
+
<style>
|
6 |
+
.badge { font-weight: bold; color: gold; }
|
7 |
+
.reward { margin: 10px 0; }
|
8 |
+
</style>
|
9 |
+
</head>
|
10 |
+
<body>
|
11 |
+
<h1>Your Loyalty Status</h1>
|
12 |
+
<div id="loyalty-info"></div>
|
13 |
+
|
14 |
+
<script>
|
15 |
+
fetch('/loyalty')
|
16 |
+
.then(response => response.json())
|
17 |
+
.then(data => {
|
18 |
+
if (data.success) {
|
19 |
+
const info = data.data;
|
20 |
+
const html = `
|
21 |
+
<p>Points: ${info.reward_points}</p>
|
22 |
+
<p>Total Orders: ${info.total_orders}</p>
|
23 |
+
<p>Total Spent: $${info.total_spent}</p>
|
24 |
+
<p>Badge: <span class="badge">${info.badge}</span></p>
|
25 |
+
<h2>Available Rewards</h2>
|
26 |
+
${info.available_rewards.map(reward => `
|
27 |
+
<div class="reward">
|
28 |
+
<strong>${reward.name}</strong> - ${reward.points} points
|
29 |
+
<p>${reward.description}</p>
|
30 |
+
</div>
|
31 |
+
`).join('')}
|
32 |
+
`;
|
33 |
+
document.getElementById('loyalty-info').innerHTML = html;
|
34 |
+
} else {
|
35 |
+
alert(data.message || 'Error loading loyalty data');
|
36 |
+
}
|
37 |
+
})
|
38 |
+
.catch(error => console.error('Error:', error));
|
39 |
+
</script>
|
40 |
+
</body>
|
41 |
+
</html>
|