More stripe integration #6649

Closed
mayeaux wants to merge 17 commits from more-stripe-integration into master
Showing only changes of commit a8c79672a1 - Show all commits

View file

@ -313,21 +313,63 @@ function WalletSendTip(props: Props) {
} }
} }
var countDecimals = function(value) {
var text = value.toString();
var index = text.indexOf('.');
return (text.length - index - 1);
}
function handleCustomPriceChange(event: SyntheticInputEvent<*>) { function handleCustomPriceChange(event: SyntheticInputEvent<*>) {
let tipAmount = parseFloat(event.target.value);
// allow maximum two decimalds console.log(event.target.value);
let tipAmountAsString = event.target.value;
let tipAmount = parseFloat(tipAmountAsString);
// allow maximum two decimals
if (activeTab === TAB_FIAT) { if (activeTab === TAB_FIAT) {
tipAmount = Math.round(tipAmount * 100) / 100;
console.log(tipAmount);
console.log(Number.isNaN(tipAmount))
if (Number.isNaN(tipAmount)) {
setCustomTipAmount('');
} }
// TODO: add limit to 4 digits
// can also do setTipError('Maximum 1000') that way
if(tipAmount.length > 5 && tipAmount > 1000){
tipAmount.length = 4
}
const howManyDecimals = countDecimals(tipAmountAsString);
console.log('how many decimals');
console.log(howManyDecimals)
if (howManyDecimals > 2) {
tipAmount = Math.floor(tipAmount * 100) / 100;
// setTipError('Value can only have two decimal places');
}
// else {
// tipAmount = ((tipAmount * 100) / 100).toFixed(2);
// }
// console.log(howManyDecimals);
jessopb commented 2021-07-29 23:45:28 +02:00 (Migrated from github.com)
Review

MAXIMUM_FIAT_TIP

MAXIMUM_FIAT_TIP
jessopb commented 2021-07-29 23:46:10 +02:00 (Migrated from github.com)
Review

repeated text, without i18n

repeated text, without i18n
console.log(tipAmount);
const howManyDigits = Math.trunc(tipAmount).toString().length;
if (howManyDigits > 4 && tipAmount !== 1000) {
setTipError('Value must be below 1000 dollars');
} else if (tipAmount > 1000) {
setTipError('Value must be below 1000 dollars');
setCustomTipAmount(tipAmount); setCustomTipAmount(tipAmount);
} else {
setCustomTipAmount(tipAmount);
}
} else {
setCustomTipAmount(tipAmount);
}
} }
function buildButtonText() { function buildButtonText() {