import { DecimalPipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, Input, 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';

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

  @Input({ required: true }) product!: Product;
  @Input() currency = '';

  get hasDeliveryInfo(): boolean {
    return this.product.deliveryMode === 'digital' || !!this.product.deliveryOptions?.length;
  }
}
