Skip to content

Commit

Permalink
Peter/refactor usd price formatting (#1553)
Browse files Browse the repository at this point in the history
* chore: update monetary to latest 0.7.3

* refactor: show 3 decimal places in usd price if amount is below 1 cent
  • Loading branch information
peterslany authored Sep 6, 2023
1 parent 1f80570 commit 9e6ee51
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/common/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ const formatUSD = (amount: number, options?: { compact?: boolean }): string => {
const { format } = new Intl.NumberFormat(undefined, {
style: 'currency',
currency: 'USD',
notation: options?.compact ? getFormatUSDNotation(amount) : undefined
notation: options?.compact ? getFormatUSDNotation(amount) : undefined,
minimumFractionDigits: amount > 0 && amount < 0.01 ? 3 : undefined
});

return format(amount);
Expand Down
3 changes: 2 additions & 1 deletion src/component-library/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const formatUSD = (amount: number, options?: { compact?: boolean }): string => {
const { format } = new Intl.NumberFormat(undefined, {
style: 'currency',
currency: 'USD',
notation: options?.compact ? getFormatUSDNotation(amount) : undefined
notation: options?.compact ? getFormatUSDNotation(amount) : undefined,
minimumFractionDigits: amount > 0 && amount < 0.01 ? 3 : undefined
});

return format(amount);
Expand Down

2 comments on commit 9e6ee51

@vercel
Copy link

@vercel vercel bot commented on 9e6ee51 Sep 6, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 9e6ee51 Sep 6, 2023

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.