website refactor

This commit is contained in:
2026-01-14 02:02:24 +01:00
parent 8d7c709e0c
commit 4522d41aef
291 changed files with 12763 additions and 9309 deletions

View File

@@ -1,37 +1,33 @@
import { AdminApiClient } from '@/lib/api/admin/AdminApiClient';
import { AdminService } from '@/lib/services/admin/AdminService';
import { EnhancedErrorReporter } from '@/lib/infrastructure/EnhancedErrorReporter';
import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger';
import { Mutation } from '@/lib/contracts/mutations/Mutation';
import { Result } from '@/lib/contracts/Result';
import { MutationError, mapToMutationError } from '@/lib/contracts/mutations/MutationError';
/**
* UpdateUserStatusMutation
*
*
* Framework-agnostic mutation for updating user status.
* Called from Server Actions.
*
*
* Input: { userId: string; status: string }
* Output: void
*
* Output: Result<void, MutationError>
*
* Pattern: Server Action → Mutation → Service → API Client
*/
export class UpdateUserStatusMutation implements Mutation<{ userId: string; status: string }, void> {
private service: AdminService;
constructor() {
// Manual DI for serverless
const logger = new ConsoleLogger();
const errorReporter = new EnhancedErrorReporter(logger, {
showUserNotifications: true,
logToConsole: true,
reportToExternal: process.env.NODE_ENV === 'production',
});
const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:3001';
const apiClient = new AdminApiClient(baseUrl, errorReporter, logger);
this.service = new AdminService(apiClient);
export class UpdateUserStatusMutation {
async execute(input: { userId: string; status: string }): Promise<Result<void, MutationError>> {
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');
}
}
async execute(input: { userId: string; status: string }): Promise<void> {
await this.service.updateUserStatus(input.userId, input.status);
}
}
}