diff options
| author | Adam Soltys <[email protected]> | 2026-03-04 15:05:44 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-03-04 15:05:44 -0800 |
| commit | e6882c6a8987e23215a2538b242431ae603c7101 (patch) | |
| tree | cdfd3a29015e630ae552968195e02c835b0c3978 /src/routes/(app)/invoice | |
| parent | 350a2a46aa3b48d3223b6e5c14ddc5952d260dba (diff) | |
| download | coinos-ui-e6882c6a8987e23215a2538b242431ae603c7101.tar.gz coinos-ui-e6882c6a8987e23215a2538b242431ae603c7101.zip | |
invoice page improvements
Diffstat (limited to 'src/routes/(app)/invoice')
| -rw-r--r-- | src/routes/(app)/invoice/+page.server.ts | 12 | ||||
| -rw-r--r-- | src/routes/(app)/invoice/+page.svelte | 1 | ||||
| -rw-r--r-- | src/routes/(app)/invoice/[id]/+layout.server.ts | 20 | ||||
| -rw-r--r-- | src/routes/(app)/invoice/[id]/+page.svelte | 4 |
4 files changed, 30 insertions, 7 deletions
diff --git a/src/routes/(app)/invoice/+page.server.ts b/src/routes/(app)/invoice/+page.server.ts index e3d8125f..9cf2088a 100644 --- a/src/routes/(app)/invoice/+page.server.ts +++ b/src/routes/(app)/invoice/+page.server.ts @@ -4,9 +4,15 @@ import { auth, post } from "$lib/utils"; import { error, redirect } from "@sveltejs/kit"; export const load = async ({ cookies, parent, url }) => { - const aid = cookies.get("aid"); + const aid = url.searchParams.get("aid") || cookies.get("aid"); + if (aid) cookies.set("aid", aid, { path: "/", maxAge: 86400 }); let { subject, user } = await parent(); + const lnurl = url.searchParams.has("lnurl"); + if (lnurl) { + redirect(307, `/invoice/lnurl`); + } + const rates = await getRates(); const type = url.searchParams.get("type") || undefined; @@ -30,9 +36,7 @@ export const load = async ({ cookies, parent, url }) => { const { id } = invoice; - const lnurl = url.searchParams.has("lnurl"); - if (invoice.memoPrompt && !invoice.memo) { redirect(307, `/invoice/${id}/memo`); - } else redirect(307, `/invoice/${id}${lnurl ? "?lnurl=true" : ""}`); + } else redirect(307, `/invoice/${id}`); }; diff --git a/src/routes/(app)/invoice/+page.svelte b/src/routes/(app)/invoice/+page.svelte index e69de29b..8b137891 100644 --- a/src/routes/(app)/invoice/+page.svelte +++ b/src/routes/(app)/invoice/+page.svelte @@ -0,0 +1 @@ + diff --git a/src/routes/(app)/invoice/[id]/+layout.server.ts b/src/routes/(app)/invoice/[id]/+layout.server.ts index f31e28f1..24b7f1b0 100644 --- a/src/routes/(app)/invoice/[id]/+layout.server.ts +++ b/src/routes/(app)/invoice/[id]/+layout.server.ts @@ -1,3 +1,4 @@ +import getRates from "$lib/rates"; import { get } from "$lib/utils"; import { redirect } from "@sveltejs/kit"; @@ -9,7 +10,24 @@ export async function load({ cookies, depends, params, url, parent }) { const { id } = params; let invoice; - if (id) { + if (id === "lnurl") { + const rates = await getRates(); + invoice = { + aid: user.id, + uid: user.id, + amount: 0, + tip: 0, + rate: rates[user?.currency || "USD"], + text: "", + hash: "", + type: "lightning", + items: [], + memo: "", + pending: 0, + received: 0, + user: { id: user.id, username: user.username, currency: user.currency }, + }; + } else if (id) { invoice = await get(`/invoice/${id}`); const options = !!url.searchParams.get("options"); let { amount, pending, received } = invoice; diff --git a/src/routes/(app)/invoice/[id]/+page.svelte b/src/routes/(app)/invoice/[id]/+page.svelte index 6405bd6f..988ba647 100644 --- a/src/routes/(app)/invoice/[id]/+page.svelte +++ b/src/routes/(app)/invoice/[id]/+page.svelte @@ -38,11 +38,11 @@ let { username, currency } = $derived(invoice.user); let locale = $derived(loc(user)); - let lnurlMode = $state(false); + let lnurlMode = $state($page.params.id === "lnurl" || $page.url.searchParams.has("lnurl")); let lnAddress = $derived(`${username}@${$page.url.host}`); $effect(() => { - if ($page.url.searchParams.has("lnurl")) { + if ($page.params.id === "lnurl" || $page.url.searchParams.has("lnurl")) { lnurlMode = true; $showQr = true; } else { |
