import React from 'react' ; import { AppState } from '../../reducers' ; import { connect } from 'react-redux' ; import { Tooltip } from '@material-ui/core' ; function NumberFormatter ( props ) { let formatter ; const formatterOptions = { useGrouping : Boolean ( props . grouping ) } ; const defaultFormatter = Intl . NumberFormat ( undefined , formatterOptions ) ; try { formatter = Intl . NumberFormat ( props . locale , formatterOptions ) ; } catch { } try { const formatted = ( formatter || defaultFormatter ) . format ( props . value ) ; return ( < Tooltip title = { props . value } > < span > { formatted } < /span> < /Tooltip>); } catch { } return < span > props . value < /span>; } const mapStateToProps = ( state ) => { return { locale : state . settings . get ( 'timeLocale' ) , } ; } ; export default connect ( mapStateToProps ) ( NumberFormatter ) ;