aboutsummaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Lnurlp.svelte6
-rw-r--r--src/components/Lnurlw.svelte5
-rw-r--r--src/components/Numpad.svelte14
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