import { ChangeDetectionStrategy, Component, EventEmitter, Output, input } from '@angular/core';
import { TranslatePipe } from '../../../../../i18n/translate.pipe';
import { ButtonComponent } from '../../../../../shared/ui/button/button.component';
import { CardComponent } from '../../../../../shared/ui/card/card.component';
import { DashboardMetricComponent } from '../../../dashboard/components/dashboard-metric.component';
import { AdminProductsDashboardStats } from '../../facade/admin-products.facade';

@Component({
  selector: 'app-products-dashboard',
  standalone: true,
  imports: [TranslatePipe, ButtonComponent, CardComponent, DashboardMetricComponent],
  templateUrl: './products-dashboard.component.html',
  styleUrl: './products-dashboard.component.scss',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ProductsDashboardComponent {
  readonly stats = input.required<AdminProductsDashboardStats>();

  @Output() openProduct = new EventEmitter<string>();

  goRecommended(): void {
    const id = this.stats().recommendation.productId;
    if (id) {
      this.openProduct.emit(id);
    }
  }
}
