34 lines
929 B
TypeScript

import type { ApolloClient } from '@apollo/client';
import type { QueryClient } from '@tanstack/react-query';
import { reaction } from 'mobx';
import type RootStore from 'stores/root';
export default function validationReactions(
store: RootStore,
apolloClient: ApolloClient<object>,
queryClient: QueryClient
) {
const { $tables } = store;
reaction(
() => {
const hasPaymentsErrors = $tables.payments.validation.hasErrors;
const finGAPInsuranceCompany = $tables.insurance.row('fingap').getValue('insuranceCompany');
return {
hasPaymentsErrors,
finGAPInsuranceCompany,
};
},
({ hasPaymentsErrors, finGAPInsuranceCompany }) => {
$tables.fingap.validate({
invalid: finGAPInsuranceCompany !== null && hasPaymentsErrors,
message: 'Неверно заполнены платежи',
});
},
{
fireImmediately: true,
}
);
}