aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-03-04 15:05:44 -0800
committerAdam Soltys <[email protected]>2026-03-04 15:05:44 -0800
commite6882c6a8987e23215a2538b242431ae603c7101 (patch)
treecdfd3a29015e630ae552968195e02c835b0c3978 /src/routes
parent350a2a46aa3b48d3223b6e5c14ddc5952d260dba (diff)
downloadcoinos-ui-e6882c6a8987e23215a2538b242431ae603c7101.tar.gz
coinos-ui-e6882c6a8987e23215a2538b242431ae603c7101.zip
invoice page improvements
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/(app)/[username]/accepted/[text]/+page.svelte24
-rw-r--r--src/routes/(app)/account/[id]/+page.svelte6
-rw-r--r--src/routes/(app)/invoice/+page.server.ts12
-rw-r--r--src/routes/(app)/invoice/+page.svelte1
-rw-r--r--src/routes/(app)/invoice/[id]/+layout.server.ts20
-rw-r--r--src/routes/(app)/invoice/[id]/+page.svelte4
-rw-r--r--src/routes/(static)/register/+page.svelte18
7 files changed, 63 insertions, 22 deletions
diff --git a/src/routes/(app)/[username]/accepted/[text]/+page.svelte b/src/routes/(app)/[username]/accepted/[text]/+page.svelte
index be3f5ec2..e1b93de1 100644
--- a/src/routes/(app)/[username]/accepted/[text]/+page.svelte
+++ b/src/routes/(app)/[username]/accepted/[text]/+page.svelte
@@ -4,6 +4,7 @@
import { back, copy } from "$lib/utils";
import { t } from "$lib/translations";
import { bech32 } from "@scure/base";
+ import { goto } from "$app/navigation";
import { page } from "$app/stores";
import { PUBLIC_DOMAIN } from "$env/static/public";
@@ -11,6 +12,13 @@
let { data } = $props();
let { nfc, text } = $derived(data);
let { username } = $derived(data.subject);
+
+ let toggleNfc = () => {
+ const url = new URL($page.url);
+ if (nfc) url.searchParams.delete("nfc");
+ else url.searchParams.set("nfc", "true");
+ goto(url.pathname + url.search, { invalidateAll: true });
+ };
let url = $derived(() => `https://coinos.io/p/${username.toLowerCase()}`);
let lnurl = $derived(
@@ -43,8 +51,16 @@
<div class="text-center text-4xl font-bold break-all">coinos.io/{username.toLowerCase()}</div>
</div>
- <button onclick={() => copy(lnurl)} class="flex gap-1 m-auto my-8">
- <PhCopyBold width={32} />
- {$t("user.copyLnurl")}
- </button>
+ <div class="flex items-center justify-center gap-4 my-8">
+ <button onclick={() => copy(lnurl)} class="flex gap-1">
+ <PhCopyBold width={32} />
+ {$t("user.copyLnurl")}
+ </button>
+ <button onclick={toggleNfc} class="flex items-center gap-2">
+ <span class="font-semibold">NFC</span>
+ <div class="w-11 h-6 rounded-full relative {nfc ? 'bg-green-500' : 'bg-gray-400'}">
+ <div class="absolute top-0.5 left-[2px] bg-white border border-gray-300 rounded-full h-5 w-5 transition-all {nfc ? 'translate-x-full' : ''}"></div>
+ </div>
+ </button>
+ </div>
</div>
diff --git a/src/routes/(app)/account/[id]/+page.svelte b/src/routes/(app)/account/[id]/+page.svelte
index 6f1d9921..3f00a168 100644
--- a/src/routes/(app)/account/[id]/+page.svelte
+++ b/src/routes/(app)/account/[id]/+page.svelte
@@ -309,8 +309,10 @@
onkeydown={(e) => e.key === "Escape" && (showDeleteConfirm = false)}
>
<div class="bg-base-100 rounded-2xl p-6 max-w-sm w-full space-y-4 text-center" role="none" onclick={(e) => e.stopPropagation()}>
- <PhWarningBold width="48" class="text-error" />
- <h2 class="text-xl font-semibold">{$t("accounts.deleteAccount")}</h2>
+ <h2 class="text-xl font-semibold flex items-center justify-center gap-2">
+ <PhWarningBold width="32" class="text-error" />
+ {$t("accounts.deleteAccount")}
+ </h2>
<p class="text-secondary">{$t("accounts.deleteConfirm")}</p>
<div class="flex gap-2">
<button type="button" class="btn !w-auto grow" onclick={() => (showDeleteConfirm = false)}>
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 {
diff --git a/src/routes/(static)/register/+page.svelte b/src/routes/(static)/register/+page.svelte
index da84ee89..f57ff0ad 100644
--- a/src/routes/(static)/register/+page.svelte
+++ b/src/routes/(static)/register/+page.svelte
@@ -130,15 +130,15 @@
{$t("login.continue")}
</button>
- <p class="text-secondary text-center font-medium">
- {$t("login.haveAccount")}
- <a
- href={"/login" + $page.url.search}
- class="block md:inline text-secondary underline underline-offset-4 hover:opacity-80"
- >
- {$t("login.signIn")}
- </a>
- </p>
+ <div class="flex items-center gap-4">
+ <hr class="flex-1" />
+ <span class="text-secondary text-sm">{$t("login.or")}</span>
+ <hr class="flex-1" />
+ </div>
+
+ <a href={"/login" + $page.url.search} class="btn">
+ {$t("login.haveAccount")} {$t("login.signIn")}
+ </a>
</div>
</div>