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

Update templates/loyalty.html

Browse files
Files changed (1) hide show
  1. templates/loyalty.html +11 -31
templates/loyalty.html CHANGED
@@ -10,37 +10,17 @@
10
  <body>
11
  <h1>Your Loyalty Status</h1>
12
  <div id="loyalty-info">
13
- <p>Loading loyalty data...</p>
 
 
 
 
 
 
 
 
 
 
14
  </div>
15
-
16
- <script>
17
- fetch('{{ url_for("cart.checkout.loyalty") }}') // Use the correct endpoint name
18
- .then(response => response.json())
19
- .then(data => {
20
- if (data.success) {
21
- const info = data.data;
22
- const html = `
23
- <p>Points: ${info.reward_points}</p>
24
- <p>Total Orders: ${info.total_orders}</p>
25
- <p>Total Spent: $${info.total_spent}</p>
26
- <p>Badge: <span class="badge">${info.badge}</span></p>
27
- <h2>Available Rewards</h2>
28
- ${info.available_rewards.map(reward => `
29
- <div class="reward">
30
- <strong>${reward.name}</strong> - ${reward.points} points
31
- <p>${reward.description}</p>
32
- </div>
33
- `).join('')}
34
- `;
35
- document.getElementById('loyalty-info').innerHTML = html;
36
- } else {
37
- document.getElementById('loyalty-info').innerHTML = `<p>${data.message || 'Error loading loyalty data'}</p>`;
38
- }
39
- })
40
- .catch(error => {
41
- console.error('Error:', error);
42
- document.getElementById('loyalty-info').innerHTML = '<p>Failed to load loyalty data</p>';
43
- });
44
- </script>
45
  </body>
46
  </html>
 
10
  <body>
11
  <h1>Your Loyalty Status</h1>
12
  <div id="loyalty-info">
13
+ <p>Points: {{ loyalty_data.reward_points }}</p>
14
+ <p>Total Orders: {{ loyalty_data.total_orders }}</p>
15
+ <p>Total Spent: ${{ loyalty_data.total_spent }}</p>
16
+ <p>Badge: <span class="badge">{{ loyalty_data.badge }}</span></p>
17
+ <h2>Available Rewards</h2>
18
+ {% for reward in loyalty_data.available_rewards %}
19
+ <div class="reward">
20
+ <strong>{{ reward.name }}</strong> - {{ reward.points }} points
21
+ <p>{{ reward.description }}</p>
22
+ </div>
23
+ {% endfor %}
24
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  </body>
26
  </html>