view models
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { StandingEntryDto, DriverDto } from '../dtos';
|
||||
import { LeagueStandingDTO } from '../types/generated/LeagueStandingDTO';
|
||||
|
||||
export class StandingEntryViewModel implements StandingEntryDto {
|
||||
export class StandingEntryViewModel implements LeagueStandingDTO {
|
||||
driverId: string;
|
||||
driver?: DriverDto;
|
||||
position: number;
|
||||
points: number;
|
||||
wins: number;
|
||||
@@ -14,8 +13,10 @@ export class StandingEntryViewModel implements StandingEntryDto {
|
||||
private currentUserId: string;
|
||||
private previousPosition?: number;
|
||||
|
||||
constructor(dto: StandingEntryDto, leaderPoints: number, nextPoints: number, currentUserId: string, previousPosition?: number) {
|
||||
Object.assign(this, dto);
|
||||
constructor(dto: LeagueStandingDTO, leaderPoints: number, nextPoints: number, currentUserId: string, previousPosition?: number) {
|
||||
this.driverId = dto.driverId;
|
||||
this.position = dto.position;
|
||||
this.points = dto.points;
|
||||
this.leaderPoints = leaderPoints;
|
||||
this.nextPoints = nextPoints;
|
||||
this.currentUserId = currentUserId;
|
||||
@@ -27,6 +28,13 @@ export class StandingEntryViewModel implements StandingEntryDto {
|
||||
return this.position.toString();
|
||||
}
|
||||
|
||||
// Note: The generated DTO is incomplete
|
||||
// These fields will need to be added when the OpenAPI spec is updated
|
||||
driver?: any;
|
||||
wins: number = 0;
|
||||
podiums: number = 0;
|
||||
races: number = 0;
|
||||
|
||||
/** UI-specific: Points difference to leader */
|
||||
get pointsGapToLeader(): number {
|
||||
return this.points - this.leaderPoints;
|
||||
|
||||
Reference in New Issue
Block a user