fix display validation
This commit is contained in:
parent
a163e278c5
commit
a76c5f234d
@ -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 <Alert type="success" showIcon message="Ошибок нет 🙂" />;
|
||||
}
|
||||
|
||||
const elementsErrors = getElementsErrors($calculation);
|
||||
const paymentsErrors = getPaymentsTableErrors($tables);
|
||||
const insuranceErrors = getInsuranceTableErrors($tables);
|
||||
|
||||
const errors = [...elementsErrors, ...paymentsErrors, ...insuranceErrors];
|
||||
|
||||
if (errors.length === 0) return <Alert type="success" showIcon message="Ошибок нет 🙂" />;
|
||||
|
||||
return <Flex flexDirection="column">{errors}</Flex>;
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user