feat: /dashboard/checkout/:id route so invoices survive refresh

This commit is contained in:
M1 2026-03-18 23:37:20 +04:00
parent 1cbbd65adb
commit 36a7d309fa
1 changed files with 9 additions and 1 deletions

View File

@ -213,7 +213,15 @@ export const dashboard = new Elysia()
if (!resolved?.accountId) return redirect("/dashboard");
const [acc] = await sql`SELECT plan, plan_expires_at FROM accounts WHERE id = ${resolved.accountId}`;
if (acc.plan === "lifetime") return redirect("/dashboard/settings");
return html("checkout", { nav: "settings", account: acc, payApi: process.env.PAY_API || "https://pay.pingql.com" });
return html("checkout", { nav: "settings", account: acc, payApi: process.env.PAY_API || "https://pay.pingql.com", invoiceId: null });
})
// Existing invoice by ID — survives refreshes
.get("/dashboard/checkout/:id", async ({ cookie, headers, params }) => {
const resolved = await getAccountId(cookie, headers);
if (!resolved?.accountId) return redirect("/dashboard");
const [acc] = await sql`SELECT plan, plan_expires_at FROM accounts WHERE id = ${resolved.accountId}`;
return html("checkout", { nav: "settings", account: acc, payApi: process.env.PAY_API || "https://pay.pingql.com", invoiceId: params.id });
})
// New monitor