Skip to content

Commit

Permalink
fix: correct formatCurrency when 0
Browse files Browse the repository at this point in the history
  • Loading branch information
newarifrh committed Aug 1, 2024
1 parent 1d33ee0 commit 4eb8368
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/utils/currency.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const formatCurrency = (number: number): string => {
if (!number) return "0";
const parts = number.toFixed(2).toString().split(".");
const formattedInteger = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".");
return `${formattedInteger},${parts[1]}`;
Expand Down

0 comments on commit 4eb8368

Please sign in to comment.