view data fixes
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 5m51s
Contract Testing / contract-snapshot (pull_request) Has been skipped

This commit is contained in:
2026-01-24 12:14:08 +01:00
parent dde77e717a
commit 046852703f
94 changed files with 1333 additions and 4885 deletions

View File

@@ -10,12 +10,14 @@ import type { ProfileViewData } from '@/lib/view-data/ProfileViewData';
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
export class ProfileViewDataBuilder implements ViewDataBuilder<any, any> {
build(input: any): any {
return ProfileViewDataBuilder.build(input);
}
static build(apiDto: GetDriverProfileOutputDTO): ProfileViewData {
export class ProfileViewDataBuilder {
/**
* Transform API DTO to ViewData
*
* @param apiDto - The DTO from the service
* @returns ViewData for the profile page
*/
public static build(apiDto: GetDriverProfileOutputDTO): ProfileViewData {
const driver = apiDto.currentDriver;
if (!driver) {
@@ -29,6 +31,7 @@ export class ProfileViewDataBuilder implements ViewDataBuilder<any, any> {
bio: null,
iracingId: null,
joinedAtLabel: '',
globalRankLabel: '—',
},
stats: null,
teamMemberships: [],
@@ -50,6 +53,7 @@ export class ProfileViewDataBuilder implements ViewDataBuilder<any, any> {
bio: driver.bio || null,
iracingId: driver.iracingId ? String(driver.iracingId) : null,
joinedAtLabel: DateFormatter.formatMonthYear(driver.joinedAt),
globalRankLabel: driver.globalRank != null ? `#${driver.globalRank}` : '—',
},
stats: stats
? {
@@ -93,7 +97,7 @@ export class ProfileViewDataBuilder implements ViewDataBuilder<any, any> {
title: a.title,
description: a.description,
earnedAtLabel: DateFormatter.formatShort(a.earnedAt),
icon: a.icon as any,
icon: a.icon as 'trophy' | 'medal' | 'star' | 'crown' | 'target' | 'zap',
rarityLabel: a.rarity,
})),
friends: socialSummary.friends.slice(0, 8).map((f) => ({
@@ -109,3 +113,5 @@ export class ProfileViewDataBuilder implements ViewDataBuilder<any, any> {
};
}
}
ProfileViewDataBuilder satisfies ViewDataBuilder<GetDriverProfileOutputDTO, ProfileViewData>;