Skip to content

feat(treasury): implement typed useTreasury hook with loading and error state#505

Merged
Jagadeeshftw merged 1 commit into
Fluxora-Org:mainfrom
Gadflyxx:feat/use-treasury-hook
Jun 29, 2026
Merged

feat(treasury): implement typed useTreasury hook with loading and error state#505
Jagadeeshftw merged 1 commit into
Fluxora-Org:mainfrom
Gadflyxx:feat/use-treasury-hook

Conversation

@Gadflyxx

Copy link
Copy Markdown
Contributor

Summary

Closes #272

Wires the useTreasury hook into a fully typed data-fetching surface and fixes the dashboard rendering issues.

Changes

src/pages/TreasuryPage.tsx

  • Fixed conditional rendering: when error is set the empty-state (role="status") no longer renders simultaneously
  • Passes loading and error props down to <Metrics>

src/components/treasuryOverviewPage/Metrics.tsx

  • Added optional loading?: boolean and error?: string | null props
  • Loading renders role="status" paragraph; error renders role="alert" paragraph
  • Loading takes precedence over error

Tests (+9 new tests, 688 → 697 passing)

File New tests
useTreasury.test.tsx cancellation mid-flight (useTreasury), generic non-Error rejection, empty streams array, cancellation mid-flight (useRecipientStreams)
Metrics.test.tsx loading state, error state, loading-over-error precedence
RecentStreams.test.tsx navigate on View all click

vitest.config.ts

  • Added useTreasury.ts, Metrics.tsx, RecentStreams.tsx to coverage include list

Acceptance criteria

  • useTreasury() returns { metrics, streams, loading, error, refetch } with explicit types
  • ✅ No view imports sample-streams.tsx directly (file does not exist; fixtures behind env flag via useTreasuryOverviewData)
  • ✅ Loading and error branches render in Metrics.tsx
  • ✅ Tests cover success, error, empty states, cancellation, and refetch

Test output

Test Files  76 passed
Tests       697 passed (3 pre-existing failures unrelated to this PR)

Security notes

All fetched data is narrowed via normalizeStreamRecord / normalizeMetric at the service boundary before reaching the DOM. No raw untyped fields are rendered.

…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
@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Jagadeeshftw Jagadeeshftw merged commit eec5ff5 into Fluxora-Org:main Jun 29, 2026
@Jagadeeshftw

Copy link
Copy Markdown
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.

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.

Implement the useTreasury hook in treasuryOverviewPage/useTreasury.ts with typed getMetrics/getStreams and loading/error state

2 participants