Spaces:
Running
Running
Update premium.html
Browse files- premium.html +27 -8
premium.html
CHANGED
|
@@ -113,9 +113,19 @@
|
|
| 113 |
const listEl = document.getElementById('premium-list');
|
| 114 |
const cards = document.querySelectorAll('#features .card');
|
| 115 |
try {
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
statusEl.className = 'badge active';
|
| 120 |
statusEl.textContent = '⭐ ACTIVE';
|
| 121 |
textEl.textContent = 'You have Premium access! Enjoy all features.';
|
|
@@ -123,20 +133,29 @@
|
|
| 123 |
} else {
|
| 124 |
statusEl.className = 'badge inactive';
|
| 125 |
statusEl.textContent = '— LOCKED';
|
| 126 |
-
textEl.textContent = '
|
| 127 |
cards.forEach(c => { c.style.borderColor = 'var(--border)'; c.style.opacity = '0.55'; c.classList.add('locked'); });
|
| 128 |
}
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
const date = new Date(u.grantedAt).toLocaleDateString();
|
| 132 |
-
const avatarUrl = u.avatarUrl ||
|
| 133 |
const displayName = u.userTag || u.userId;
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
}).join('');
|
| 136 |
} else {
|
| 137 |
listEl.innerHTML = '<tr><td colspan="3" style="text-align:center;color:var(--text-dim);padding:24px">No premium users yet. Win a league match to be the first!</td></tr>';
|
| 138 |
}
|
| 139 |
} catch (e) {
|
|
|
|
| 140 |
statusEl.textContent = '❌ ERROR';
|
| 141 |
textEl.textContent = 'Could not load premium data.';
|
| 142 |
listEl.innerHTML = '<tr><td colspan="3" style="text-align:center;color:var(--red)">Failed to load.</td></tr>';
|
|
|
|
| 113 |
const listEl = document.getElementById('premium-list');
|
| 114 |
const cards = document.querySelectorAll('#features .card');
|
| 115 |
try {
|
| 116 |
+
// Check login status first to show user-specific premium status
|
| 117 |
+
let userPremium = false;
|
| 118 |
+
try {
|
| 119 |
+
const authR = await fetch('/api/me');
|
| 120 |
+
const authData = await authR.json();
|
| 121 |
+
if (authData.loggedIn) {
|
| 122 |
+
const premiumR = await fetch('/api/premium');
|
| 123 |
+
const premiumData = await premiumR.json();
|
| 124 |
+
userPremium = premiumData.premium;
|
| 125 |
+
}
|
| 126 |
+
} catch (e) { /* not logged in, that's fine */ }
|
| 127 |
+
|
| 128 |
+
if (userPremium) {
|
| 129 |
statusEl.className = 'badge active';
|
| 130 |
statusEl.textContent = '⭐ ACTIVE';
|
| 131 |
textEl.textContent = 'You have Premium access! Enjoy all features.';
|
|
|
|
| 133 |
} else {
|
| 134 |
statusEl.className = 'badge inactive';
|
| 135 |
statusEl.textContent = '— LOCKED';
|
| 136 |
+
textEl.textContent = 'Log in to the dashboard and win a league match with !win to unlock Premium.';
|
| 137 |
cards.forEach(c => { c.style.borderColor = 'var(--border)'; c.style.opacity = '0.55'; c.classList.add('locked'); });
|
| 138 |
}
|
| 139 |
+
|
| 140 |
+
// Load public premium list
|
| 141 |
+
const listR = await fetch('/api/premium/list');
|
| 142 |
+
const listData = await listR.json();
|
| 143 |
+
if (listData.list && listData.list.length > 0) {
|
| 144 |
+
listEl.innerHTML = listData.list.map(u => {
|
| 145 |
const date = new Date(u.grantedAt).toLocaleDateString();
|
| 146 |
+
const avatarUrl = u.avatarUrl || '';
|
| 147 |
const displayName = u.userTag || u.userId;
|
| 148 |
+
const initial = (displayName || '?')[0].toUpperCase();
|
| 149 |
+
const avatarHtml = avatarUrl
|
| 150 |
+
? `<img src="${avatarUrl}" onerror="this.parentElement.textContent='${initial}'" alt="">`
|
| 151 |
+
: `<span style="font-size:14px;font-weight:700">${initial}</span>`;
|
| 152 |
+
return `<tr><td><div class="user-row"><div class="user-avatar">${avatarHtml}</div><span style="font-size:13px;font-weight:500">${displayName}</span></div></td><td style="font-size:13px">${date}</td><td style="font-size:13px;color:var(--text-dim)">${u.reason || 'manual'}</td></tr>`;
|
| 153 |
}).join('');
|
| 154 |
} else {
|
| 155 |
listEl.innerHTML = '<tr><td colspan="3" style="text-align:center;color:var(--text-dim);padding:24px">No premium users yet. Win a league match to be the first!</td></tr>';
|
| 156 |
}
|
| 157 |
} catch (e) {
|
| 158 |
+
statusEl.className = 'badge inactive';
|
| 159 |
statusEl.textContent = '❌ ERROR';
|
| 160 |
textEl.textContent = 'Could not load premium data.';
|
| 161 |
listEl.innerHTML = '<tr><td colspan="3" style="text-align:center;color:var(--red)">Failed to load.</td></tr>';
|