diff options
| author | Adam Soltys <[email protected]> | 2023-03-29 08:08:41 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-03-29 08:08:41 -0700 |
| commit | f4507d0758c5e3e5e879d70cb1c5dbdbfd2186e8 (patch) | |
| tree | 2b838c3cf248b7d570459f7c5831e864be367a25 /src/components | |
| parent | b51467da14e6a3def3ce12681b5222bf49484cd5 (diff) | |
| download | coinos-ui-f4507d0758c5e3e5e879d70cb1c5dbdbfd2186e8.tar.gz coinos-ui-f4507d0758c5e3e5e879d70cb1c5dbdbfd2186e8.zip | |
currency display
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Lnurlp.svelte | 6 | ||||
| -rw-r--r-- | src/components/Lnurlw.svelte | 5 | ||||
| -rw-r--r-- | src/components/Numpad.svelte | 14 |
3 files changed, 14 insertions, 11 deletions
diff --git a/src/components/Lnurlp.svelte b/src/components/Lnurlp.svelte index ab0c50ce..9918a3f4 100644 --- a/src/components/Lnurlp.svelte +++ b/src/components/Lnurlp.svelte @@ -6,7 +6,9 @@ export let data, form; let { currency } = data.user; - let { minSendable, maxSendable, callback, metadata } = data; + let { minSendable, maxSendable, callback, metadata, rates } = data; + + $: rate = rates[currency]; let amount = Math.round(minSendable / 1000), loading; @@ -33,7 +35,7 @@ </div> {/if} - <Numpad bind:amount {currency} /> + <Numpad bind:amount bind:rate {currency} /> <form action="?/pay" method="POST" use:enhance on:submit={submit}> <input name="amount" value={amount} type="hidden" /> diff --git a/src/components/Lnurlw.svelte b/src/components/Lnurlw.svelte index f2855b53..f780d755 100644 --- a/src/components/Lnurlw.svelte +++ b/src/components/Lnurlw.svelte @@ -7,7 +7,8 @@ export let data, form; let { currency, username } = data.user; - let { defaultDescription, minWithdrawable, maxWithdrawable, k1, callback } = data; + let { defaultDescription, minWithdrawable, maxWithdrawable, k1, callback, rates } = data; + $: rate = rates[currency]; let amount = Math.round(maxWithdrawable / 1000), loading; @@ -28,7 +29,7 @@ </div> {/if} - <Numpad bind:amount {currency} /> + <Numpad bind:amount {currency} bind:rate /> <form action="?/withdraw" method="POST" use:enhance on:submit={submit}> <input name="amount" value={amount} type="hidden" /> diff --git a/src/components/Numpad.svelte b/src/components/Numpad.svelte index 77a4f38b..20bfe561 100644 --- a/src/components/Numpad.svelte +++ b/src/components/Numpad.svelte @@ -7,17 +7,19 @@ export let amount, currency, fiat = !amount, + rate, submit = undefined; export let amountFiat = 0; + let arrow = '<'; $: update(amount, amountFiat); let update = (a, f) => { if (fiat) { - amount = Math.round(f / ($selectedRate / sats)); + amount = Math.round(f / (rate / sats)); } else { - amountFiat = ((a * $selectedRate) / sats).toFixed(2); + amountFiat = ((a * rate) / sats).toFixed(2); } }; @@ -60,7 +62,7 @@ amount = 0; } } - } else if (value !== '.' && value !== '<' && parseInt(amountFiat + value) > $selectedRate) { + } else if (value !== '.' && value !== '<' && parseInt(amountFiat + value) > rate) { warning($t('user.receive.lessThan1BTCWarning')); } else if (amountFiat !== 0 && amountFiat.match(/\.../)) { return; @@ -184,12 +186,10 @@ type="button" on:click={() => { if (fiat) { - amount = parseInt((amountFiat / ($selectedRate / sats)).toFixed(0)); + amount = parseInt((amountFiat / (rate / sats)).toFixed(0)); } else { amountFiat = - (amount * ($selectedRate / sats)).toFixed(2) > 0.0 - ? (amount * ($selectedRate / sats)).toFixed(2) - : 0; + (amount * (rate / sats)).toFixed(2) > 0.0 ? (amount * (rate / sats)).toFixed(2) : 0; } fiat = !fiat; }}><Icon icon="swap" style="inline hover:opacity-80" /></button |
