23 lines
1.1 KiB
TypeScript
23 lines
1.1 KiB
TypeScript
import type { IRaceRegistrationRepository } from '../../domain/repositories/IRaceRegistrationRepository';
|
|
import type { IsDriverRegisteredForRaceQueryParamsDTO } from '../dto/RaceRegistrationQueryDTO';
|
|
import type { IDriverRegistrationStatusPresenter } from '../presenters/IDriverRegistrationStatusPresenter';
|
|
import type { UseCase } from '@gridpilot/shared/application/UseCase';
|
|
|
|
/**
|
|
* Use Case: IsDriverRegisteredForRaceUseCase
|
|
*
|
|
* Checks if a driver is registered for a specific race.
|
|
* Orchestrates domain logic and delegates presentation to the presenter.
|
|
*/
|
|
export class IsDriverRegisteredForRaceUseCase
|
|
implements UseCase<IsDriverRegisteredForRaceQueryParamsDTO, boolean, any, IDriverRegistrationStatusPresenter>
|
|
{
|
|
constructor(private readonly registrationRepository: IRaceRegistrationRepository) {}
|
|
|
|
async execute(params: IsDriverRegisteredForRaceQueryParamsDTO, presenter: IDriverRegistrationStatusPresenter): Promise<void> {
|
|
presenter.reset();
|
|
const { raceId, driverId } = params;
|
|
const isRegistered = await this.registrationRepository.isRegistered(raceId, driverId);
|
|
presenter.present(isRegistered, raceId, driverId);
|
|
}
|
|
} |