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 (