From 888aa32a1467fa752ff543149470d3275c7e8915 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 8 Jul 2025 02:09:42 -0700 Subject: sweep success --- src/routes/(app)/fund/[id]/sweep/+page.svelte | 34 ++++++++++------------ .../send/fund/[...name]/[...amount]/+page.svelte | 29 ++++++++++++++---- 2 files changed, 39 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/routes/(app)/fund/[id]/sweep/+page.svelte b/src/routes/(app)/fund/[id]/sweep/+page.svelte index 0523b85a..986a84bb 100644 --- a/src/routes/(app)/fund/[id]/sweep/+page.svelte +++ b/src/routes/(app)/fund/[id]/sweep/+page.svelte @@ -1,35 +1,33 @@ -
-
- -
-

- {$t("payments.fundsClaimed")} -

-

- {f(toFiat(amount, rate), currency)} -

-

- ⚡️{s(amount)} -

+
+
- -
+
+
-
+
{$t("payments.tapAnywhere")}
diff --git a/src/routes/(app)/send/fund/[...name]/[...amount]/+page.svelte b/src/routes/(app)/send/fund/[...name]/[...amount]/+page.svelte index 314be3ef..652e0885 100644 --- a/src/routes/(app)/send/fund/[...name]/[...amount]/+page.svelte +++ b/src/routes/(app)/send/fund/[...name]/[...amount]/+page.svelte @@ -7,10 +7,11 @@ import { pin } from "$lib/store"; import handler from "$lib/handler"; import { s } from "$lib/utils"; + import { applyAction, deserialize } from "$app/forms"; let { data, form } = $props(); - let { amount } = $state(data); - let { balance, currency } = data.user; + let { amount, user } = $state(data); + let { balance, currency } = $derived(user); let { name, rate } = $derived(data); let loading = $state(); let fiat = $state(); @@ -22,11 +23,22 @@ if (form?.message?.includes("pin")) $pin = undefined; loading = false; }); + let formElement = $state(); - let setMax = (e) => { + let setMax = async (e) => { e.preventDefault(); - fiat = false; - amount = balance; + let body = new FormData(formElement); + body.set("fiat", false); + body.set("amount", user.balance); + + const response = await fetch(formElement.action, { + method: "POST", + body, + }); + + const result = deserialize(await response.text()); + if (result.type === "success") await invalidateAll(); + applyAction(result); }; @@ -39,7 +51,12 @@
-
+ -- cgit v1.2.3