import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';

@Component({
  selector: 'app-cart-icon',
  imports: [],
  templateUrl: './cart-icon.component.html',
  styleUrl: './cart-icon.component.scss',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CartIconComponent {
  readonly quantity = input<number | null | undefined>(undefined);
  readonly disabled = input(false);
  readonly ariaLabel = input<string>('Carrito de compras');

  protected readonly hasQuantity = computed(() => {
    if (this.disabled()) {
      return false;
    }

    const q = this.quantity();
    return q !== null && q !== undefined && q > 0;
  });
}
