Files
gridpilot.gg/core/racing/application/use-cases/GetLeagueAdminUseCase.ts
2025-12-16 11:52:26 +01:00

37 lines
1.2 KiB
TypeScript

import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
import type { IGetLeagueAdminPresenter, GetLeagueAdminResultDTO, GetLeagueAdminViewModel } from '../presenters/IGetLeagueAdminPresenter';
import type { UseCase } from '@core/shared/application/UseCase';
export interface GetLeagueAdminUseCaseParams {
leagueId: string;
}
export interface GetLeagueAdminResultDTO {
league: {
id: string;
ownerId: string;
};
// Additional data would be populated by combining multiple use cases
}
export class GetLeagueAdminUseCase implements UseCase<GetLeagueAdminUseCaseParams, GetLeagueAdminResultDTO, GetLeagueAdminViewModel, IGetLeagueAdminPresenter> {
constructor(
private readonly leagueRepository: ILeagueRepository,
) {}
async execute(params: GetLeagueAdminUseCaseParams, presenter: IGetLeagueAdminPresenter): Promise<void> {
const league = await this.leagueRepository.findById(params.leagueId);
if (!league) {
throw new Error('League not found');
}
const dto: GetLeagueAdminResultDTO = {
league: {
id: league.id,
ownerId: league.ownerId,
},
};
presenter.reset();
presenter.present(dto);
}
}