website refactor

This commit is contained in:
2026-01-14 17:25:30 +01:00
parent 4b7d82ab43
commit e3c6146c1d
10 changed files with 243 additions and 1 deletions

View File

@@ -6,11 +6,13 @@ import { DriverRegistrationStatusDTO } from './dtos/DriverRegistrationStatusDTO'
import { DriversLeaderboardDTO } from './dtos/DriversLeaderboardDTO';
import { DriverStatsDTO } from './dtos/DriverStatsDTO';
import { GetDriverOutputDTO } from './dtos/GetDriverOutputDTO';
import { GetDriverLiveriesOutputDTO } from './dtos/GetDriverLiveriesOutputDTO';
import { GetDriverProfileOutputDTO } from './dtos/GetDriverProfileOutputDTO';
import { GetDriverRegistrationStatusQueryDTO } from './dtos/GetDriverRegistrationStatusQueryDTO';
// Use cases
import { CompleteDriverOnboardingUseCase } from '@core/racing/application/use-cases/CompleteDriverOnboardingUseCase';
import { GetDriverLiveriesUseCase } from '@core/racing/application/use-cases/GetDriverLiveriesUseCase';
import { GetDriversLeaderboardUseCase } from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase';
import { GetProfileOverviewUseCase } from '@core/racing/application/use-cases/GetProfileOverviewUseCase';
import { GetTotalDriversUseCase } from '@core/racing/application/use-cases/GetTotalDriversUseCase';
@@ -24,6 +26,7 @@ import { DriverProfilePresenter } from './presenters/DriverProfilePresenter';
import { DriverRegistrationStatusPresenter } from './presenters/DriverRegistrationStatusPresenter';
import { DriversLeaderboardPresenter } from './presenters/DriversLeaderboardPresenter';
import { DriverStatsPresenter } from './presenters/DriverStatsPresenter';
import { GetDriverLiveriesPresenter } from './presenters/GetDriverLiveriesPresenter';
// Tokens
import type { IDriverRepository } from '@core/racing/domain/repositories/IDriverRepository';
@@ -31,6 +34,7 @@ import type { Logger } from '@core/shared/application';
import {
COMPLETE_DRIVER_ONBOARDING_USE_CASE_TOKEN,
DRIVER_REPOSITORY_TOKEN,
GET_DRIVER_LIVERIES_USE_CASE_TOKEN,
GET_DRIVERS_LEADERBOARD_USE_CASE_TOKEN,
GET_PROFILE_OVERVIEW_USE_CASE_TOKEN,
GET_TOTAL_DRIVERS_USE_CASE_TOKEN,
@@ -46,6 +50,8 @@ export class DriverService {
private readonly getDriversLeaderboardUseCase: GetDriversLeaderboardUseCase,
@Inject(GET_TOTAL_DRIVERS_USE_CASE_TOKEN)
private readonly getTotalDriversUseCase: GetTotalDriversUseCase,
@Inject(GET_DRIVER_LIVERIES_USE_CASE_TOKEN)
private readonly getDriverLiveriesUseCase: GetDriverLiveriesUseCase,
@Inject(COMPLETE_DRIVER_ONBOARDING_USE_CASE_TOKEN)
private readonly completeDriverOnboardingUseCase: CompleteDriverOnboardingUseCase,
@Inject(IS_DRIVER_REGISTERED_FOR_RACE_USE_CASE_TOKEN)
@@ -65,6 +71,7 @@ export class DriverService {
private readonly driverRegistrationStatusPresenter?: DriverRegistrationStatusPresenter,
private readonly driverPresenter?: DriverPresenter,
private readonly driverProfilePresenter?: DriverProfilePresenter,
private readonly getDriverLiveriesPresenter?: GetDriverLiveriesPresenter,
) {
// Presenters are configured by providers, no need to configure here
}
@@ -175,4 +182,15 @@ export class DriverService {
}
return this.driverProfilePresenter!.getResponseModel();
}
async getDriverLiveries(driverId: string): Promise<GetDriverLiveriesOutputDTO> {
this.logger.debug(`[DriverService] Fetching driver liveries for driverId: ${driverId}`);
const result = await this.getDriverLiveriesUseCase.execute({ driverId });
if (result.isErr()) {
throw new Error(result.unwrapErr().details.message);
}
await this.getDriverLiveriesPresenter!.present(result);
return this.getDriverLiveriesPresenter!.getResponseModel()!;
}
}