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 { BadgeComponent } from '../../../../../shared/ui/badge/badge.component';
import { DashboardMetricComponent } from '../../../dashboard/components/dashboard-metric.component';
import { AdminOrdersDashboardStats } from '../../facade/admin-orders.facade';

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

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

  activityText(entry: AdminOrdersDashboardStats['recentActivity'][number]): string {
    return this.translate.t('adminOrders.timelineEvent.' + entry.eventKey, {
      status: this.translate.t('adminOrders.status.' + entry.status),
    });
  }
}
