This commit is contained in:
2025-12-21 17:05:36 +01:00
parent 08b0d59e45
commit f2d8a23583
66 changed files with 1131 additions and 1342 deletions

View File

@@ -1,4 +1,6 @@
import type { Logger } from '@core/shared/application';
import type { Logger, UseCaseOutputPort, UseCase } from '@core/shared/application';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
export interface GetDashboardDataInput {}
@@ -9,12 +11,14 @@ export interface GetDashboardDataOutput {
totalLeagues: number;
}
export class GetDashboardDataUseCase {
export type GetDashboardDataErrorCode = 'REPOSITORY_ERROR';
export class GetDashboardDataUseCase implements UseCase<GetDashboardDataInput, GetDashboardDataOutput, GetDashboardDataErrorCode> {
constructor(
private readonly logger: Logger,
) {}
async execute(): Promise<GetDashboardDataOutput> {
async execute(input: GetDashboardDataInput = {}): Promise<Result<GetDashboardDataOutput, ApplicationErrorCode<GetDashboardDataErrorCode, { message: string }>>> {
try {
// Placeholder implementation - would need repositories from identity and racing domains
const totalUsers = 0;
@@ -29,15 +33,21 @@ export class GetDashboardDataUseCase {
totalLeagues,
});
return {
const result = Result.ok<GetDashboardDataOutput, ApplicationErrorCode<GetDashboardDataErrorCode, { message: string }>>({
totalUsers,
activeUsers,
totalRaces,
totalLeagues,
};
});
return result;
} catch (error) {
this.logger.error('Failed to get dashboard data', { error });
throw error;
const err = error as Error;
this.logger.error('Failed to get dashboard data', err);
const result = Result.err<GetDashboardDataOutput, ApplicationErrorCode<GetDashboardDataErrorCode, { message: string }>>({
code: 'REPOSITORY_ERROR',
details: { message: err.message ?? 'Failed to get dashboard data' },
});
return result;
}
}
}