import { Query } from '@datorama/akita';
import { pipe } from 'fp-ts/lib/function';
import * as O from 'fp-ts/Option';
import manageBenefitsStore from '../store/manage-benefits.store';
export class ManageBenefitsQuery extends Query {
  constructor(store) {
    super(store);
    this.store = store;
    this.managedBenefits$ = this.select((state) => state.manageBenefitsPageState);
    this.selectedBenefit$ = this.select((state) => state.selectedBenefit);
    this.draftBenefit$ = this.select((state) => state.draftBenefit);
    this.draftBenefitUrl$ = this.select((state) => pipe(state.draftBenefit, O.chain((draft) => draft.url)));
    this.draftBenefitIcon$ = this.select((state) => pipe(state.draftBenefit, O.chain((draft) => draft.icon)));
    this.draftBenefitAttachment$ = this.select((state) => pipe(state.draftBenefit, O.chain((draft) => draft.attachment)));
    this.isLoading$ = this.selectLoading();
  }
}
export default new ManageBenefitsQuery(manageBenefitsStore);
