process/configurator: auto set value for specific fields

This commit is contained in:
vchikalkin 2023-03-02 15:26:03 +03:00
parent 86c9bdb113
commit fc3610079d

View File

@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/naming-convention */
import type { Elements } from '@/Components/Calculation/config/map/values';
import * as CRMTypes from '@/graphql/crm.types';
import type { ProcessContext } from '@/process/types';
import dayjs from 'dayjs';
@ -174,4 +175,29 @@ export default function valuesReactions({ store, apolloClient }: ProcessContext)
$calculation.element('tbxCreditRate').setValue(evo_rate?.evo_base_rate);
}
);
(
[
'selectProduct',
'selectLeaseObjectType',
'selectBrand',
'selectModel',
'selectConfiguration',
'selectTracker',
'selectTelematic',
'selectTechnicalCard',
'selectFuelCard',
'selectRegistration',
'selectTownRegistration',
] as Elements[]
).forEach((elementName) => {
reaction(
() => $calculation.element(elementName).getOptions(),
(options) => {
if (options.length === 1) {
$calculation.element(elementName).setValue(options[0]?.value);
}
}
);
});
}