import { ViewModel } from "../contracts/view-models/ViewModel"; import { LeagueRole, LeagueRoleFormatter } from "../formatters/LeagueRoleFormatter"; import type { LeagueMemberViewData } from "../view-data/LeagueMemberViewData"; export class LeagueMemberViewModel extends ViewModel { private readonly data: LeagueMemberViewData; constructor(data: LeagueMemberViewData) { super(); this.data = data; } get driverId(): string { return this.data.driverId; } get currentUserId(): string { return this.data.currentUserId; } get driver(): any { return this.data.driver; } get role(): string { return this.data.role; } get joinedAt(): string { return this.data.joinedAt; } /** UI-specific: Formatted join date */ get formattedJoinedAt(): string { // Client-only formatting return new Date(this.joinedAt).toLocaleDateString(); } /** UI-specific: Badge classes for role */ get roleBadgeClasses(): string { return LeagueRoleFormatter.getLeagueRoleDisplay(this.role as LeagueRole)?.badgeClasses || ''; } /** UI-specific: Whether this member is the owner */ get isOwner(): boolean { return this.role === 'owner'; } /** UI-specific: Whether this is the current user */ get isCurrentUser(): boolean { return this.driverId === this.data.currentUserId; } }