diff options
Diffstat (limited to 'src/routes/(app)')
| -rw-r--r-- | src/routes/(app)/send/bitcoin/[address]/+page.svelte | 13 | ||||
| -rw-r--r-- | src/routes/(app)/send/invoice/[id]/+page.server.ts | 5 | ||||
| -rw-r--r-- | src/routes/(app)/send/invoice/[id]/+page.svelte | 30 |
3 files changed, 34 insertions, 14 deletions
diff --git a/src/routes/(app)/send/bitcoin/[address]/+page.svelte b/src/routes/(app)/send/bitcoin/[address]/+page.svelte index 09caaa85..060473ec 100644 --- a/src/routes/(app)/send/bitcoin/[address]/+page.svelte +++ b/src/routes/(app)/send/bitcoin/[address]/+page.svelte @@ -1,6 +1,4 @@ <script> - import { run, preventDefault } from 'svelte/legacy'; - import { t } from "$lib/translations"; import Icon from "$comp/Icon.svelte"; import Numpad from "$comp/Numpad.svelte"; @@ -16,16 +14,13 @@ let amount = $state(0); let submit = $state(), fiat = $state(); + $effect(() => ($rate = data.rate)); - let update = () => ($rate = data.rate); - - let setMax = () => { + let setMax = (e) => { + e.preventDefault(); fiat = false; amount = balance; }; - run(() => { - update(data); - }); </script> <div class="container px-4 max-w-xl mx-auto space-y-5 text-center"> @@ -39,7 +34,7 @@ <button type="button" class="btn !w-auto grow" - onclick={preventDefault(setMax)} + onclick={setMax} onkeydown={setMax}>Max ⚡️{s(balance)}</button > diff --git a/src/routes/(app)/send/invoice/[id]/+page.server.ts b/src/routes/(app)/send/invoice/[id]/+page.server.ts index 6cacc1c6..c78ba008 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.server.ts +++ b/src/routes/(app)/send/invoice/[id]/+page.server.ts @@ -3,8 +3,8 @@ import { auth, fd, get, post, types } from "$lib/utils"; import { error, redirect } from "@sveltejs/kit"; export async function load({ cookies, params: { id }, parent }) { - const aid = cookies.get("aid"); const { user } = await parent(); + const aid = cookies.get("aid") || user.id; const invoice = await get(`/invoice/${id}`); @@ -24,8 +24,9 @@ export async function load({ cookies, params: { id }, parent }) { const rates = await getRates(); const rate = rates[user.currency]; const invoiceRate = rates[invoice.currency]; + const { balance } = await get(`/account/${aid}`, auth(cookies)); - return { invoice, user, rate, invoiceRate }; + return { balance, invoice, user, rate, invoiceRate }; } export const actions = { diff --git a/src/routes/(app)/send/invoice/[id]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte index 5a446dbb..7d167f41 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.svelte +++ b/src/routes/(app)/send/invoice/[id]/+page.svelte @@ -12,10 +12,21 @@ import Numpad from "$comp/Numpad.svelte"; import Spinner from "$comp/Spinner.svelte"; import { page } from "$app/stores"; - import { btc, sat, post, back, f, toFiat, s, sats, focus, loc } from "$lib/utils"; + import { + btc, + sat, + post, + back, + f, + toFiat, + s, + sats, + focus, + loc, + } from "$lib/utils"; let { data, form } = $props(); - let { invoice, user } = $state(data); + let { balance, invoice, user } = $state(data); let { address, hash, payreq, user: recipient, tip } = $state(invoice); let { currency } = $derived(user); let locale = $derived(loc(user)); @@ -76,6 +87,12 @@ // } // } // }); + + let setMax = (e) => { + e.preventDefault(); + fiat = false; + amount = balance; + }; </script> {#if form?.message} @@ -157,9 +174,16 @@ </button> {:else} <button + type="button" + class="btn !w-auto grow" + onclick={setMax} + onkeydown={setMax}>Max ⚡️{s(balance)}</button + > + + <button bind:this={submit} type="button" - class="btn !w-auto" + class="btn btn-accent !w-auto grow" onclick={setAmount} > {$t("payments.next")} |
