refactor(format): centralize currency formatters and app constants#144
Merged
greatest0fallt1me merged 1 commit intoJun 19, 2026
Conversation
- Move formatUsdc, formatUsdShortcut to src/utils/format.ts (single source) - Add formatPrice (3-decimal) helper for per-request pricing - Create src/config/constants.ts for EXPLORER_BASE_URL, API_BASE_URL, MIN_DEPOSIT, NETWORK_FEE, PRESET_AMOUNTS, LOADING_DELAY_MS - Remove inline duplicate formatters from App.tsx and ApiUsage.tsx - Remove per-component currency closures from ApiCard.tsx and ApiDetailPage.tsx - Replace hard-coded loading delays with LOADING_DELAY_MS constant - Add Vitest + unit tests for format module (22 tests, 100% coverage) - Fix pre-existing build errors: duplicate Dashboard import, duplicate statusFilter, missing Skeleton import - Update README project layout to document new modules Closes CalloraOrg#138
Contributor
|
yep, the |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #138
Centralizes duplicated currency formatters and scattered magic config values into shared modules, eliminating inline redefinitions across 6 files.
Changes
formatUsdc,formatUsdShortcuttosrc/utils/format.ts(single source of truth)formatPrice(3-decimal) helper for per-request pricingsrc/config/constants.tsforEXPLORER_BASE_URL,API_BASE_URL,MIN_DEPOSIT,NETWORK_FEE,PRESET_AMOUNTS,LOADING_DELAY_MSApp.tsxandApiUsage.tsxcurrencyclosures fromApiCard.tsxandApiDetailPage.tsxLOADING_DELAY_MSconstantDashboardimport, duplicatestatusFilter, missingSkeletonimportVerification
npm run build✅npm run test- 22/22 passed ✅Note on
LOADING_DELAY_MSThe issue asks for a single shared
LOADING_DELAY_MSconstant, but also states that simulated loading durations should remain unchanged. These are slightly contradictory sinceDashboardpreviously used1200mswhileMarketplacePageandApiDetailPageboth used1500ms. I unified all three to1500msto keep a single constant as requested - this means the Dashboard skeleton shows for 300ms longer, which is imperceptible to users. Happy to split into per-component constants if preferred.Closes #138