import { TeamDetailsDto, TeamMemberDto } from '../dtos';
import { TeamMemberViewModel } from './TeamMemberViewModel';

export class TeamDetailsViewModel implements TeamDetailsDto {
  id: string;
  name: string;
  description?: string;
  logoUrl?: string;
  memberCount: number;
  ownerId: string;
  members: TeamMemberViewModel[];

  private currentUserId: string;

  constructor(dto: TeamDetailsDto & { members: TeamMemberDto[] }, currentUserId: string) {
    this.id = dto.id;
    this.name = dto.name;
    this.description = dto.description;
    this.logoUrl = dto.logoUrl;
    this.memberCount = dto.memberCount;
    this.ownerId = dto.ownerId;
    this.members = dto.members.map(m => new TeamMemberViewModel(m, currentUserId, dto.ownerId));
    this.currentUserId = currentUserId;
  }

  /** UI-specific: Whether current user is owner */
  get isOwner(): boolean {
    return this.currentUserId === this.ownerId;
  }

  /** UI-specific: Whether can add members */
  get canAddMembers(): boolean {
    return this.isOwner && this.memberCount < 10; // Assuming max 10
  }

  /** UI-specific: Member management actions available */
  get memberActionsAvailable(): boolean {
    return this.isOwner;
  }

  /** UI-specific: Team status */
  get teamStatus(): string {
    if (this.memberCount < 5) return 'Recruiting';
    if (this.memberCount < 10) return 'Active';
    return 'Full';
  }
}