Skip to content

feat(ui): standardize fiat currency formatting with Intl.NumberFormat - #123

Merged
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
David-282:fix/standardize-currency-formatting
Jul 30, 2026
Merged

feat(ui): standardize fiat currency formatting with Intl.NumberFormat#123
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
David-282:fix/standardize-currency-formatting

Conversation

@David-282

Copy link
Copy Markdown
Contributor

Description

This PR replaces manual string concatenation (e.g., "$" + .toFixed()) and ad-hoc formatting helpers with a central, locale-aware formatCurrency utility powered by the native Intl.NumberFormat API.

Linked Issue

Closes #114

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • UI/UX improvement
  • Performance improvement
  • Code refactoring

Summary of Changes

  • Added Unit Tests (src/utils/format.test.ts): Created test coverage verifying grouping separators (commas), edge cases (< $0.01), zero handling, custom currencies, and safe fallbacks for null/undefined/NaN inputs.
  • Refactored Protocol Stats (components/dashboard/ProtocolStatsBar.tsx): Removed the duplicate inline string formatting function and migrated the component to use the shared formatCurrency utility.
  • Standardized Currency Formatting (src/utils/format.ts): Enforced SSR-safe locale detection, strict 2-decimal fiat formatting, and proper number grouping across the application.

Test Evidence

Ran local testing suite and TypeScript validation:

npm run lint
npm run typecheck
npm run test

@Lakes41
Lakes41 merged commit f90a47c into Adamantine-guild:main Jul 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add internationalized number formatting (Intl.NumberFormat) for fiat values

2 participants