diff --git a/apps/web/process/fingap/reactions/index.ts b/apps/web/process/fingap/reactions/index.ts index c8077ba..af23c4e 100644 --- a/apps/web/process/fingap/reactions/index.ts +++ b/apps/web/process/fingap/reactions/index.ts @@ -1 +1,2 @@ export { default as common } from './common'; +export { default as init } from './init'; diff --git a/apps/web/process/fingap/reactions/init.ts b/apps/web/process/fingap/reactions/init.ts new file mode 100644 index 0000000..2eaacef --- /dev/null +++ b/apps/web/process/fingap/reactions/init.ts @@ -0,0 +1,33 @@ +import type { ProcessContext } from '@/process/types'; +import { when } from 'mobx'; + +export default function reactions({ store }: ProcessContext) { + const { $tables } = store; + + /** + * Устанавливаем СК фингап по умолчанию при загрузке страницы + */ + when(() => { + const finGAPInsuranceCompanies = $tables.insurance.row('fingap').getOptions('insuranceCompany'); + if (finGAPInsuranceCompanies.length) { + $tables.insurance + .row('fingap') + .setValue('insuranceCompany', finGAPInsuranceCompanies[0]?.value); + } + + return Boolean(finGAPInsuranceCompanies.length); + }); + + /** + * Устанавливаем все риски ФинГАП по умолчанию при загрузке страницы + */ + when(() => { + const { risks } = $tables.fingap; + + if (risks.length) { + $tables.fingap.setSelectedKeys(risks.map((x) => x.key)); + } + + return Boolean(risks.length); + }); +}