Summary
Improve the admin experience by adding optimistic updates and rollback handling for role and policy changes.
Current Behaviour
Admin actions such as assigning roles or changing policies depend on mutation completion before the UI reflects changes. Failure behaviour is minimal, and users may not clearly see whether data is pending, saved, or reverted.
Expected Behaviour
Admin changes should feel responsive while remaining correct if the server rejects a mutation.
Suggested Implementation
Use React Query mutation lifecycle hooks to update cached members and policies optimistically. Add rollback logic in onError, cache invalidation in onSettled, and visible pending or failed state indicators.
Files or Areas Likely Affected
app/admin/members/page.tsx
app/admin/policies/page.tsx
lib/api/types.ts
lib/api/live.ts
lib/api/mock.ts
components/ui/
Acceptance Criteria
Additional Notes
Do not hide backend validation errors. Rollback should be paired with a useful error message.
Summary
Improve the admin experience by adding optimistic updates and rollback handling for role and policy changes.
Current Behaviour
Admin actions such as assigning roles or changing policies depend on mutation completion before the UI reflects changes. Failure behaviour is minimal, and users may not clearly see whether data is pending, saved, or reverted.
Expected Behaviour
Admin changes should feel responsive while remaining correct if the server rejects a mutation.
Suggested Implementation
Use React Query mutation lifecycle hooks to update cached members and policies optimistically. Add rollback logic in
onError, cache invalidation inonSettled, and visible pending or failed state indicators.Files or Areas Likely Affected
app/admin/members/page.tsxapp/admin/policies/page.tsxlib/api/types.tslib/api/live.tslib/api/mock.tscomponents/ui/Acceptance Criteria
Additional Notes
Do not hide backend validation errors. Rollback should be paired with a useful error message.