diff --git a/apps/web/process/add-product/reactions.ts b/apps/web/process/add-product/reactions.ts index b6baa39..38cbfe5 100644 --- a/apps/web/process/add-product/reactions.ts +++ b/apps/web/process/add-product/reactions.ts @@ -7,11 +7,11 @@ import * as CRMTypes from '@/graphql/crm.types'; import { getCurrentDateString } from '@/utils/date'; import { normalizeOptions } from '@/utils/entity'; import { debouncedReaction } from '@/utils/mobx'; -import { reaction } from 'mobx'; +import { reaction, toJS } from 'mobx'; import { max } from 'radash'; export default function reactions({ store, apolloClient }: ProcessContext) { - const { $calculation, $process } = store; + const { $calculation, $tables, $process } = store; reaction( () => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType', 'maxMass']), @@ -160,35 +160,35 @@ export default function reactions({ store, apolloClient }: ProcessContext) { } ); - // reaction( - // () => { - // const values = $calculation.$values.getValues(['leasingPeriod', 'leasingWithoutKasko']); - // const kaskoInsured = toJS($tables.insurance.row('kasko').getValue('insured')); - // const fingapInsured = toJS($tables.insurance.row('fingap').getValue('insured')); + reaction( + () => { + const values = $calculation.$values.getValues(['leasingPeriod', 'leasingWithoutKasko']); + const kaskoInsured = toJS($tables.insurance.row('kasko').getValue('insured')); + const fingapInsured = toJS($tables.insurance.row('fingap').getValue('insured')); - // return { - // ...values, - // fingapInsured, - // kaskoInsured, - // }; - // }, - // ({ leasingPeriod, fingapInsured, kaskoInsured, leasingWithoutKasko }) => { - // if ( - // leasingPeriod < 12 || - // leasingWithoutKasko || - // kaskoInsured === 100_000_001 || - // (fingapInsured === 100_000_001 && leasingPeriod < 36) - // ) { - // $calculation.element('selectInsNSIB').resetValue().block(); - // } else { - // $calculation.element('selectInsNSIB').unblock(); - // } - // }, - // { - // delay: 10, - // fireImmediately: true, - // } - // ); + return { + ...values, + fingapInsured, + kaskoInsured, + }; + }, + ({ leasingPeriod, fingapInsured, kaskoInsured, leasingWithoutKasko }) => { + if ( + leasingPeriod < 12 || + leasingWithoutKasko || + kaskoInsured === 100_000_001 || + (fingapInsured === 100_000_001 && leasingPeriod < 36) + ) { + $calculation.element('selectInsNSIB').resetValue().block(); + } else { + $calculation.element('selectInsNSIB').unblock(); + } + }, + { + delay: 10, + fireImmediately: true, + } + ); debouncedReaction( () =>