import { AdminService } from '@/lib/services/admin/AdminService'; import { Result } from '@/lib/contracts/Result'; import { MutationError, mapToMutationError } from '@/lib/contracts/mutations/MutationError'; import { Mutation } from '@/lib/contracts/mutations/Mutation'; /** * UpdateUserStatusMutation * * Framework-agnostic mutation for updating user status. * Called from Server Actions. * * Input: { userId: string; status: string } * Output: Result * * Pattern: Server Action → Mutation → Service → API Client */ export class UpdateUserStatusMutation implements Mutation<{ userId: string; status: string }, void, MutationError> { async execute(input: { userId: string; status: string }): Promise> { try { // Manual construction: Service creates its own dependencies const service = new AdminService(); const result = await service.updateUserStatus(input.userId, input.status); if (result.isErr()) { return Result.err(mapToMutationError(result.getError())); } return Result.ok(undefined); } catch (err) { return Result.err('updateFailed'); } } }