Components/Output: set active key validation if hasErrors
This commit is contained in:
parent
2800184cfe
commit
4383bc54b3
@ -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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user