feat: invoices section on settings page, show paid and active payments
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user