feat: Implement API and cache improvements

This commit is contained in:
gpt-engineer-app[bot]
2025-10-31 12:11:14 +00:00
parent 2fb983bb4f
commit 0d16bb511c
11 changed files with 584 additions and 9 deletions

View File

@@ -171,3 +171,49 @@ When migrating a component:
- [ ] Replace loading state with `mutation.isPending`
- [ ] Remove try/catch blocks from component
- [ ] Test optimistic updates if applicable
- [ ] Add audit log creation where appropriate
- [ ] Ensure proper type safety with TypeScript
## Available Mutation Hooks
### Profile & User Management
- `useProfileUpdateMutation` - Profile updates (username, display name, bio)
- `useProfileLocationMutation` - Location and personal info updates
- `usePrivacyMutations` - Privacy settings updates
### Security
- `useSecurityMutations` - Session management (revoke sessions)
### Moderation
- `useReportMutation` - Submit user reports
- `useReportActionMutation` - Resolve/dismiss reports
### Admin
- `useAuditLogs` - Query audit logs with pagination
## Cache Invalidation Guidelines
Always invalidate related caches after mutations:
```typescript
// After profile update
invalidateUserProfile(userId);
invalidateProfileStats(userId);
invalidateProfileActivity(userId);
invalidateUserSearch(); // If username/display name changed
// After privacy update
invalidateUserProfile(userId);
invalidateAuditLogs(userId);
invalidateUserSearch(); // If privacy level changed
// After report action
invalidateModerationQueue();
invalidateModerationStats();
invalidateAuditLogs();
// After security action
invalidateSessions();
invalidateAuditLogs();
invalidateEmailChangeStatus(); // For email changes
```