import { Component, ChangeDetectionStrategy } from '@angular/core';
import { PurchasingOptionsListModalStore } from '../purchasing-options-list-modal.store';

@Component({
  selector: 'page-delivery-option-list',
  templateUrl: 'delivery-option-list.component.html',
  styleUrls: ['../list-options.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DeliveryOptionListComponent {
  selectedOption$ = this._store.selectedFilterOption$;
  optionChipDisabled$ = this._store.fetchingAvailabilities$;

  constructor(private _store: PurchasingOptionsListModalStore) {}

  optionChange(option: string) {
    if (this._store.selectedFilterOption === option) {
      this._store.selectedFilterOption = undefined;
    } else {
      this._store.selectedFilterOption = option;
    }
  }
}
