diff --git a/source/components/Value.js b/source/components/Value.js index 67d02aa38..8831c6258 100644 --- a/source/components/Value.js +++ b/source/components/Value.js @@ -8,7 +8,10 @@ const NumberFormat = memoizeWith( Intl.NumberFormat ) -let numberFormatter = (style, numFractionDigits = 2) => (value, language) => +export let numberFormatter = (style, numFractionDigits = 2) => ( + value, + language +) => NumberFormat(language, { style, currency: 'EUR', diff --git a/source/engine/mecanismViews/Barème.js b/source/engine/mecanismViews/Barème.js index dd781f2bc..dcb9a90cf 100644 --- a/source/engine/mecanismViews/Barème.js +++ b/source/engine/mecanismViews/Barème.js @@ -7,7 +7,8 @@ import React from 'react' import { Trans } from 'react-i18next' import { makeJsx } from '../evaluation' import './Barème.css' -import { formatNumber, Node, NodeValuePointer } from './common' +import { Node, NodeValuePointer } from './common' +import { numberFormatter } from 'Components/Value' export let BarèmeAttributes = ({ explanation, lazyEval = identity }) => ( <> @@ -96,12 +97,13 @@ let Component = withLanguage(function Barème({ Taux final :{' '} - {formatNumber( - (nodeValue / - lazyEval(explanation['assiette']).nodeValue) * - 100, - language - )}{' '} + % )} @@ -113,6 +115,8 @@ let Component = withLanguage(function Barème({ ) }) +let number = numberFormatter(undefined, 0) + let Tranche = ({ tranche: { 'en-dessous de': maxOnly, @@ -132,16 +136,16 @@ let Tranche = ({ {maxOnly ? ( <> - En-dessous de {formatNumber(maxOnly, language)} + En-dessous de {number(maxOnly, language)} ) : minOnly ? ( <> - Au-dessus de {formatNumber(minOnly, language)} + Au-dessus de {number(minOnly, language)} ) : ( <> - De {formatNumber(min, language)} à{' '} - {formatNumber(max, language)} + De {number(min, language)} à{' '} + {number(max, language)} )} diff --git a/source/engine/mecanismViews/common.js b/source/engine/mecanismViews/common.js index d951424b3..11853fbd7 100644 --- a/source/engine/mecanismViews/common.js +++ b/source/engine/mecanismViews/common.js @@ -13,12 +13,6 @@ import mecanismColours from './colours' import classnames from 'classnames' import Value from 'Components/Value' -//TODO remove this one, it should reside in 'Value.js' -export let formatNumber = (data, language) => - !isNaN(data) - ? Intl.NumberFormat(language, { maximumFractionDigits: 4 }).format(data) - : data - export let NodeValuePointer = ({ data, unit }) => (