🔥 Un seul numberFormatter
parent
d2a0904c99
commit
956a8662fe
|
@ -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',
|
||||
|
|
|
@ -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({
|
|||
<b>
|
||||
<Trans>Taux final</Trans> :{' '}
|
||||
</b>
|
||||
{formatNumber(
|
||||
(nodeValue /
|
||||
lazyEval(explanation['assiette']).nodeValue) *
|
||||
100,
|
||||
language
|
||||
)}{' '}
|
||||
<NodeValuePointer
|
||||
data={
|
||||
(nodeValue /
|
||||
lazyEval(explanation['assiette']).nodeValue) *
|
||||
100
|
||||
}
|
||||
/>
|
||||
%
|
||||
</>
|
||||
)}
|
||||
|
@ -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 = ({
|
|||
<td key="tranche">
|
||||
{maxOnly ? (
|
||||
<>
|
||||
<Trans>En-dessous de</Trans> {formatNumber(maxOnly, language)}
|
||||
<Trans>En-dessous de</Trans> {number(maxOnly, language)}
|
||||
</>
|
||||
) : minOnly ? (
|
||||
<>
|
||||
<Trans>Au-dessus de</Trans> {formatNumber(minOnly, language)}
|
||||
<Trans>Au-dessus de</Trans> {number(minOnly, language)}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Trans>De</Trans> {formatNumber(min, language)} <Trans>à</Trans>{' '}
|
||||
{formatNumber(max, language)}
|
||||
<Trans>De</Trans> {number(min, language)} <Trans>à</Trans>{' '}
|
||||
{number(max, language)}
|
||||
</>
|
||||
)}
|
||||
</td>
|
||||
|
|
|
@ -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 }) => (
|
||||
<span
|
||||
className={classnames('situationValue', {
|
||||
|
|
Loading…
Reference in New Issue