api client refactor
This commit is contained in:
41
apps/website/lib/view-models/TeamSummaryViewModel.ts
Normal file
41
apps/website/lib/view-models/TeamSummaryViewModel.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { TeamSummaryDto } from '../dtos';
|
||||
|
||||
export class TeamSummaryViewModel implements TeamSummaryDto {
|
||||
id: string;
|
||||
name: string;
|
||||
logoUrl?: string;
|
||||
memberCount: number;
|
||||
rating: number;
|
||||
|
||||
private maxMembers = 10; // Assuming max members
|
||||
|
||||
constructor(dto: TeamSummaryDto) {
|
||||
Object.assign(this, dto);
|
||||
}
|
||||
|
||||
/** UI-specific: Whether team is full */
|
||||
get isFull(): boolean {
|
||||
return this.memberCount >= this.maxMembers;
|
||||
}
|
||||
|
||||
/** UI-specific: Rating display */
|
||||
get ratingDisplay(): string {
|
||||
return this.rating.toFixed(0);
|
||||
}
|
||||
|
||||
/** 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';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user