diff --git a/src/client/stores/CalculationStore/Effects/lib/validate.ts b/src/client/stores/CalculationStore/Effects/lib/validate.ts index 9256d15..ac797c0 100644 --- a/src/client/stores/CalculationStore/Effects/lib/validate.ts +++ b/src/client/stores/CalculationStore/Effects/lib/validate.ts @@ -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(); };