Skip to content

Commit

Permalink
fix(utils price): minimumFractionDigits 0 when whole number
Browse files Browse the repository at this point in the history
  • Loading branch information
shadow81627 committed Apr 28, 2022
1 parent 49e2544 commit 53205ad
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions utils/price.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ export default function price(args) {
const price = cost / (margin || 1);
const nines =
price === 0 || price % 1 !== 0 || margin === 0 ? price : price - 0.01;
const minimumFractionDigits = nines % 1 !== 0 ? 0 : 2;
const maximumSignificantDigits = 3;
return nines.toLocaleString('en-US', {
style: 'currency',
currency,
minimumFractionDigits,
maximumSignificantDigits,
});
}

1 comment on commit 53205ad

@vercel
Copy link

@vercel vercel bot commented on 53205ad Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.