automatically truncate to two decimals

This commit is contained in:
Anthony 2021-07-25 23:58:32 +02:00
parent f4d8de2ac6
commit 96fc536547
No known key found for this signature in database
GPG key ID: C386D3C93D50E356

View file

@ -314,7 +314,18 @@ function WalletSendTip(props: Props) {
} }
function handleCustomPriceChange(event: SyntheticInputEvent<*>) { function handleCustomPriceChange(event: SyntheticInputEvent<*>) {
const tipAmount = parseFloat(event.target.value); let tipAmount = parseFloat(event.target.value);
// allow maximum two decimalds
if (activeTab === TAB_FIAT) {
tipAmount = Math.round(tipAmount * 100) / 100;
}
// TODO: add limit to 4 digits
// can also do setTipError('Maximum 1000') that way
if(tipAmount.length > 5 && tipAmount > 1000){
tipAmount.length = 4
}
setCustomTipAmount(tipAmount); setCustomTipAmount(tipAmount);
} }