diff --git a/frontend/src/utils/formatters.js b/frontend/src/utils/formatters.js index 78ed0e0e6..ebcdaeef6 100644 --- a/frontend/src/utils/formatters.js +++ b/frontend/src/utils/formatters.js @@ -7,9 +7,14 @@ import { ROLES_BADGE_SIZE } from '@/constants/common' * @param {Object|number|string|null} params - The input parameter which can be an object with a `value` property, a number, or a string. * @param {number|string} [params.value] - The value to be formatted, if params is an object. * @param {boolean} [useParentheses=false] - Whether to use parentheses for negative numbers. + * @param maxDecimals the max number of decimals to return * @returns {string} - The formatted number as a string, or the original value if it cannot be parsed as a number. */ -export const numberFormatter = (params, useParentheses = false) => { +export const numberFormatter = ( + params, + useParentheses = false, + maxDecimals = 10 +) => { if (params == null || (typeof params === 'object' && params.value == null)) return '' @@ -21,7 +26,7 @@ export const numberFormatter = (params, useParentheses = false) => { const absValue = Math.abs(parsedValue) const formattedValue = absValue.toLocaleString(undefined, { minimumFractionDigits: 0, - maximumFractionDigits: 10 + maximumFractionDigits: maxDecimals }) if (parsedValue < 0) { diff --git a/frontend/src/views/ComplianceReports/components/SummaryTable.jsx b/frontend/src/views/ComplianceReports/components/SummaryTable.jsx index 0077e5bde..952b918ee 100644 --- a/frontend/src/views/ComplianceReports/components/SummaryTable.jsx +++ b/frontend/src/views/ComplianceReports/components/SummaryTable.jsx @@ -194,7 +194,8 @@ const SummaryTable = ({ {row.format && colIndex !== 0 ? rowFormatters[row.format]( row[column.id], - useParenthesis + useParenthesis, + 0 ) : row[column.id]}