diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/app.css | 2 | ||||
| -rw-r--r-- | src/routes/(app)/send/invoice/[id]/+page.server.ts | 6 | ||||
| -rw-r--r-- | src/routes/(app)/send/invoice/[id]/+page.svelte | 35 |
3 files changed, 16 insertions, 27 deletions
diff --git a/src/app.css b/src/app.css index a366e177..364668b6 100644 --- a/src/app.css +++ b/src/app.css @@ -41,7 +41,7 @@ input, textarea, select, .input { @apply w-full rounded-2xl; } -.input:focus, .input:focus-within { +textarea:focus, textarea:focus-within, .input:focus, .input:focus-within, .btn:focus, .btn:focus-within { @apply outline-offset-0; } diff --git a/src/routes/(app)/send/invoice/[id]/+page.server.ts b/src/routes/(app)/send/invoice/[id]/+page.server.ts index 2b10b375..2798a234 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.server.ts +++ b/src/routes/(app)/send/invoice/[id]/+page.server.ts @@ -13,8 +13,10 @@ export async function load({ cookies, params: { id }, parent }) { if (invoice.memoPrompt && invoice.memo === null) redirect(307, `/invoice/${id}/memo`); - if (user && invoice.aid === aid) error(500, { message: "Cannot send to self" }); - else if (user && invoice.type !== types.lightning) redirect(307, `/send/${invoice.type}/${invoice.hash}`); + if (user && invoice.aid === aid) + error(500, { message: "Cannot send to self" }); + else if (user && invoice.type !== types.lightning) + redirect(307, `/send/${invoice.type}/${invoice.hash}`); if (!user) redirect(307, `/invoice/${id}`); diff --git a/src/routes/(app)/send/invoice/[id]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte index 9f3a008b..57f33f24 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.svelte +++ b/src/routes/(app)/send/invoice/[id]/+page.svelte @@ -1,5 +1,5 @@ <script> - import { run } from 'svelte/legacy'; + import { run } from "svelte/legacy"; import handler from "$lib/handler"; import { onDestroy, onMount } from "svelte"; @@ -29,25 +29,22 @@ let { address, hash, payreq, user: recipient, tip } = $state(invoice); let { currency } = $state(user); - let reload = (data) => { - ({ invoice, rates, user } = data); - ({ address, hash, payreq, user: recipient, tip } = invoice); - ({ currency } = user); - }; - - let amount = $state(form?.amount || invoice.amount); + let rate = $derived( + invoice.rate * (rates[user.currency] / rates[invoice.currency]), + ); let a = $state(), af = $state(), - amountFiat = amount * (rate / sats), fiat = $state(!amount); + let amountFiat = $state(amount * (rate / sats)); let setAmount = () => { amount = a; amountFiat = af; }; - let submit = $state(), submitting = $state(); + let submit = $state(), + submitting = $state(); let toggle = () => (submitting = !submitting); let external = async () => { @@ -66,10 +63,10 @@ }); }; - let update = () => { + $effect(() => { if (form?.message?.includes("pin")) $pin = undefined; submitting = false; - }; + }); // onMount(async () => { // if (browser && window.NDEFReader && user.nfc) { @@ -89,16 +86,6 @@ // } // } // }); - run(() => { - reload(data); - }); - let rate; - run(() => { - rate = invoice.rate * (rates[user.currency] / rates[invoice.currency]); - }); - run(() => { - update(form); - }); </script> {#if form?.message} @@ -167,9 +154,9 @@ <Numpad bind:amount={a} bind:amountFiat={af} - {currency} bind:fiat - bind:rate + {currency} + {rate} {submit} /> {/if} |
