feat: /dashboard/checkout/:id route so invoices survive refresh
This commit is contained in:
parent
1cbbd65adb
commit
36a7d309fa
|
|
@ -213,7 +213,15 @@ export const dashboard = new Elysia()
|
||||||
if (!resolved?.accountId) return redirect("/dashboard");
|
if (!resolved?.accountId) return redirect("/dashboard");
|
||||||
const [acc] = await sql`SELECT plan, plan_expires_at FROM accounts WHERE id = ${resolved.accountId}`;
|
const [acc] = await sql`SELECT plan, plan_expires_at FROM accounts WHERE id = ${resolved.accountId}`;
|
||||||
if (acc.plan === "lifetime") return redirect("/dashboard/settings");
|
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
|
// New monitor
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue