website cleanup

This commit is contained in:
2025-12-25 00:19:36 +01:00
parent d78854a4c6
commit 9486455b9e
82 changed files with 1223 additions and 363 deletions

View File

@@ -1,14 +1,14 @@
import { RaceDetailUserResultDTO } from '../types/generated/RaceDetailUserResultDTO';
export class RaceDetailUserResultViewModel {
position: number;
startPosition: number;
incidents: number;
fastestLap: number;
positionChange: number;
ratingChange: number;
isPodium: boolean;
isClean: boolean;
position!: number;
startPosition!: number;
incidents!: number;
fastestLap!: number;
positionChange!: number;
isPodium!: boolean;
isClean!: boolean;
ratingChange!: number;
constructor(dto: RaceDetailUserResultDTO) {
this.position = dto.position;
@@ -16,8 +16,49 @@ export class RaceDetailUserResultViewModel {
this.incidents = dto.incidents;
this.fastestLap = dto.fastestLap;
this.positionChange = dto.positionChange;
this.ratingChange = dto.ratingChange;
this.isPodium = dto.isPodium;
this.isClean = dto.isClean;
this.ratingChange = dto.ratingChange ?? 0;
}
/** UI-specific: Display for position change */
get positionChangeDisplay(): string {
if (this.positionChange > 0) return `+${this.positionChange}`;
if (this.positionChange < 0) return `${this.positionChange}`;
return '0';
}
/** UI-specific: Color for position change */
get positionChangeColor(): string {
if (this.positionChange > 0) return 'green';
if (this.positionChange < 0) return 'red';
return 'gray';
}
/** UI-specific: Whether this is the winner */
get isWinner(): boolean {
return this.position === 1;
}
/** UI-specific: Rating change display */
get ratingChangeDisplay(): string {
if (this.ratingChange > 0) return `+${this.ratingChange}`;
return `${this.ratingChange}`;
}
/** UI-specific: Rating change color */
get ratingChangeColor(): string {
if (this.ratingChange > 0) return 'green';
if (this.ratingChange < 0) return 'red';
return 'gray';
}
/** UI-specific: Formatted lap time */
get lapTimeFormatted(): string {
if (this.fastestLap <= 0) return '--:--.---';
const minutes = Math.floor(this.fastestLap / 60);
const seconds = Math.floor(this.fastestLap % 60);
const milliseconds = Math.floor((this.fastestLap % 1) * 1000);
return `${minutes}:${seconds.toString().padStart(2, '0')}.${milliseconds.toString().padStart(3, '0')}`;
}
}