process/supplier-agent: trigger validation on change condition options

This commit is contained in:
vchikalkin 2023-03-10 09:27:30 +03:00
parent ba283d3b99
commit 630b6733ed

View File

@ -14,8 +14,8 @@ export default function reactions(context: ProcessContext) {
const helper = new ValidationHelper();
reaction(
() =>
$calculation.$values.getValues([
() => {
const values = $calculation.$values.getValues([
'calcBrokerRewardCondition',
'calcBrokerRewardSum',
'calcDoubleAgentRewardCondition',
@ -35,8 +35,22 @@ export default function reactions(context: ProcessContext) {
'indAgentRewardSumm',
'calcDoubleAgent',
'calcBroker',
]),
async (values) => {
]);
const options = (
[
'selectCalcBrokerRewardCondition',
'selectCalcDoubleAgentRewardCondition',
'selectDealerBrokerRewardCondition',
'selectDealerRewardCondition',
'selectFinDepartmentRewardCondtion',
'selectIndAgentRewardCondition',
] as Elements[]
).map((elementName) => $calculation.element(elementName).getOptions());
return { options, values };
},
async ({ values }) => {
helper.removeErrors();
const validationResult = await validationSchema.safeParseAsync(values);