Skip to content

Add optimistic updates for admin mutations #22

@Lakes41

Description

@Lakes41

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

  • Role assignment updates the visible member list optimistically
  • Policy edits update visible policy values optimistically
  • Failed mutations rollback to the previous cached state
  • Pending saves are visibly indicated
  • Successful saves produce clear feedback
  • Tests cover success and rollback behaviour

Additional Notes

Do not hide backend validation errors. Rollback should be paired with a useful error message.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions