import { initIns } from 'client/Containers/Calculation/Components/ELT/lib/resetIns';
import { IWhenEffect } from 'core/types/Calculation/Store/effect';

const whenEffects: IWhenEffect[] = [
  calculationStore => ({
    predicate: () => {
      const insuranceCompanies = calculationStore.getTableOptions(
        'tableInsurance',
        'insuranceCompany',
      );
      return insuranceCompanies !== undefined && insuranceCompanies.length > 0;
    },
    effect: () => {
      ['osago', 'kasko'].forEach(insType => {
        initIns.call(calculationStore, insType);
      });
    },
  }),
];

export default whenEffects;
