import { Component, Input, Output, EventEmitter } from '@angular/core';
import { CommonModule } from '@angular/common';

interface Case {
  id: string;
  name: string;
  coverImage: string;
  projectType: '工装' | '家装';
  spaceType: '平层' | '复式' | '别墅' | '自建房';
  renderingLevel: '高端' | '中端' | '低端';
  designer: string;
  team: string;
  area: number;
  styleTags: string[];
  customerReview?: string;
  viewCount: number;
  shareCount: number;
  favoriteCount: number;
  isFavorite: boolean;
  isExcellent: boolean;
  createdAt: Date;
}

@Component({
  selector: 'app-case-detail-panel',
  standalone: true,
  imports: [CommonModule],
  templateUrl: './case-detail-panel.component.html',
  styleUrls: ['./case-detail-panel.component.scss']
})
export class CaseDetailPanelComponent {
  @Input() case!: Case;
  @Input() isInternalUser: boolean = false;
  @Output() close = new EventEmitter<void>();
  @Output() toggleFavorite = new EventEmitter<Case>();
  @Output() share = new EventEmitter<Case>();

  closePanel() {
    this.close.emit();
  }

  onToggleFavorite() {
    this.toggleFavorite.emit(this.case);
  }

  onShare() {
    this.share.emit(this.case);
  }

  getFormattedDate(date: Date): string {
    return new Intl.DateTimeFormat('zh-CN', {
      year: 'numeric',
      month: 'long',
      day: 'numeric'
    }).format(new Date(date));
  }
}