diff --git a/Components/Output/Validation.jsx b/Components/Output/Validation.jsx
index e1467fd..43db968 100644
--- a/Components/Output/Validation.jsx
+++ b/Components/Output/Validation.jsx
@@ -9,31 +9,56 @@ const Bold = styled.span`
font-weight: bold;
`;
-const Errors = observer(() => {
- const { $calculation } = useStore();
-
- if (!$calculation.$validation.hasErrors()) {
- return ;
- }
+function Message(title, text) {
+ return (
+ <>
+ {title}
+ {': '}
+ {text}
+ >
+ );
+}
+function getElementsErrors($calculation) {
const { elementsErrors } = $calculation.$validation;
const errors = Object.keys(elementsErrors).map((elementName) => {
const elementErrors = elementsErrors[elementName];
const elementTitle = titles[elementName];
- return elementErrors.map((error) => {
- const message = (
- <>
- {elementTitle}
- {': '}
- {error.text}
- >
- );
-
- return ;
- });
+ return elementErrors.map((error) => (
+
+ ));
});
+ return errors;
+}
+
+function getPaymentsTableErrors($tables) {
+ const { payments } = $tables;
+ const messages = payments.validation.getMessages();
+ const title = payments.validation.params.err_title;
+
+ return messages.map((text) => );
+}
+
+function getInsuranceTableErrors($tables) {
+ const { insurance } = $tables;
+ const messages = insurance.validation.getMessages();
+
+ return messages.map((message) => );
+}
+
+const Errors = observer(() => {
+ const { $calculation, $tables } = useStore();
+
+ const elementsErrors = getElementsErrors($calculation);
+ const paymentsErrors = getPaymentsTableErrors($tables);
+ const insuranceErrors = getInsuranceTableErrors($tables);
+
+ const errors = [...elementsErrors, ...paymentsErrors, ...insuranceErrors];
+
+ if (errors.length === 0) return ;
+
return {errors};
});
diff --git a/pages/index.tsx b/pages/index.tsx
index db34709..2069a21 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -6,6 +6,7 @@ import type { BaseOption } from 'Elements/types';
import type { GetServerSideProps } from 'next';
import Head from 'next/head';
import leadOpportunityUrlsReactions from 'process/lead-opportunity/reactions/urls';
+import paymentsReactions from 'process/payments/reactions';
import { fetchUser } from 'services/user';
import { getDomainName } from 'services/user/tools';
import { useStore } from 'stores/hooks';
@@ -46,6 +47,7 @@ function Home({ graphQLData }: PageProps) {
* add reactions to store
*/
leadOpportunityUrlsReactions(store, apolloClient);
+ paymentsReactions(store, apolloClient);
/**
* set graphql data to store
diff --git a/process/payments/reactions.ts b/process/payments/reactions.ts
new file mode 100644
index 0000000..aa22b1e
--- /dev/null
+++ b/process/payments/reactions.ts
@@ -0,0 +1,27 @@
+import type { ApolloClient } from '@apollo/client';
+import { reaction } from 'mobx';
+import type RootStore from 'stores/root';
+
+export default function paymentsReactions(store: RootStore, apolloClient: ApolloClient