import { Component, Input, Output, EventEmitter } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FmodeObject } from 'fmode-ng/parse';

@Component({
  selector: 'app-project-bottom-card',
  standalone: true,
  imports: [CommonModule],
  templateUrl: './project-bottom-card.component.html',
  styleUrls: ['./project-bottom-card.component.scss']
})
export class ProjectBottomCardComponent {
  @Input() project: FmodeObject | null = null;
  @Input() groupChat: FmodeObject | null = null;
  @Input() currentUser: FmodeObject | null = null;
  @Input() cid: string = '';
  @Input() loading: boolean = false;
  @Input() fileCount: number = 0;
  @Input() memberCount: number = 0;
  @Input() issueCount: number = 0;

  @Output() showFiles = new EventEmitter<void>();
  @Output() showMembers = new EventEmitter<void>();
  @Output() showIssues = new EventEmitter<void>();

  constructor() {}

  onShowFiles() {
    this.showFiles.emit();
  }

  onShowMembers() {
    this.showMembers.emit();
  }

  onShowIssues() {
    this.showIssues.emit();
  }

  getProjectTitle(): string {
    return this.project?.get('title') || '项目详情';
  }

  getProjectStatus(): string {
    return this.project?.get('status') || '未知';
  }

  getStatusClass(): string {
    const status = this.getProjectStatus();
    switch (status) {
      case '进行中':
        return 'status-active';
      case '已完成':
        return 'status-completed';
      case '已暂停':
        return 'status-paused';
      default:
        return 'status-default';
    }
  }
}