view data fixes
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
import type { TeamsPageDto } from '@/lib/page-queries/TeamsPageQuery';
|
||||
import type { GetAllTeamsOutputDTO } from '@/lib/types/generated/GetAllTeamsOutputDTO';
|
||||
import type { TeamsViewData, TeamSummaryData } from '@/lib/view-data/TeamsViewData';
|
||||
import type { TeamListItemDTO } from '@/lib/types/generated/TeamListItemDTO';
|
||||
import { RatingDisplay } from '@/lib/display-objects/RatingDisplay';
|
||||
import { NumberDisplay } from '@/lib/display-objects/NumberDisplay';
|
||||
|
||||
/**
|
||||
* TeamsViewDataBuilder - Transforms TeamsPageDto into ViewData for TeamsTemplate
|
||||
* Deterministic; side-effect free; no HTTP calls
|
||||
*/
|
||||
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
|
||||
|
||||
export class TeamsViewDataBuilder implements ViewDataBuilder<any, any> {
|
||||
@@ -15,23 +11,22 @@ export class TeamsViewDataBuilder implements ViewDataBuilder<any, any> {
|
||||
return TeamsViewDataBuilder.build(input);
|
||||
}
|
||||
|
||||
static build(
|
||||
static build(apiDto: TeamsPageDto): TeamsViewData {
|
||||
static build(apiDto: GetAllTeamsOutputDTO): TeamsViewData {
|
||||
const teams: TeamSummaryData[] = apiDto.teams.map((team: TeamListItemDTO): TeamSummaryData => ({
|
||||
teamId: team.id,
|
||||
teamName: team.name,
|
||||
memberCount: team.memberCount,
|
||||
logoUrl: team.logoUrl,
|
||||
logoUrl: team.logoUrl || '',
|
||||
ratingLabel: RatingDisplay.format(team.rating),
|
||||
ratingValue: team.rating || 0,
|
||||
winsLabel: NumberDisplay.format(team.totalWins || 0),
|
||||
racesLabel: NumberDisplay.format(team.totalRaces || 0),
|
||||
region: team.region,
|
||||
region: team.region || '',
|
||||
isRecruiting: team.isRecruiting,
|
||||
category: team.category,
|
||||
performanceLevel: team.performanceLevel,
|
||||
description: team.description,
|
||||
countryCode: team.region, // Assuming region contains country code for now
|
||||
category: team.category || '',
|
||||
performanceLevel: team.performanceLevel || '',
|
||||
description: team.description || '',
|
||||
countryCode: team.region || '', // Assuming region contains country code for now
|
||||
}));
|
||||
|
||||
return { teams };
|
||||
|
||||
Reference in New Issue
Block a user