feat(treasury): implement typed useTreasury hook with loading and error state#505
Merged
Merged
Conversation
…or state - Fix TreasuryPage error branch suppressing empty-state correctly - Add loading/error props to Metrics.tsx with dedicated render branches - Expand useTreasury tests: cancellation, generic error fallback, empty streams, non-Error rejection, serializeFilters no-filter path - Expand Metrics tests: loading state, error state, precedence - Expand RecentStreams test: View all click coverage - Add useTreasury.ts, Metrics.tsx, RecentStreams.tsx to coverage include Closes Fluxora-Org#272
|
@Gadflyxx Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
a typed useTreasury hook with explicit loading and error states is a much cleaner interface than ad-hoc data fetching in the component. co-locating the loading/error handling in one place also makes it straightforward to add caching or retry logic later. nice structured addition. |
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.
Summary
Closes #272
Wires the
useTreasuryhook into a fully typed data-fetching surface and fixes the dashboard rendering issues.Changes
src/pages/TreasuryPage.tsxerroris set the empty-state (role="status") no longer renders simultaneouslyloadinganderrorprops down to<Metrics>src/components/treasuryOverviewPage/Metrics.tsxloading?: booleananderror?: string | nullpropsrole="status"paragraph; error rendersrole="alert"paragraphTests (+9 new tests, 688 → 697 passing)
useTreasury.test.tsxMetrics.test.tsxRecentStreams.test.tsxvitest.config.tsuseTreasury.ts,Metrics.tsx,RecentStreams.tsxto coverageincludelistAcceptance criteria
useTreasury()returns{ metrics, streams, loading, error, refetch }with explicit typessample-streams.tsxdirectly (file does not exist; fixtures behind env flag viauseTreasuryOverviewData)Metrics.tsxTest output
Security notes
All fetched data is narrowed via
normalizeStreamRecord/normalizeMetricat the service boundary before reaching the DOM. No raw untyped fields are rendered.