From 4383bc54b37e892e83e535409295b60ddc45641b Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 24 May 2023 11:46:01 +0300 Subject: [PATCH] Components/Output: set active key validation if hasErrors --- apps/web/Components/Output/index.jsx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/web/Components/Output/index.jsx b/apps/web/Components/Output/index.jsx index 9e6ff98..90bf543 100644 --- a/apps/web/Components/Output/index.jsx +++ b/apps/web/Components/Output/index.jsx @@ -48,14 +48,30 @@ const Wrapper = styled(Background)` `; const Output = observer(() => { - const { $results } = useStore(); + const { $calculation, $tables, $results } = useStore(); const [activeKey, setActiveKey] = useState(undefined); useEffect(() => { + const hasErrors = + $calculation.hasErrors || + $tables.fingap.hasErrors || + $tables.insurance.hasErrors || + $tables.payments.hasErrors; + if ($results.payments.length > 0) { setActiveKey('payments-table'); } - }, [$results.payments.length]); + + if (hasErrors) { + setActiveKey('validation'); + } + }, [ + $calculation.hasErrors, + $results.payments.length, + $tables.fingap.hasErrors, + $tables.insurance.hasErrors, + $tables.payments.hasErrors, + ]); return (