feat: invoices section on settings page, show paid and active payments

This commit is contained in:
2026-03-19 00:16:33 +04:00
parent 81f1e1585e
commit c3103f06ce
2 changed files with 47 additions and 1 deletions
+14 -1
View File
@@ -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