web: process/add-product: disable selectInsNSIB reaction

This commit is contained in:
vchikalkin 2024-07-16 10:13:15 +03:00
parent 4a314326fb
commit 671b25a087

View File

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