aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/fund
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-07-19 08:41:49 -0700
committerAdam Soltys <[email protected]>2025-07-19 08:41:49 -0700
commitfea147df07046f240e77075e7c743959d85b1271 (patch)
treeaeb578df4777ea0b74c06b3141ffd4ba0b5b4a1c /src/routes/(app)/fund
parentf063e6a88999f1fe4d9ed2900b90efba1bcf1ac5 (diff)
downloadcoinos-ui-fea147df07046f240e77075e7c743959d85b1271.tar.gz
coinos-ui-fea147df07046f240e77075e7c743959d85b1271.zip
handle tipping for lnurls, sweep fixes
Diffstat (limited to 'src/routes/(app)/fund')
-rw-r--r--src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts11
-rw-r--r--src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte3
2 files changed, 9 insertions, 5 deletions
diff --git a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts
index 61a66fd2..8a8e71ee 100644
--- a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts
+++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts
@@ -8,8 +8,9 @@ export async function load({ cookies, request, params, parent }) {
const { id } = params;
let [amount, currency] = params.amount.split("/");
+ if (!currency) currency = user?.currency;
const rates = await getRates();
- const rate = rates[user?.currency || "USD"];
+ const rate = rates[currency?.toUpperCase() || "USD"];
if (currency && !rate) error(500, "Invalid currency symbol");
if (!amount) {
@@ -35,6 +36,10 @@ export async function load({ cookies, request, params, parent }) {
await register(user, ip, cookies, `/fund/${id}/sweep`);
}
- await post("/take", { amount, id }, auth(cookies));
- return { amount, id, rate, rates, password };
+ try {
+ await post("/take", { amount, id }, auth(cookies));
+ } catch (e) {
+ redirect(307, `/fund/${id}`);
+ }
+ return { amount, currency, id, rate, rates, password };
}
diff --git a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte
index adba77ae..7a7d5402 100644
--- a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte
+++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte
@@ -11,8 +11,7 @@
let { data } = $props();
- let { amount, id, user, rate, rates, password: pw } = data;
- let { currency } = user;
+ let { amount, currency, id, user, rate, rates, password: pw } = data;
let locale = $derived(loc(user));
onMount(() => ($password = pw));