diff options
| author | Adam Soltys <[email protected]> | 2026-03-03 16:08:52 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-03-03 16:08:52 -0800 |
| commit | 8551df92b96ff69f3cda50184cb714ba30f3803d (patch) | |
| tree | b53b414d20d40d9bb9ab33764caa113c5996a262 /src/routes/(app)/invoice/+page.server.ts | |
| parent | 14fff3ba852b1d696f61a0da25aaf0e04ccd4158 (diff) | |
| download | coinos-ui-8551df92b96ff69f3cda50184cb714ba30f3803d.tar.gz coinos-ui-8551df92b96ff69f3cda50184cb714ba30f3803d.zip | |
get rid of /receive route
Diffstat (limited to 'src/routes/(app)/invoice/+page.server.ts')
| -rw-r--r-- | src/routes/(app)/invoice/+page.server.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/routes/(app)/invoice/+page.server.ts b/src/routes/(app)/invoice/+page.server.ts index 92cfd18d..e3d8125f 100644 --- a/src/routes/(app)/invoice/+page.server.ts +++ b/src/routes/(app)/invoice/+page.server.ts @@ -3,16 +3,20 @@ import type { Invoice } from "$lib/types"; import { auth, post } from "$lib/utils"; import { error, redirect } from "@sveltejs/kit"; -export const load = async ({ cookies, parent }) => { +export const load = async ({ cookies, parent, url }) => { const aid = cookies.get("aid"); let { subject, user } = await parent(); const rates = await getRates(); - if (aid === user.id) redirect(307, `/${user.username}/receive`); + + const type = url.searchParams.get("type") || undefined; + const address_type = url.searchParams.get("address_type") || undefined; let invoice: Invoice = { aid: aid || "", rate: rates[user?.currency || subject?.currency], + ...(type && { type }), + ...(address_type && { address_type }), }; if (!user) user = subject; @@ -26,7 +30,9 @@ export const load = async ({ cookies, parent }) => { const { id } = invoice; + const lnurl = url.searchParams.has("lnurl"); + if (invoice.memoPrompt && !invoice.memo) { redirect(307, `/invoice/${id}/memo`); - } else redirect(307, `/invoice/${id}`); + } else redirect(307, `/invoice/${id}${lnurl ? "?lnurl=true" : ""}`); }; |
