import { DecimalPipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, inject } from '@angular/core';
import { Product } from '../../../../../core/products/models/product-domain.model';
import { TranslatePipe } from '../../../../../i18n/translate.pipe';
import { CurrencyConvertPipe } from '../../../../../pipes/currency-convert.pipe';
import { LanguageService } from '../../../../../services/language.service';
import { getBadgeClass } from '../../../../../utils/item.utils';

@Component({
  selector: 'app-product-information',
  standalone: true,
  imports: [DecimalPipe, TranslatePipe, CurrencyConvertPipe],
  templateUrl: './product-information.component.html',
  styleUrls: ['./product-information.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class ProductInformationComponent {
  private readonly languageService = inject(LanguageService);
  readonly displayCurrency = this.languageService.currentCurrency;

  @Input({ required: true }) product!: Product;
  @Input() title = '';
  @Input() price = 0;
  @Input() discountedPrice = 0;
  @Input() currency = '';
  @Input() remaining: number | null = null;
  @Input() stockStatus = 'high';
  @Input() showAddToCart = true;

  @Output() addToCart = new EventEmitter<void>();

  readonly getBadgeClass = getBadgeClass;
}
