refactor core presenters
This commit is contained in:
@@ -10,7 +10,7 @@ import type { ISeasonRepository } from '../../domain/repositories/ISeasonReposit
|
||||
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
|
||||
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
|
||||
import type { IRaceRepository } from '../../domain/repositories/IRaceRepository';
|
||||
import type { SponsorDashboardViewModel } from '../presenters/ISponsorDashboardPresenter';
|
||||
import type { SponsorDashboardOutputPort } from '../ports/output/SponsorDashboardOutputPort';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
|
||||
@@ -61,7 +61,7 @@ export class GetSponsorDashboardUseCase {
|
||||
|
||||
async execute(
|
||||
params: GetSponsorDashboardQueryParams,
|
||||
): Promise<Result<SponsorDashboardViewModel, ApplicationErrorCode<'REPOSITORY_ERROR'>>> {
|
||||
): Promise<Result<SponsorDashboardOutputPort | null, ApplicationErrorCode<'REPOSITORY_ERROR'>>> {
|
||||
try {
|
||||
const { sponsorId } = params;
|
||||
|
||||
@@ -146,7 +146,7 @@ export class GetSponsorDashboardUseCase {
|
||||
? Math.min(100, (mainSponsorships * 30) + (sponsorships.length * 10))
|
||||
: 0;
|
||||
|
||||
const dto: SponsorDashboardDTO = {
|
||||
const outputPort: SponsorDashboardOutputPort = {
|
||||
sponsorId,
|
||||
sponsorName: sponsor.name,
|
||||
metrics: {
|
||||
@@ -167,7 +167,7 @@ export class GetSponsorDashboardUseCase {
|
||||
},
|
||||
};
|
||||
|
||||
return Result.ok(dto);
|
||||
return Result.ok(outputPort);
|
||||
} catch {
|
||||
return Result.err({ code: 'REPOSITORY_ERROR', message: 'Failed to fetch sponsor dashboard' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user