wip
This commit is contained in:
@@ -11,7 +11,11 @@ import type { ILeagueRepository } from '../../domain/repositories/ILeagueReposit
|
||||
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
|
||||
import type { IRaceRepository } from '../../domain/repositories/IRaceRepository';
|
||||
import type { SponsorshipTier, SponsorshipStatus } from '../../domain/entities/SeasonSponsorship';
|
||||
import type { ISponsorSponsorshipsPresenter } from '../presenters/ISponsorSponsorshipsPresenter';
|
||||
import type {
|
||||
ISponsorSponsorshipsPresenter,
|
||||
SponsorSponsorshipsViewModel,
|
||||
} from '../presenters/ISponsorSponsorshipsPresenter';
|
||||
import type { UseCase } from '@gridpilot/shared/application/UseCase';
|
||||
|
||||
export interface GetSponsorSponsorshipsQueryParams {
|
||||
sponsorId: string;
|
||||
@@ -62,7 +66,9 @@ export interface SponsorSponsorshipsDTO {
|
||||
};
|
||||
}
|
||||
|
||||
export class GetSponsorSponsorshipsUseCase {
|
||||
export class GetSponsorSponsorshipsUseCase
|
||||
implements UseCase<GetSponsorSponsorshipsQueryParams, SponsorSponsorshipsDTO | null, SponsorSponsorshipsViewModel, ISponsorSponsorshipsPresenter>
|
||||
{
|
||||
constructor(
|
||||
private readonly sponsorRepository: ISponsorRepository,
|
||||
private readonly seasonSponsorshipRepository: ISeasonSponsorshipRepository,
|
||||
@@ -70,15 +76,19 @@ export class GetSponsorSponsorshipsUseCase {
|
||||
private readonly leagueRepository: ILeagueRepository,
|
||||
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
|
||||
private readonly raceRepository: IRaceRepository,
|
||||
private readonly presenter: ISponsorSponsorshipsPresenter,
|
||||
) {}
|
||||
|
||||
async execute(params: GetSponsorSponsorshipsQueryParams): Promise<void> {
|
||||
async execute(
|
||||
params: GetSponsorSponsorshipsQueryParams,
|
||||
presenter: ISponsorSponsorshipsPresenter,
|
||||
): Promise<void> {
|
||||
presenter.reset();
|
||||
|
||||
const { sponsorId } = params;
|
||||
|
||||
const sponsor = await this.sponsorRepository.findById(sponsorId);
|
||||
if (!sponsor) {
|
||||
this.presenter.present(null);
|
||||
presenter.present(null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -150,7 +160,7 @@ export class GetSponsorSponsorshipsUseCase {
|
||||
|
||||
const activeSponsorships = sponsorships.filter(s => s.status === 'active').length;
|
||||
|
||||
this.presenter.present({
|
||||
const dto: SponsorSponsorshipsDTO = {
|
||||
sponsorId,
|
||||
sponsorName: sponsor.name,
|
||||
sponsorships: sponsorshipDetails,
|
||||
@@ -161,6 +171,8 @@ export class GetSponsorSponsorshipsUseCase {
|
||||
totalPlatformFees,
|
||||
currency: 'USD',
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
presenter.present(dto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user