import { CommonModule } from '@angular/common';
import { Component, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
import { PurchaseOptionsStore } from '../store';
import { BasePurchaseOptionDirective } from './base-purchase-option.directive';
import { IconComponent } from '@shared/components/icon';
import { map, shareReplay } from 'rxjs/operators';

@Component({
  selector: 'app-delivery-purchase-options-tile',
  templateUrl: 'delivery-purchase-options-tile.component.html',
  styleUrls: ['purchase-options-tile.component.css'],
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [CommonModule, IconComponent],
})
export class DeliveryPurchaseOptionTileComponent extends BasePurchaseOptionDirective {
  hasNoInStoreAvailability$ = this.store.purchasingOptions$.pipe(
    map((po) => !(po.includes('delivery') || po.includes('b2b-delivery') || po.includes('dig-delivery'))),
  );

  constructor(
    protected store: PurchaseOptionsStore,
    protected cdr: ChangeDetectorRef,
  ) {
    super('delivery');
  }
}
