Skip to content

Commit

Permalink
fix: 🐛 lnpay amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
apotdevin committed Nov 23, 2020
1 parent 6478308 commit c61296b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 30 deletions.
24 changes: 11 additions & 13 deletions src/views/home/quickActions/lnurl/LnPay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
30 changes: 13 additions & 17 deletions src/views/home/quickActions/lnurl/LnWithdraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit c61296b

Please sign in to comment.