130 lines
3.4 KiB
TypeScript
130 lines
3.4 KiB
TypeScript
import { DriverProfileDriverSummaryViewModel } from "./DriverProfileDriverSummaryViewModel";
|
|
export type { DriverProfileDriverSummaryViewModel };
|
|
|
|
export interface DriverProfileStatsViewModel {
|
|
totalRaces: number;
|
|
wins: number;
|
|
podiums: number;
|
|
dnfs: number;
|
|
avgFinish: number | null;
|
|
bestFinish: number | null;
|
|
worstFinish: number | null;
|
|
finishRate: number | null;
|
|
winRate: number | null;
|
|
podiumRate: number | null;
|
|
percentile: number | null;
|
|
rating: number | null;
|
|
consistency: number | null;
|
|
overallRank: number | null;
|
|
}
|
|
|
|
export interface DriverProfileFinishDistributionViewModel {
|
|
totalRaces: number;
|
|
wins: number;
|
|
podiums: number;
|
|
topTen: number;
|
|
dnfs: number;
|
|
other: number;
|
|
}
|
|
|
|
export interface DriverProfileTeamMembershipViewModel {
|
|
teamId: string;
|
|
teamName: string;
|
|
teamTag: string | null;
|
|
role: string;
|
|
joinedAt: string;
|
|
isCurrent: boolean;
|
|
}
|
|
|
|
export interface DriverProfileSocialFriendSummaryViewModel {
|
|
id: string;
|
|
name: string;
|
|
country: string;
|
|
avatarUrl: string;
|
|
}
|
|
|
|
export interface DriverProfileSocialSummaryViewModel {
|
|
friendsCount: number;
|
|
friends: DriverProfileSocialFriendSummaryViewModel[];
|
|
}
|
|
|
|
export type DriverProfileSocialPlatform = 'twitter' | 'youtube' | 'twitch' | 'discord';
|
|
|
|
export type DriverProfileAchievementRarity = 'common' | 'rare' | 'epic' | 'legendary';
|
|
|
|
export interface DriverProfileAchievementViewModel {
|
|
id: string;
|
|
title: string;
|
|
description: string;
|
|
icon: 'trophy' | 'medal' | 'star' | 'crown' | 'target' | 'zap';
|
|
rarity: DriverProfileAchievementRarity;
|
|
earnedAt: string;
|
|
}
|
|
|
|
export interface DriverProfileSocialHandleViewModel {
|
|
platform: DriverProfileSocialPlatform;
|
|
handle: string;
|
|
url: string;
|
|
}
|
|
|
|
export interface DriverProfileExtendedProfileViewModel {
|
|
socialHandles: DriverProfileSocialHandleViewModel[];
|
|
achievements: DriverProfileAchievementViewModel[];
|
|
racingStyle: string;
|
|
favoriteTrack: string;
|
|
favoriteCar: string;
|
|
timezone: string;
|
|
availableHours: string;
|
|
lookingForTeam: boolean;
|
|
openToRequests: boolean;
|
|
}
|
|
|
|
export interface DriverProfileViewModelData {
|
|
currentDriver: DriverProfileDriverSummaryViewModel | null;
|
|
stats: DriverProfileStatsViewModel | null;
|
|
finishDistribution: DriverProfileFinishDistributionViewModel | null;
|
|
teamMemberships: DriverProfileTeamMembershipViewModel[];
|
|
socialSummary: DriverProfileSocialSummaryViewModel;
|
|
extendedProfile: DriverProfileExtendedProfileViewModel | null;
|
|
}
|
|
|
|
/**
|
|
* Driver Profile View Model
|
|
*
|
|
* Represents a fully prepared UI state for driver profile display.
|
|
* Transforms API DTOs into UI-ready data structures.
|
|
*/
|
|
export class DriverProfileViewModel {
|
|
constructor(private readonly dto: DriverProfileViewModelData) {}
|
|
|
|
get currentDriver(): DriverProfileDriverSummaryViewModel | null {
|
|
return this.dto.currentDriver;
|
|
}
|
|
|
|
get stats(): DriverProfileStatsViewModel | null {
|
|
return this.dto.stats;
|
|
}
|
|
|
|
get finishDistribution(): DriverProfileFinishDistributionViewModel | null {
|
|
return this.dto.finishDistribution;
|
|
}
|
|
|
|
get teamMemberships(): DriverProfileTeamMembershipViewModel[] {
|
|
return this.dto.teamMemberships;
|
|
}
|
|
|
|
get socialSummary(): DriverProfileSocialSummaryViewModel {
|
|
return this.dto.socialSummary;
|
|
}
|
|
|
|
get extendedProfile(): DriverProfileExtendedProfileViewModel | null {
|
|
return this.dto.extendedProfile;
|
|
}
|
|
|
|
/**
|
|
* Get the raw DTO for serialization or further processing
|
|
*/
|
|
toDTO(): DriverProfileViewModelData {
|
|
return this.dto;
|
|
}
|
|
} |