view models
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { RacesApiClient } from '../../api/races/RacesApiClient';
|
||||
import { RaceResultsDetailPresenter } from '../../presenters/RaceResultsDetailPresenter';
|
||||
import { RaceWithSOFPresenter } from '../../presenters/RaceWithSOFPresenter';
|
||||
import type { RaceWithSOFViewModel } from '../../presenters/RaceWithSOFPresenter';
|
||||
import { ImportRaceResultsPresenter } from '../../presenters/ImportRaceResultsPresenter';
|
||||
import type { ImportRaceResultsSummaryViewModel } from '../../presenters/ImportRaceResultsPresenter';
|
||||
import type { RaceResultsDetailViewModel } from '../../view-models/RaceResultsDetailViewModel';
|
||||
import type { ImportRaceResultsInputDto } from '../../dtos';
|
||||
import { RaceResultsDetailViewModel } from '../../view-models/RaceResultsDetailViewModel';
|
||||
|
||||
// TODO: Move these types to apps/website/lib/types/generated when available
|
||||
type ImportRaceResultsInputDto = { raceId: string; results: Array<any> };
|
||||
|
||||
// Note: RaceWithSOFViewModel and ImportRaceResultsSummaryViewModel are defined in presenters
|
||||
// These will need to be converted to proper view models
|
||||
type RaceWithSOFViewModel = any; // TODO: Create proper view model
|
||||
type ImportRaceResultsSummaryViewModel = any; // TODO: Create proper view model
|
||||
|
||||
/**
|
||||
* Race Results Service
|
||||
@@ -15,33 +17,32 @@ import type { ImportRaceResultsInputDto } from '../../dtos';
|
||||
*/
|
||||
export class RaceResultsService {
|
||||
constructor(
|
||||
private readonly apiClient: RacesApiClient,
|
||||
private readonly resultsDetailPresenter: RaceResultsDetailPresenter,
|
||||
private readonly sofPresenter: RaceWithSOFPresenter,
|
||||
private readonly importPresenter: ImportRaceResultsPresenter
|
||||
private readonly apiClient: RacesApiClient
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get race results detail with presentation transformation
|
||||
* Get race results detail with view model transformation
|
||||
*/
|
||||
async getResultsDetail(raceId: string, currentUserId?: string): Promise<RaceResultsDetailViewModel> {
|
||||
const dto = await this.apiClient.getResultsDetail(raceId);
|
||||
return this.resultsDetailPresenter.present(dto, currentUserId);
|
||||
return new RaceResultsDetailViewModel(dto, currentUserId || '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get race with strength of field calculation
|
||||
* TODO: Create RaceWithSOFViewModel and use it here
|
||||
*/
|
||||
async getWithSOF(raceId: string): Promise<RaceWithSOFViewModel> {
|
||||
const dto = await this.apiClient.getWithSOF(raceId);
|
||||
return this.sofPresenter.present(dto);
|
||||
return dto; // TODO: return new RaceWithSOFViewModel(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Import race results and get summary
|
||||
* TODO: Create ImportRaceResultsSummaryViewModel and use it here
|
||||
*/
|
||||
async importResults(raceId: string, input: ImportRaceResultsInputDto): Promise<ImportRaceResultsSummaryViewModel> {
|
||||
const dto = await this.apiClient.importResults(raceId, input);
|
||||
return this.importPresenter.present(dto);
|
||||
return dto; // TODO: return new ImportRaceResultsSummaryViewModel(dto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user