website refactor

This commit is contained in:
2026-01-14 16:28:39 +01:00
parent 85e09b6f4d
commit 4b7d82ab43
119 changed files with 2403 additions and 1615 deletions

View File

@@ -0,0 +1,85 @@
import type { GetDriverProfileOutputDTO } from '@/lib/types/generated/GetDriverProfileOutputDTO';
import type { DriverProfileViewData } from '@/lib/types/view-data/DriverProfileViewData';
export class DriverProfileViewDataBuilder {
static build(dto: GetDriverProfileOutputDTO): DriverProfileViewData {
return {
currentDriver: dto.currentDriver ? {
id: dto.currentDriver.id,
name: dto.currentDriver.name,
country: dto.currentDriver.country,
avatarUrl: dto.currentDriver.avatarUrl || '',
iracingId: dto.currentDriver.iracingId || null,
joinedAt: dto.currentDriver.joinedAt,
rating: dto.currentDriver.rating || null,
globalRank: dto.currentDriver.globalRank || null,
consistency: dto.currentDriver.consistency || null,
bio: dto.currentDriver.bio || null,
totalDrivers: dto.currentDriver.totalDrivers || null,
} : null,
stats: dto.stats ? {
totalRaces: dto.stats.totalRaces,
wins: dto.stats.wins,
podiums: dto.stats.podiums,
dnfs: dto.stats.dnfs,
avgFinish: dto.stats.avgFinish || null,
bestFinish: dto.stats.bestFinish || null,
worstFinish: dto.stats.worstFinish || null,
finishRate: dto.stats.finishRate || null,
winRate: dto.stats.winRate || null,
podiumRate: dto.stats.podiumRate || null,
percentile: dto.stats.percentile || null,
rating: dto.stats.rating || null,
consistency: dto.stats.consistency || null,
overallRank: dto.stats.overallRank || null,
} : null,
finishDistribution: dto.finishDistribution ? {
totalRaces: dto.finishDistribution.totalRaces,
wins: dto.finishDistribution.wins,
podiums: dto.finishDistribution.podiums,
topTen: dto.finishDistribution.topTen,
dnfs: dto.finishDistribution.dnfs,
other: dto.finishDistribution.other,
} : null,
teamMemberships: dto.teamMemberships.map(m => ({
teamId: m.teamId,
teamName: m.teamName,
teamTag: m.teamTag || null,
role: m.role,
joinedAt: m.joinedAt,
isCurrent: m.isCurrent,
})),
socialSummary: {
friendsCount: dto.socialSummary.friendsCount,
friends: dto.socialSummary.friends.map(f => ({
id: f.id,
name: f.name,
country: f.country,
avatarUrl: f.avatarUrl || '',
})),
},
extendedProfile: dto.extendedProfile ? {
socialHandles: dto.extendedProfile.socialHandles.map(h => ({
platform: h.platform,
handle: h.handle,
url: h.url,
})),
achievements: dto.extendedProfile.achievements.map(a => ({
id: a.id,
title: a.title,
description: a.description,
icon: a.icon,
rarity: a.rarity,
earnedAt: a.earnedAt,
})),
racingStyle: dto.extendedProfile.racingStyle,
favoriteTrack: dto.extendedProfile.favoriteTrack,
favoriteCar: dto.extendedProfile.favoriteCar,
timezone: dto.extendedProfile.timezone,
availableHours: dto.extendedProfile.availableHours,
lookingForTeam: dto.extendedProfile.lookingForTeam,
openToRequests: dto.extendedProfile.openToRequests,
} : null,
};
}
}

View File

@@ -0,0 +1,25 @@
import type { DriversLeaderboardDTO } from '@/lib/types/generated/DriversLeaderboardDTO';
import type { DriversViewData } from '@/lib/types/view-data/DriversViewData';
export class DriversViewDataBuilder {
static build(dto: DriversLeaderboardDTO): DriversViewData {
return {
drivers: dto.drivers.map(driver => ({
id: driver.id,
name: driver.name,
country: driver.country,
avatarUrl: driver.avatarUrl || '',
iracingId: driver.iracingId || null,
rating: driver.rating || null,
globalRank: driver.globalRank || null,
consistency: driver.consistency || null,
totalRaces: driver.racesCompleted,
wins: driver.wins,
isActive: driver.isActive,
})),
totalRaces: dto.totalRaces,
totalWins: dto.totalWins,
activeCount: dto.activeCount,
};
}
}

View File

@@ -0,0 +1,78 @@
export interface DriverProfileViewData {
currentDriver: {
id: string;
name: string;
country: string;
avatarUrl: string;
iracingId: number | null;
joinedAt: string;
rating: number | null;
globalRank: number | null;
consistency: number | null;
bio: string | null;
totalDrivers: number | null;
} | null;
stats: {
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;
} | null;
finishDistribution: {
totalRaces: number;
wins: number;
podiums: number;
topTen: number;
dnfs: number;
other: number;
} | null;
teamMemberships: {
teamId: string;
teamName: string;
teamTag: string | null;
role: string;
joinedAt: string;
isCurrent: boolean;
}[];
socialSummary: {
friendsCount: number;
friends: {
id: string;
name: string;
country: string;
avatarUrl: string;
}[];
};
extendedProfile: {
socialHandles: {
platform: string;
handle: string;
url: string;
}[];
achievements: {
id: string;
title: string;
description: string;
icon: string;
rarity: string;
earnedAt: string;
}[];
racingStyle: string;
favoriteTrack: string;
favoriteCar: string;
timezone: string;
availableHours: string;
lookingForTeam: boolean;
openToRequests: boolean;
} | null;
}

View File

@@ -0,0 +1,18 @@
export interface DriversViewData {
drivers: {
id: string;
name: string;
country: string;
avatarUrl: string;
iracingId: number | null;
rating: number | null;
globalRank: number | null;
consistency: number | null;
totalRaces: number;
wins: number;
isActive: boolean;
}[];
totalRaces: number;
totalWins: number;
activeCount: number;
}