view data fixes
This commit is contained in:
@@ -1,48 +1,32 @@
|
||||
import type { TeamListItemDTO } from '@/lib/types/generated/TeamListItemDTO';
|
||||
|
||||
import { ViewModel } from "../contracts/view-models/ViewModel";
|
||||
import type { TeamSummaryViewData } from "../view-data/TeamSummaryViewData";
|
||||
|
||||
export class TeamSummaryViewModel extends ViewModel {
|
||||
id: string;
|
||||
name: string;
|
||||
tag: string;
|
||||
memberCount: number;
|
||||
description?: string;
|
||||
totalWins: number = 0;
|
||||
totalRaces: number = 0;
|
||||
performanceLevel: 'beginner' | 'intermediate' | 'advanced' | 'pro' = 'intermediate';
|
||||
isRecruiting: boolean = false;
|
||||
specialization: 'endurance' | 'sprint' | 'mixed' | undefined;
|
||||
region: string | undefined;
|
||||
languages: string[] = [];
|
||||
leagues: string[] = [];
|
||||
logoUrl: string | undefined;
|
||||
rating: number | undefined;
|
||||
category: string | undefined;
|
||||
private readonly data: TeamSummaryViewData;
|
||||
private readonly maxMembers = 10; // Assuming max members
|
||||
|
||||
private maxMembers = 10; // Assuming max members
|
||||
|
||||
constructor(dto: TeamListItemDTO) {
|
||||
this.id = dto.id;
|
||||
this.name = dto.name;
|
||||
this.tag = dto.tag;
|
||||
this.memberCount = dto.memberCount;
|
||||
this.description = dto.description;
|
||||
this.specialization = dto.specialization as 'endurance' | 'sprint' | 'mixed' | undefined;
|
||||
this.region = dto.region;
|
||||
this.languages = dto.languages ?? [];
|
||||
this.leagues = dto.leagues;
|
||||
|
||||
// Map stats fields from DTO
|
||||
this.totalWins = dto.totalWins ?? 0;
|
||||
this.totalRaces = dto.totalRaces ?? 0;
|
||||
this.performanceLevel = (dto.performanceLevel as 'beginner' | 'intermediate' | 'advanced' | 'pro') ?? 'intermediate';
|
||||
this.logoUrl = dto.logoUrl;
|
||||
this.rating = dto.rating;
|
||||
this.category = dto.category;
|
||||
this.isRecruiting = dto.isRecruiting ?? false;
|
||||
constructor(data: TeamSummaryViewData) {
|
||||
super();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
get id(): string { return this.data.id; }
|
||||
get name(): string { return this.data.name; }
|
||||
get tag(): string { return this.data.tag; }
|
||||
get memberCount(): number { return this.data.memberCount; }
|
||||
get description(): string | undefined { return this.data.description; }
|
||||
get totalWins(): number { return this.data.totalWins; }
|
||||
get totalRaces(): number { return this.data.totalRaces; }
|
||||
get performanceLevel(): string { return this.data.performanceLevel; }
|
||||
get isRecruiting(): boolean { return this.data.isRecruiting; }
|
||||
get specialization(): string | undefined { return this.data.specialization; }
|
||||
get region(): string | undefined { return this.data.region; }
|
||||
get languages(): string[] { return this.data.languages; }
|
||||
get leagues(): string[] { return this.data.leagues; }
|
||||
get logoUrl(): string | undefined { return this.data.logoUrl; }
|
||||
get rating(): number | undefined { return this.data.rating; }
|
||||
get category(): string | undefined { return this.data.category; }
|
||||
|
||||
/** UI-specific: Whether team is full */
|
||||
get isFull(): boolean {
|
||||
return this.memberCount >= this.maxMembers;
|
||||
|
||||
Reference in New Issue
Block a user