Merge pull request #296 from dod-ccpo/ie/fix-toggler

Ie/fix toggler
This commit is contained in:
andrewdds
2018-09-18 12:01:51 -04:00
committed by GitHub
7 changed files with 151 additions and 11 deletions

View File

@@ -1,4 +1,11 @@
export const formatDollars = value => `$${value.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')}`
export const formatDollars = (value, cents = true) => {
if (typeof value === 'number') {
return cents
? `$${value.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')}`
: `$${value.toFixed(0).replace(/\d(?=(\d{3})+(?!\d))/g, '$&,')}`
}
return ''
}
export const abbreviateDollars = (value, decimals = 1) => {
if (value === null) { return null } // terminate early