fix: ๐Ÿ› lnpay amounts

This commit is contained in:
Anthony Potdevin 2020-11-23 19:41:59 +01:00
parent 6478308ad4
commit c61296b82f
No known key found for this signature in database
GPG key ID: 4403F1DFBE779457
2 changed files with 24 additions and 30 deletions

View file

@ -112,25 +112,23 @@ export const LnPay: FC<LnPayProps> = ({ request }) => {
amount={amount}
value={amount}
inputType={'number'}
inputCallback={value => {
if (min && max) {
setAmount(Math.min(max, Math.max(min, Number(value))));
} else if (min && !max) {
setAmount(Math.max(min, Number(value)));
} else if (!min && max) {
setAmount(Math.min(max, Number(value)));
} else {
setAmount(Number(value));
}
}}
inputCallback={value => setAmount(Number(value))}
/>
)}
<ColorButton
loading={loading}
disabled={loading}
disabled={loading || !amount}
fullWidth={true}
withMargin={'16px 0 0'}
onClick={() => payLnUrl({ variables: { callback, amount, comment } })}
onClick={() => {
if (min && amount < min) {
toast.warning('Amount is below the minimum');
} else if (max && amount > max) {
toast.warning('Amount is above the maximum');
} else {
payLnUrl({ variables: { callback, amount, comment } });
}
}}
>
{`Pay (${amount} sats)`}
</ColorButton>

View file

@ -138,29 +138,25 @@ export const LnWithdraw: FC<LnWithdrawProps> = ({ request }) => {
amount={amount}
value={amount}
inputType={'number'}
inputCallback={value => {
if (min && max) {
setAmount(Math.min(max, Math.max(min, Number(value))));
} else if (min && !max) {
setAmount(Math.max(min, Number(value)));
} else if (!min && max) {
setAmount(Math.min(max, Number(value)));
} else {
setAmount(Number(value));
}
}}
inputCallback={value => setAmount(Number(value))}
/>
)}
<ColorButton
loading={loading || statusLoading}
disabled={loading || !k1 || statusLoading}
disabled={loading || !k1 || statusLoading || !amount}
fullWidth={true}
withMargin={'16px 0 0'}
onClick={() =>
withdraw({
variables: { callback, amount, k1: k1 || '', description },
})
}
onClick={() => {
if (min && amount < min) {
toast.warning('Amount is below the minimum');
} else if (max && amount > max) {
toast.warning('Amount is above the maximum');
} else {
withdraw({
variables: { callback, amount, k1: k1 || '', description },
});
}
}}
>
{`Withdraw (${amount} sats)`}
</ColorButton>