refactor
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { CompleteOnboardingOutput } from '../dto/DriverDto';
|
||||
import { CompleteOnboardingOutputDTO } from '../dtos/CompleteOnboardingOutputDTO';
|
||||
import type { ICompleteDriverOnboardingPresenter, CompleteDriverOnboardingResultDTO } from '../../../../../core/racing/application/presenters/ICompleteDriverOnboardingPresenter';
|
||||
|
||||
export class CompleteOnboardingPresenter implements ICompleteDriverOnboardingPresenter {
|
||||
private result: CompleteOnboardingOutput | null = null;
|
||||
private result: CompleteOnboardingOutputDTO | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
@@ -16,7 +16,7 @@ export class CompleteOnboardingPresenter implements ICompleteDriverOnboardingPre
|
||||
};
|
||||
}
|
||||
|
||||
get viewModel(): CompleteOnboardingOutput {
|
||||
get viewModel(): CompleteOnboardingOutputDTO {
|
||||
if (!this.result) throw new Error('Presenter not presented');
|
||||
return this.result;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { DriverRegistrationStatusViewModel } from '../dto/DriverDto';
|
||||
import { DriverRegistrationStatusDTO } from '../dtos/DriverRegistrationStatusDTO';
|
||||
import type { IDriverRegistrationStatusPresenter } from '../../../../../core/racing/application/presenters/IDriverRegistrationStatusPresenter';
|
||||
|
||||
export class DriverRegistrationStatusPresenter implements IDriverRegistrationStatusPresenter {
|
||||
private result: DriverRegistrationStatusViewModel | null = null;
|
||||
private result: DriverRegistrationStatusDTO | null = null;
|
||||
|
||||
present(isRegistered: boolean, raceId: string, driverId: string) {
|
||||
this.result = {
|
||||
@@ -12,7 +12,7 @@ export class DriverRegistrationStatusPresenter implements IDriverRegistrationSta
|
||||
};
|
||||
}
|
||||
|
||||
getViewModel(): DriverRegistrationStatusViewModel {
|
||||
getViewModel(): DriverRegistrationStatusDTO {
|
||||
if (!this.result) throw new Error('Presenter not presented');
|
||||
return this.result;
|
||||
}
|
||||
@@ -22,7 +22,7 @@ export class DriverRegistrationStatusPresenter implements IDriverRegistrationSta
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
get viewModel(): DriverRegistrationStatusViewModel {
|
||||
get viewModel(): DriverRegistrationStatusDTO {
|
||||
return this.getViewModel();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { DriverStatsDto } from '../dto/DriverDto';
|
||||
import { DriverStatsDTO } from '../dtos/DriverStatsDTO';
|
||||
import type { ITotalDriversPresenter, TotalDriversResultDTO } from '../../../../../core/racing/application/presenters/ITotalDriversPresenter';
|
||||
|
||||
export class DriverStatsPresenter implements ITotalDriversPresenter {
|
||||
private result: DriverStatsDto | null = null;
|
||||
private result: DriverStatsDTO | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
@@ -14,7 +14,7 @@ export class DriverStatsPresenter implements ITotalDriversPresenter {
|
||||
};
|
||||
}
|
||||
|
||||
get viewModel(): DriverStatsDto {
|
||||
get viewModel(): DriverStatsDTO {
|
||||
if (!this.result) throw new Error('Presenter not presented');
|
||||
return this.result;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { DriversLeaderboardViewModel, DriverLeaderboardItemViewModel } from '../dto/DriverDto';
|
||||
import { DriversLeaderboardDTO, DriverLeaderboardItemDTO } from '../dtos/DriversLeaderboardDTO';
|
||||
import { DriverLeaderboardItemDTO } from '../dtos/DriverLeaderboardItemDTO';
|
||||
import type { IDriversLeaderboardPresenter, DriversLeaderboardResultDTO } from '../../../../../core/racing/application/presenters/IDriversLeaderboardPresenter';
|
||||
|
||||
export class DriversLeaderboardPresenter implements IDriversLeaderboardPresenter {
|
||||
private result: DriversLeaderboardViewModel | null = null;
|
||||
private result: DriversLeaderboardDTO | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(dto: DriversLeaderboardResultDTO) {
|
||||
const drivers: DriverLeaderboardItemViewModel[] = dto.drivers.map(driver => {
|
||||
const drivers: DriverLeaderboardItemDTO[] = dto.drivers.map(driver => {
|
||||
const ranking = dto.rankings.find(r => r.driverId === driver.id);
|
||||
const stats = dto.stats[driver.id];
|
||||
const avatarUrl = dto.avatarUrls[driver.id];
|
||||
@@ -42,7 +43,7 @@ export class DriversLeaderboardPresenter implements IDriversLeaderboardPresenter
|
||||
};
|
||||
}
|
||||
|
||||
get viewModel(): DriversLeaderboardViewModel {
|
||||
get viewModel(): DriversLeaderboardDTO {
|
||||
if (!this.result) throw new Error('Presenter not presented');
|
||||
return this.result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user