2023-05-06 13:52:03 +03:00

48 lines
1.2 KiB
TypeScript

import type { ProcessContext } from '../../types';
import helper from '../lib/helper';
import { reaction, toJS } from 'mobx';
export default function reactions(context: ProcessContext) {
const { store } = context;
const { $calculation, $tables } = store;
const { init } = helper(context);
reaction(
() => ({
kasko: toJS($tables.insurance.row('kasko').getValues()),
osago: toJS($tables.insurance.row('osago').getValues()),
values: $calculation.$values.getValues([
'leaseObjectType',
// osago
'townRegistration',
'legalClientTown',
'legalClientRegion',
'objectRegistration',
'townRegistration',
// kasko
'lead',
'opportunity',
'leaseObjectUseFor',
'leaseObjectCategory',
'insDecentral',
'leasingWithoutKasko',
'insAgeDrivers',
'insExpDrivers',
'vin',
]),
}),
async () => {
const initialValues = await init();
if (initialValues) {
$tables.elt.kasko.setRows(initialValues.kasko);
$tables.elt.osago.setRows(initialValues.osago);
}
},
{
fireImmediately: true,
}
);
}