import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-dashboard-general',
  templateUrl: './dashboard-general.component.html',
  styleUrls: ['./dashboard-general.component.scss']
})
export class DashboardGeneralComponent implements OnInit {
  
  public autoRefresh = false;
  public selectedView = 'summary';
  public showGeneralKPIs = true;
  public showProjectOverview = true;
  
  public generalKPIs = [
    { title: 'Projets Actifs', value: '12', icon: 'folder_open', color: '#4AA8DC', trend: 'up', variation: 8 },
    { title: 'Équipe Active', value: '8', icon: 'people', color: '#8DA969', trend: 'stable', variation: 0 },
    { title: 'Tâches Terminées', value: '45', icon: 'check_circle', color: '#F59E0B', trend: 'up', variation: 12 },
    { title: 'Performance', value: '94%', icon: 'trending_up', color: '#10B981', trend: 'up', variation: 3 }
  ];
  
  public recentActivities = [
    { user: 'Marie Dupont', action: 'a créé un nouveau projet', time: 'il y a 2 min', color: '#4AA8DC' },
    { user: 'Jean Martin', action: 'a mis à jour le rapport', time: 'il y a 5 min', color: '#8DA969' },
    { user: 'Sophie Bernard', action: 'a terminé une tâche', time: 'il y a 10 min', color: '#F59E0B' }
  ];

  constructor() { }

  ngOnInit(): void {
  }

  toggleAutoRefresh(): void {
    this.autoRefresh = !this.autoRefresh;
  }

  refreshGeneralData(): void {
    console.log('Actualisation des données générales');
  }

  changeView(view: string): void {
    this.selectedView = view;
  }

  toggleGeneralKPIs(): void {
    this.showGeneralKPIs = !this.showGeneralKPIs;
  }

  toggleProjectOverview(): void {
    this.showProjectOverview = !this.showProjectOverview;
  }

  getVariationClass(trend: string): string {
    return trend === 'up' ? 'trend-positive' : trend === 'down' ? 'trend-negative' : '';
  }

  trackByKpiId(index: number, kpi: any): string {
    return kpi.title;
  }

  trackByActivityId(index: number, activity: any): string {
    return activity.user + activity.time;
  }

  formatTimestamp(timestamp: string): string {
    return timestamp;
  }

  getCurrentTime(): Date {
    return new Date();
  }
}