validate insurance table onCalculate
This commit is contained in:
parent
54869d28f3
commit
af56bb2566
@ -49,6 +49,40 @@ const validateElements = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const validateTables = () => {
|
||||
const tableInsurance = CalculationStore.tables.tableInsurance;
|
||||
|
||||
const kaskoRowIndex = tableInsurance.rows.findIndex(
|
||||
x => x.policyType?.value === 'КАСКО',
|
||||
);
|
||||
const osagoRowIndex = tableInsurance.rows.findIndex(
|
||||
x => x.policyType?.value === 'ОСАГО',
|
||||
);
|
||||
|
||||
const condition =
|
||||
!CalculationStore.tables.tableInsurance.rows[kaskoRowIndex].insuranceCompany
|
||||
?.value ||
|
||||
!CalculationStore.tables.tableInsurance.rows[osagoRowIndex].insuranceCompany
|
||||
?.value;
|
||||
|
||||
CalculationStore.setTableRows(
|
||||
'tableInsurance',
|
||||
0,
|
||||
)([
|
||||
{
|
||||
insuranceCompany: {
|
||||
validation: !condition,
|
||||
},
|
||||
},
|
||||
{
|
||||
insuranceCompany: {
|
||||
validation: !condition,
|
||||
},
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
export default () => {
|
||||
validateElements();
|
||||
validateTables();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user