import { TeamMemberDto, DriverDto } from '../dtos';

export class TeamMemberViewModel implements TeamMemberDto {
  driverId: string;
  driver?: DriverDto;
  role: string;
  joinedAt: string;

  private currentUserId: string;
  private teamOwnerId: string;

  constructor(dto: TeamMemberDto, currentUserId: string, teamOwnerId: string) {
    Object.assign(this, dto);
    this.currentUserId = currentUserId;
    this.teamOwnerId = teamOwnerId;
  }

  /** UI-specific: Role badge variant */
  get roleBadgeVariant(): string {
    switch (this.role) {
      case 'owner': return 'primary';
      case 'captain': return 'secondary';
      case 'member': return 'default';
      default: return 'default';
    }
  }

  /** UI-specific: Whether this member is the owner */
  get isOwner(): boolean {
    return this.driverId === this.teamOwnerId;
  }

  /** UI-specific: Whether current user can manage this member */
  get canManage(): boolean {
    return this.currentUserId === this.teamOwnerId && this.driverId !== this.currentUserId;
  }

  /** UI-specific: Whether this is the current user */
  get isCurrentUser(): boolean {
    return this.driverId === this.currentUserId;
  }

  /** UI-specific: Formatted joined date */
  get formattedJoinedAt(): string {
    return new Date(this.joinedAt).toLocaleDateString();
  }
}