import { LeagueSummaryDto } from '../dtos';

export class LeagueSummaryViewModel implements LeagueSummaryDto {
  id: string;
  name: string;
  description?: string;
  logoUrl?: string;
  coverImage?: string;
  memberCount: number;
  maxMembers: number;
  isPublic: boolean;
  ownerId: string;
  ownerName?: string;
  scoringType?: string;
  status?: string;

  constructor(dto: LeagueSummaryDto) {
    Object.assign(this, dto);
  }

  /** UI-specific: Formatted capacity display */
  get formattedCapacity(): string {
    return `${this.memberCount}/${this.maxMembers}`;
  }

  /** UI-specific: Capacity bar percentage */
  get capacityBarPercent(): number {
    return (this.memberCount / this.maxMembers) * 100;
  }

  /** UI-specific: Label for join button */
  get joinButtonLabel(): string {
    if (this.isFull) return 'Full';
    return this.isJoinable ? 'Join League' : 'Request to Join';
  }

  /** UI-specific: Whether the league is full */
  get isFull(): boolean {
    return this.memberCount >= this.maxMembers;
  }

  /** UI-specific: Whether the league is joinable */
  get isJoinable(): boolean {
    return this.isPublic && !this.isFull;
  }

  /** UI-specific: Color for member progress */
  get memberProgressColor(): string {
    const percent = this.capacityBarPercent;
    if (percent < 50) return 'green';
    if (percent < 80) return 'yellow';
    return 'red';
  }

  /** UI-specific: Badge variant for status */
  get statusBadgeVariant(): string {
    switch (this.status) {
      case 'active': return 'success';
      case 'inactive': return 'secondary';
      default: return 'default';
    }
  }
}