Files
gridpilot.gg/apps/website/lib/view-models/LeagueMemberViewModel.ts
2025-12-17 18:01:47 +01:00

39 lines
998 B
TypeScript

import { LeagueMemberDto, DriverDto } from '../dtos';
export class LeagueMemberViewModel implements LeagueMemberDto {
driverId: string;
driver?: DriverDto;
role: string;
joinedAt: string;
private currentUserId: string;
constructor(dto: LeagueMemberDto, currentUserId: string) {
Object.assign(this, dto);
this.currentUserId = currentUserId;
}
/** UI-specific: Formatted join date */
get formattedJoinedAt(): string {
return new Date(this.joinedAt).toLocaleDateString();
}
/** UI-specific: Badge variant for role */
get roleBadgeVariant(): string {
switch (this.role) {
case 'owner': return 'primary';
case 'admin': return 'secondary';
default: return 'default';
}
}
/** 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.currentUserId;
}
}