diff --git a/src/const/CustomFunc.js b/src/const/CustomFunc.js index 0fec461..808b6d4 100644 --- a/src/const/CustomFunc.js +++ b/src/const/CustomFunc.js @@ -285,7 +285,17 @@ export const formatThousand = (x) => { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."); } - +export const formatLargeNumber = (num) => { + const formattedNum = formatThousand(num); + if (num >= 1000000000000) { + return `${(num / 1000000000000).toFixed(1)}T`; + } else if (num >= 1000000000) { + return `${(num / 1000000000).toFixed(1)}M`; + } else if (num >= 1000000) { + return `${(num / 1000000).toFixed(1)}Jt`; + } + return formattedNum; +}; /* Using it: sortBy(data, {