view data fixes
This commit is contained in:
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user