import { LeagueMemberDTO } from '@/lib/types/generated/LeagueMemberDTO';
import { DriverViewModel } from './DriverViewModel';

export class LeagueMemberViewModel {
  driverId: string;

  currentUserId: string;

  constructor(dto: LeagueMemberDTO, currentUserId: string) {
    this.driverId = dto.driverId;
    this.currentUserId = currentUserId;
  }

  // Note: The generated DTO is incomplete
  // These fields will need to be added when the OpenAPI spec is updated
  driver?: DriverViewModel;
  role: string = 'member';
  joinedAt: string = new Date().toISOString();

  /** 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;
  }
}