Files
gridpilot.gg/apps/website/lib/view-models/TeamSummaryViewModel.ts
2025-12-18 22:19:40 +01:00

57 lines
1.4 KiB
TypeScript

import type { TeamListItemDTO } from '@/lib/types/generated/GetAllTeamsOutputDTO';
export class TeamSummaryViewModel {
id: string;
name: string;
tag: string;
memberCount: number;
description?: string;
totalWins: number = 0;
totalRaces: number = 0;
performanceLevel: string = '';
isRecruiting: boolean = false;
specialization?: string;
region?: string;
languages: string[] = [];
leagues: string[] = [];
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;
this.region = dto.region;
this.languages = dto.languages ?? [];
this.leagues = dto.leagues;
}
/** UI-specific: Whether team is full */
get isFull(): boolean {
return this.memberCount >= this.maxMembers;
}
/** UI-specific: Tag display */
get tagDisplay(): string {
return `[${this.tag}]`;
}
/** UI-specific: Member count display */
get memberCountDisplay(): string {
return `${this.memberCount}/${this.maxMembers}`;
}
/** UI-specific: Status indicator */
get statusIndicator(): string {
if (this.isFull) return 'Full';
return 'Open';
}
/** UI-specific: Status color */
get statusColor(): string {
return this.isFull ? 'red' : 'green';
}
}