import { ChangeDetectionStrategy, Component, inject, input } from '@angular/core';
import { DatePipe } from '@angular/common';
import { TranslatePipe } from '../../../../../i18n/translate.pipe';
import { TranslateService } from '../../../../../i18n/translate.service';
import { CardComponent } from '../../../../../shared/ui/card/card.component';
import { DashboardMetricComponent } from '../../../dashboard/components/dashboard-metric.component';
import { AdminModerationDashboardStats } from '../../facade/admin-moderation.facade';

@Component({
  selector: 'app-moderation-dashboard',
  standalone: true,
  imports: [TranslatePipe, DatePipe, CardComponent, DashboardMetricComponent],
  templateUrl: './moderation-dashboard.component.html',
  styleUrl: './moderation-dashboard.component.scss',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ModerationDashboardComponent {
  private readonly translate = inject(TranslateService);

  readonly stats = input.required<AdminModerationDashboardStats>();

  activityText(entry: AdminModerationDashboardStats['recentActivity'][number]): string {
    const status = entry.status ? this.translate.t('adminModeration.status.' + entry.status) : '';
    return this.translate.t('adminModeration.timelineEvent.' + entry.eventKey, { status });
  }
}
