diff --git a/apps/web/src/routes/dashboard.ts b/apps/web/src/routes/dashboard.ts index 0a2e5aa..675f13d 100644 --- a/apps/web/src/routes/dashboard.ts +++ b/apps/web/src/routes/dashboard.ts @@ -204,7 +204,20 @@ export const dashboard = new Elysia() const loginKey = isSubKey ? null : (cookie?.pingql_key?.value ?? null); const [{ count: monitorCount }] = await sql`SELECT COUNT(*)::int as count FROM monitors WHERE account_id = ${accountId}`; - return html("settings", { nav: "settings", account: acc, apiKeys, accountId, loginKey, isSubKey, monitorCount }); + // Fetch paid + active (non-expired) invoices + let invoices: any[] = []; + try { + invoices = await sql` + SELECT id, plan, months, amount_usd, coin, amount_crypto, status, created_at, paid_at, expires_at, txid + FROM payments + WHERE account_id = ${accountId} + AND (status = 'paid' OR (status IN ('pending', 'confirming') AND expires_at >= now())) + ORDER BY created_at DESC + LIMIT 20 + `; + } catch {} + + return html("settings", { nav: "settings", account: acc, apiKeys, accountId, loginKey, isSubKey, monitorCount, invoices }); }) // Checkout — upgrade plan diff --git a/apps/web/src/views/settings.ejs b/apps/web/src/views/settings.ejs index e76f062..f7fe0d0 100644 --- a/apps/web/src/views/settings.ejs +++ b/apps/web/src/views/settings.ejs @@ -46,6 +46,39 @@ <% } %> + + <% if (it.invoices && it.invoices.length > 0) { %> +
+

Invoices

+
+ <% it.invoices.forEach(function(inv) { + const statusColors = { paid: 'green', confirming: 'blue', pending: 'yellow' }; + const statusColor = statusColors[inv.status] || 'gray'; + const date = new Date(inv.created_at).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }); + const planLabel = inv.plan === 'lifetime' ? 'Lifetime' : `Pro × ${inv.months}mo`; + %> +
+
+ +
+ <%= planLabel %> + $<%= Number(inv.amount_usd).toFixed(2) %> · <%= inv.coin.toUpperCase() %> +
+
+
+ <%= date %> + <% if (inv.status === 'pending' || inv.status === 'confirming') { %> + View + <% } else if (inv.status === 'paid' && inv.txid) { %> + Paid + <% } %> +
+
+ <% }) %> +
+
+ <% } %> +

Account