1
0
Fork 0
mirror of https://github.com/betagouv/mon-entreprise synced 2025-02-08 23:25:02 +00:00
mon-entreprise/source/components/Montant.js
Johan Girod 0e028cc843 wip
2018-08-04 12:11:34 +02:00

38 lines
784 B
JavaScript

/* @flow */
import withLanguage from 'Components/utils/withLanguage'
import React from 'react'
import './Montant.css'
type Props = {
children: number,
className?: string,
type: 'currency' | 'percent',
style?: { [string]: string },
numFractionDigit?: number
} & ConnectedProps
type ConnectedProps = {
language: string
}
const Montant = ({
language,
numFractionDigit = 2,
children: value,
className = '',
type = 'currency',
style = {}
}: Props) => (
<span className={'montant ' + className} style={style}>
{value === 0
? '—'
: Intl.NumberFormat(language, {
style: type,
currency: 'EUR',
maximumFractionDigits: numFractionDigit,
minimumFractionDigits: numFractionDigit
}).format(value)}
</span>
)
export default withLanguage(Montant)