Difficulty: Advanced
Type: feature
Background
POST /v1/members/:address/roles is a Bearer-authenticated admin mutation (per the Live API endpoints table) that assigns a role to a member, and the app already uses React Query for data fetching/mutations.
Problem
Role assignment currently likely waits for the network round-trip before updating the UI (or, if optimistic, has no visible history of who changed what and when), and any failure handling/rollback behavior isn't documented — admins have no way to see a history of role changes made through the dashboard.
Expected outcome
Assigning a role updates the UI immediately (optimistic update via React Query's onMutate), automatically rolls back cleanly on failure (including on a 401 that isn't resolved by the auto-retry flow), and a local "recent changes" panel shows a short audit trail (who/what/when) of role changes made in the current admin session.
Suggested implementation
- Implement the mutation with React Query's optimistic update pattern: snapshot the previous member/role state in
onMutate, apply the optimistic change, and roll back in onError.
- Add a lightweight, session-scoped (not necessarily persisted) audit log of role changes attempted in the UI, including failed/rolled-back attempts marked as such.
- Integrate with the existing SIWE re-auth retry flow (if implemented) so a 401-triggered rollback doesn't falsely mark a change as permanently failed if it's about to be retried.
- Add tests (mocking the API layer) for: successful optimistic update, network failure rollback, and 401-then-retry-success.
Acceptance criteria
Likely affected files/directories
app/admin/ (role assignment UI)
lib/api/live.ts, lib/api/mock.ts
lib/wallet/providers.tsx
Difficulty: Advanced
Type: feature
Background
POST /v1/members/:address/rolesis a Bearer-authenticated admin mutation (per the Live API endpoints table) that assigns a role to a member, and the app already uses React Query for data fetching/mutations.Problem
Role assignment currently likely waits for the network round-trip before updating the UI (or, if optimistic, has no visible history of who changed what and when), and any failure handling/rollback behavior isn't documented — admins have no way to see a history of role changes made through the dashboard.
Expected outcome
Assigning a role updates the UI immediately (optimistic update via React Query's
onMutate), automatically rolls back cleanly on failure (including on a401that isn't resolved by the auto-retry flow), and a local "recent changes" panel shows a short audit trail (who/what/when) of role changes made in the current admin session.Suggested implementation
onMutate, apply the optimistic change, and roll back inonError.Acceptance criteria
Likely affected files/directories
app/admin/(role assignment UI)lib/api/live.ts,lib/api/mock.tslib/wallet/providers.tsx