Credits column: balance view = credits left, all-time view = total purchased

This commit is contained in:
inference-bot committed 2026-10-03 13:59:34 -06:00
1 parent 585f133412
commit 345eca7f1e
1 file changed
+12 -7
+12 -7
View File
@@ -274,7 +274,9 @@ PAGE_HTML = """<!DOCTYPE html>
.range-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.range-btn { cursor: pointer; border: 1px solid var(--border); background: #fff; color: var(--muted); border-radius: 8px; font-size: 12px; font-weight: 600; padding: 5px 12px; }
.range-btn.active { background: var(--green-mid); color: #fff; border-color: var(--green-mid); }
.members-all-time .balance-col { display: none; }
.members-all-time .balance-col.allowance-only,
.members-all-time .balance-col.remaining-only { display: none; }
.members-all-time .credits-col-head .mode-note::after { content: " (total purchased)"; }
.table-scroll { overflow-x: auto; border-radius: 12px; }
.table-scroll table { min-width: 980px; }
th.sortable { cursor: pointer; user-select: none; }
@@ -322,8 +324,8 @@ PAGE_HTML = """<!DOCTYPE html>
<th class="sortable" onclick="sortMembers('active')">Status<span class="arrow" id="arrow-members-active"></span></th>
<th class="sortable" onclick="sortMembers('activated')">Activated<span class="arrow" id="arrow-members-activated"></span></th>
<th class="sortable" onclick="sortMembers('manual')">Source<span class="arrow" id="arrow-members-manual"></span></th>
<th class="sortable balance-col" onclick="sortMembers('balance')">Allowance<span class="arrow" id="arrow-members-balance"></span></th>
<th class="sortable balance-col" onclick="sortMembers('credit_balance')">Credits<span class="arrow" id="arrow-members-credit_balance"></span></th>
<th class="sortable balance-col allowance-only" onclick="sortMembers('balance')">Allowance<span class="arrow" id="arrow-members-balance"></span></th>
<th class="sortable balance-col credits-col-head" onclick="sortMembers('credit_balance')">Credits<span class="mode-note"></span><span class="arrow" id="arrow-members-credit_balance"></span></th>
<th class="sortable" onclick="sortMembers('spend')"><span id="spend-mode-label">Spend</span><span class="arrow" id="arrow-members-spend"></span></th>
<th class="sortable balance-col" onclick="sortMembers('remaining')">Remaining<span class="arrow" id="arrow-members-remaining"></span></th>
<th class="sortable balance-col" onclick="sortMembers('reset_at')">Reset<span class="arrow" id="arrow-members-reset_at"></span></th>
@@ -483,8 +485,11 @@ function renderMembers() {
? '<span class="pill active">yes</span>'
: '<span class="pill inactive">pending</span>';
const credits = m.credit_balance ?? 0;
const creditsCell = credits > 0
? fmt(credits)
const creditsLeft = m.credits_remaining ?? credits;
// Balance view: credits LEFT. All-time view: total purchased.
const creditsShown = memberMode === 'all' ? credits : creditsLeft;
const creditsCell = creditsShown > 0
? fmt(creditsShown)
: '<span style="color:var(--muted)">—</span>';
const src = m.manual
? '<span class="pill manual" title="Manual member (no OC subscription; exempt from sweep)">manual</span>'
@@ -494,10 +499,10 @@ function renderMembers() {
'<td><span class="pill ' + pill + '">' + pill + '</span></td>' +
'<td>' + act + '</td>' +
'<td>' + src + '</td>' +
'<td class="num balance-col">' + fmt(m.balance) + '</td>' +
'<td class="num balance-col allowance-only">' + fmt(m.balance) + '</td>' +
'<td class="num balance-col">' + creditsCell + '</td>' +
'<td class="num">' + fmt(memberSpend(m)) + '</td>' +
'<td class="num balance-col remaining-col">' + fmt(m.remaining) + '</td>' +
'<td class="num balance-col remaining-col remaining-only">' + fmt(m.remaining) + '</td>' +
'<td class="balance-col">' + esc(reset) + '</td>' +
'<td><div class="adjust">' +
'<input id="add-' + i(m.email) + '" placeholder="+$" />' +