From a76c5f234d7df2fb4f19aa60b572e99cd267946e Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 27 Oct 2022 10:58:38 +0300 Subject: [PATCH] fix display validation --- Components/Output/Validation.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Components/Output/Validation.jsx b/Components/Output/Validation.jsx index ac74c9a..0f20056 100644 --- a/Components/Output/Validation.jsx +++ b/Components/Output/Validation.jsx @@ -49,14 +49,22 @@ function getInsuranceTableErrors($tables) { const Errors = observer(() => { const { $calculation, $tables } = useStore(); + const hasElementsErrors = Object.values($calculation.$validation).some( + (validation) => validation.hasErrors + ); + const hasPaymentsErrors = $tables.payments.validation.hasErrors; + const hasInsuranceErrors = $tables.insurance.validation.hasErrors; + + if (!hasElementsErrors && !hasPaymentsErrors && !hasInsuranceErrors) { + return ; + } + const elementsErrors = getElementsErrors($calculation); const paymentsErrors = getPaymentsTableErrors($tables); const insuranceErrors = getInsuranceTableErrors($tables); const errors = [...elementsErrors, ...paymentsErrors, ...insuranceErrors]; - if (errors.length === 0) return ; - return {errors}; });