Skip to content

Feat/adoption approvals hook#299

Open
Mitch5000 wants to merge 5 commits intoamina69:mainfrom
Mitch5000:feat/adoption-approvals-hook
Open

Feat/adoption approvals hook#299
Mitch5000 wants to merge 5 commits intoamina69:mainfrom
Mitch5000:feat/adoption-approvals-hook

Conversation

@Mitch5000
Copy link
Copy Markdown

Hook to fetch and monitor adoption approval state.

What it does

  • Fetches GET /adoption/:id/approvals
  • Polls every 30s while quorumMet is false
  • Stops polling once quorum reached
  • Returns {required, given, pending, quorumMet, escrowAccountId, isLoading, isError}

Included

Mitch5000 added 4 commits March 29, 2026 19:49
…-party approval UI

- Create PendingApprovalBadge component showing pending approval count
- Integrate badge into Navbar on Approvals nav link
- Add approvalService with GET /shelter/approvals endpoint
- Implement usePendingApprovals hook with 5-minute polling
- Create ApprovalsPage for managing pending approvals
- Add comprehensive unit tests (32 total):
  * PendingApprovalBadge component tests (9)
  * usePendingApprovals hook tests (8)
  * approvalService tests (6)
  * Navbar integration tests (9)
  * ApprovalsPage tests (10)

Features:
- Red badge displaying pending approval count
- '9+' display cap for counts above 9
- Role-based visibility (SHELTER & ADMIN only)
- Badge auto-hides when count reaches 0
- Real-time polling every 5 minutes
- Loading, error, and forbidden states
- Type-safe API responses
- Full error handling
- Added AdoptionApprovalsState and ApprovalParty types to adoption.ts
- Created adoptionApprovalsService with getAdoptionApprovals method
- Implemented useAdoptionApprovals hook with:
  * Fetches from GET /adoption/:id/approvals endpoint
  * Returns {required, given, pending, quorumMet, escrowAccountId, isLoading, isError}
  * Polls every 30s while quorumMet is false
  * Stops polling once quorum is reached
  * Stale time set to 30 seconds

- Added MSW handlers with pre-quorum and post-quorum mock shapes:
  * adoption-pending: shows 3 required, 1 given, 2 pending, quorumMet: false
  * adoption-approved: shows 3 required, 3 given, 0 pending, quorumMet: true

- Added comprehensive unit tests (18 total):
  * useAdoptionApprovals hook tests (12 tests)
  * adoptionApprovalsService tests (6 tests)
  * Covers polling behavior, quorum state transitions, error handling
  * Tests verify polling stops when quorumMet becomes true
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 29, 2026

@Mitch5000 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

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.

Frontend · Multi-party approval UI] Create useAdoptionApprovals hook

1 participant