Update dollars filter and formatDollars() to display cent values
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
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 value.toLocaleString('us-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
})
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
Reference in New Issue
Block a user