Revert "fix: formatCredits on large numbers"
This reverts commit 0090f195eb
.
This commit is contained in:
parent
b09e1699eb
commit
9919a81509
2 changed files with 18 additions and 12 deletions
14
dist/bundle.es.js
vendored
14
dist/bundle.es.js
vendored
|
@ -2093,12 +2093,18 @@ const makeSelectMyStreamUrlsForPage = (page = 1) => reselect.createSelector(sele
|
|||
|
||||
const selectMyStreamUrlsCount = reselect.createSelector(selectMyClaimUrisWithoutChannels, channels => channels.length);
|
||||
|
||||
function numberWithCommas(x) {
|
||||
var parts = x.toString().split('.');
|
||||
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
return parts.join('.');
|
||||
}
|
||||
|
||||
function formatCredits(amount, precision, shortFormat = false) {
|
||||
let actualAmount = parseFloat(amount);
|
||||
let actualPrecision = parseFloat(precision);
|
||||
let suffix = '';
|
||||
|
||||
if (!amount || Number.isNaN(actualAmount) || actualAmount === 0) return '0';
|
||||
if (Number.isNaN(actualAmount) || actualAmount === 0) return '0';
|
||||
|
||||
if (actualAmount >= 1000000) {
|
||||
if (precision <= 7) {
|
||||
|
@ -2120,11 +2126,7 @@ function formatCredits(amount, precision, shortFormat = false) {
|
|||
}
|
||||
}
|
||||
|
||||
const number = actualAmount.toString().replace(/\.*0+$/, '');
|
||||
|
||||
return new Intl.NumberFormat('en-IN', {
|
||||
maximumSignificantDigits: actualPrecision >= 0 ? actualPrecision : 1
|
||||
}).format(number) + suffix;
|
||||
return numberWithCommas(actualAmount.toFixed(actualPrecision >= 0 ? actualPrecision : 1).replace(/\.*0+$/, '')) + suffix;
|
||||
}
|
||||
|
||||
function formatFullPrice(amount, precision = 1) {
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
function numberWithCommas(x) {
|
||||
var parts = x.toString().split('.');
|
||||
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
return parts.join('.');
|
||||
}
|
||||
|
||||
export function formatCredits(amount, precision, shortFormat = false) {
|
||||
let actualAmount = parseFloat(amount);
|
||||
let actualPrecision = parseFloat(precision);
|
||||
let suffix = '';
|
||||
|
||||
if (!amount || Number.isNaN(actualAmount) || actualAmount === 0) return '0';
|
||||
if (Number.isNaN(actualAmount) || actualAmount === 0) return '0';
|
||||
|
||||
if (actualAmount >= 1000000) {
|
||||
if (precision <= 7) {
|
||||
|
@ -25,12 +31,10 @@ export function formatCredits(amount, precision, shortFormat = false) {
|
|||
}
|
||||
}
|
||||
|
||||
const number = actualAmount.toString().replace(/\.*0+$/, '');
|
||||
|
||||
return (
|
||||
new Intl.NumberFormat('en-IN', {
|
||||
maximumSignificantDigits: actualPrecision >= 0 ? actualPrecision : 1,
|
||||
}).format(number) + suffix
|
||||
numberWithCommas(
|
||||
actualAmount.toFixed(actualPrecision >= 0 ? actualPrecision : 1).replace(/\.*0+$/, '')
|
||||
) + suffix
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue