diff options
| author | Adam Soltys <[email protected]> | 2025-07-08 02:09:42 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-07-08 02:09:42 -0700 |
| commit | 888aa32a1467fa752ff543149470d3275c7e8915 (patch) | |
| tree | 7390f452df15a40d947093c01aaf4f2d01166910 /src/routes/(app)/send | |
| parent | 0c82af33cc5f315e71f38074750b534534836d7f (diff) | |
| download | coinos-ui-888aa32a1467fa752ff543149470d3275c7e8915.tar.gz coinos-ui-888aa32a1467fa752ff543149470d3275c7e8915.zip | |
sweep success
Diffstat (limited to 'src/routes/(app)/send')
| -rw-r--r-- | src/routes/(app)/send/fund/[...name]/[...amount]/+page.svelte | 29 |
1 files changed, 23 insertions, 6 deletions
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); }; </script> @@ -39,7 +51,12 @@ <div class="container px-4 mt-20 max-w-xl mx-auto"> <Numpad bind:amount {currency} {rate} {fiat} {submit} /> - <form use:enhance={handler(toggle)} method="POST" class="space-y-5"> + <form + use:enhance={handler(toggle)} + method="POST" + class="space-y-5" + bind:this={formElement} + > <input name="fund" value={name} type="hidden" /> <input name="amount" value={amount} type="hidden" /> <input name="pin" value={$pin} type="hidden" /> |
