aboutsummaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-21 17:05:30 -0800
committerAdam Soltys <[email protected]>2023-02-21 17:05:30 -0800
commitf9d76e8846c27d9eeb3959c3b77d91d9e444bcc0 (patch)
treef0f59e32147831beeae6266bbc60952f54a7644a /src/components
parentdd94f1ee35e2204a27975846a990a2fa6dc629a3 (diff)
downloadcoinos-ui-f9d76e8846c27d9eeb3959c3b77d91d9e444bcc0.tar.gz
coinos-ui-f9d76e8846c27d9eeb3959c3b77d91d9e444bcc0.zip
max send button
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Numpad.svelte30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/components/Numpad.svelte b/src/components/Numpad.svelte
index 3647914e..47bd9375 100644
--- a/src/components/Numpad.svelte
+++ b/src/components/Numpad.svelte
@@ -57,7 +57,7 @@
amountFiat = amountFiat.slice(0, amountFiat.length - 1);
if (amountFiat.length === 0) {
amountFiat = 0;
- amountSats = 0;
+ amount = 0;
}
}
} else if (value !== '.' && value !== '<' && parseInt(amountFiat + value) > $selectedRate) {
@@ -70,25 +70,27 @@
} else {
if (value === '.') {
return;
- } else if (!amountSats && value !== '<' && value !== '0') {
- amountSats = parseInt(value);
+ } else if (!amount && value !== '<' && value !== '0') {
+ amount = parseInt(value);
} else if (value === '<') {
- if (amountSats !== 0) {
- amountSats = Math.floor(amountSats / 10);
- if (amountSats.length === 0) {
- amountSats = 0;
+ if (amount !== 0) {
+ amount = Math.floor(amount / 10);
+ if (amount.length === 0) {
+ amount = 0;
amountFiat = 0;
}
}
- } else if (value !== '<' && parseInt(amountSats + value) > sats) {
+ } else if (value !== '<' && parseInt(amount + value) > sats) {
warning($t('user.receive.lessThan1BTCWarning'));
} else {
+ console.log('CLICK', amount.toString(), value);
amount = parseInt(amount.toString() + value);
+ console.log('AMOUNT', amount);
}
}
};
- $: html = fiat ? amountFiat : s(amountSats);
+ $: html = fiat ? amountFiat : s(amount);
let prev = '';
@@ -123,10 +125,10 @@
if (fiat) {
amountFiat = html;
} else {
- amountSats = parseInt(html.replace(/,/g, ''));
+ amount = parseInt(html.replace(/,/g, ''));
}
- if (!amountSats) amountSats = null;
+ if (!amount) amount = null;
setTimeout(() => {
if (!fiat) {
@@ -182,11 +184,11 @@
type="button"
on:click={() => {
if (fiat) {
- amountSats = parseInt((amountFiat / ($selectedRate / sats)).toFixed(0));
+ amount = parseInt((amountFiat / ($selectedRate / sats)).toFixed(0));
} else {
amountFiat =
- (amountSats * ($selectedRate / sats)).toFixed(2) > 0.0
- ? (amountSats * ($selectedRate / sats)).toFixed(2)
+ (amount * ($selectedRate / sats)).toFixed(2) > 0.0
+ ? (amount * ($selectedRate / sats)).toFixed(2)
: 0;
}
fiat = !fiat;