dashboard: always-visible 'Buy a credit pack' link out to Open Collective

Members expected to add usage from the dashboard and couldn't find it —
the buy path (OpenCollective contribute page) was invisible. Payments
still happen on OC; this just surfaces the door:

- green 'Buy a credit pack' button in the My usage card, always visible
- hint shows the member's real credit status ('Credits never expire
  ($X purchased all-time).' — moved out of the meta line, which keeps
  'Shared across chat and API · Allowance renews <date>.')
- 'More about allowance & credits' links to the docs section
  (getting-started.md#need-more-than-the-allowance)

Verified desktop + 390px mobile rendering.
This commit is contained in:
Casey Gollan committed 2026-11-01 18:23:36 -05:00
1 parent c28a5b3fe7
commit 40792d6387
3 files changed
+86 -3

No files matched your search

+24 -3
View File
@@ -357,6 +357,18 @@ PAGE_HTML = """<!DOCTYPE html>
.bar .fill { height: 100%; background: var(--green-mid); border-radius: 6px; transition: width .3s ease; }
.bar .fill.warn { background: #d99a3e; }
.meta { color: var(--muted); font-size: 13px; margin-top: 8px; }
/* Buy-a-credit-pack: always-visible link out to Open Collective, plus
a pointer to the docs section that explains allowance vs. credits. */
.buy-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
a.buy-btn {
display: inline-block; background: var(--green-deep); color: #fff;
border-radius: 8px; font-size: 14px; font-weight: 600;
padding: 8px 16px; text-decoration: none; transition: background .15s ease;
}
a.buy-btn:hover { background: #4e7a4d; }
.buy-hint { color: var(--muted); font-size: 12px; }
a.buy-docs { color: var(--green-deep); font-weight: 600; text-decoration: none; white-space: nowrap; }
a.buy-docs:hover { text-decoration: underline; }
.models { margin-top: 16px; }
.model-row {
display: flex; align-items: center; justify-content: space-between; gap: 12px;
@@ -557,6 +569,12 @@ PAGE_HTML = """<!DOCTYPE html>
</div>
<div class="bar"><div class="fill" id="fill" style="width:0%"></div></div>
<div class="meta" id="meta">Shared across chat and API.</div>
<div class="buy-row">
<a class="buy-btn" href="https://opencollective.com/inference-cooperative/contribute" target="_blank" rel="noopener">Buy a credit pack</a>
<span class="buy-hint"><span id="buy-credits">Credit packs never expire · used after your monthly allowance.</span>
<a class="buy-docs" href="https://git.inference.coop/co-op/docs/src/branch/main/getting-started.md#need-more-than-the-allowance" target="_blank">More about allowance &amp; credits →</a>
</span>
</div>
<div class="models" id="models"></div>
</div>
@@ -685,9 +703,12 @@ async function load() {
if (d.reset_at) {
const d2 = new Date(d.reset_at);
const opts = { year: 'numeric', month: 'long', day: 'numeric' };
let meta = 'Shared across chat and API · Allowance renews ' + d2.toLocaleDateString(undefined, opts);
if (creditsTotal > 0) meta += ' · Credits never expire (' + fmtMoney(creditsTotal) + ' purchased all-time)';
$('meta').textContent = meta + '.';
$('meta').textContent = 'Shared across chat and API · Allowance renews ' + d2.toLocaleDateString(undefined, opts) + '.';
}
// Credits copy lives in the buy row (next to the button), not the meta line.
if (creditsTotal > 0) {
$('buy-credits').textContent = 'Credits never expire (' + fmtMoney(creditsTotal) + ' purchased all-time).';
}
const calls = (d.models || []).reduce((s, m) => s + (m.calls || 0), 0);