aboutsummaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-18 20:19:47 -0800
committerAdam Soltys <[email protected]>2023-02-21 16:47:56 -0800
commitc6bcdfc1bf705acd5379ead810b605a4e799d59f (patch)
tree7728061be451b17681016bdcc6aca921ad57df9c /src/components
parent714d7b840533e35184ca27ae3fe3f5decff9a4eb (diff)
downloadcoinos-ui-c6bcdfc1bf705acd5379ead810b605a4e799d59f.tar.gz
coinos-ui-c6bcdfc1bf705acd5379ead810b605a4e799d59f.zip
numpad cleanup
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Numpad.svelte25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/components/Numpad.svelte b/src/components/Numpad.svelte
index 5ffaa2ea..3647914e 100644
--- a/src/components/Numpad.svelte
+++ b/src/components/Numpad.svelte
@@ -9,11 +9,18 @@
fiat = !amount,
submit = undefined;
- export let amountFiat = amount ? amount * ($selectedRate / sats) : 0;
-
+ let amountFiat = 0;
let arrow = '<';
- let amountSats = amount;
+ $: update(amount, amountFiat);
+ let update = (a, f) => {
+ if (fiat) {
+ amount = Math.round(f / ($selectedRate / sats));
+ } else {
+ amountFiat = ((a * $selectedRate) / sats).toFixed(2);
+ }
+ };
+
let loading = false;
let symbol =
@@ -33,14 +40,6 @@
KRW: '₩'
}[currency] || '';
- $: amount = parseInt(fiat ? Math.round(amountFiat / ($selectedRate / sats)) : amountSats);
-
- $: amountSatsFormatted = s(amountSats);
-
- $: amountFiatConverted = f(amountSats * ($selectedRate / sats), currency);
-
- $: amountSatsConverted = sat(amountFiat / ($selectedRate / sats));
-
const numPad = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '0', '<'];
const handleInput = (value) => {
@@ -84,7 +83,7 @@
} else if (value !== '<' && parseInt(amountSats + value) > sats) {
warning($t('user.receive.lessThan1BTCWarning'));
} else {
- amountSats = parseInt(amountSats + value);
+ amount = parseInt(amount.toString() + value);
}
}
};
@@ -178,7 +177,7 @@
/>
</div>
<div class="mt-2">
- <span class="text-secondary mr-1">{fiat ? amountSatsConverted : amountFiatConverted}</span>
+ <span class="text-secondary mr-1">{fiat ? sat(amount) : f(amountFiat, currency)}</span>
<button
type="button"
on:click={() => {