Components/Output: set active key validation if hasErrors

This commit is contained in:
vchikalkin 2023-05-24 11:46:01 +03:00
parent 2800184cfe
commit 4383bc54b3

View File

@ -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 (
<Wrapper>