2023-01-10 14:46:27 +03:00

28 lines
773 B
TypeScript

import { reaction } from 'mobx';
import type { ReactionsContext } from 'process/types';
export default function validationReactions({ store }: ReactionsContext) {
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,
}
);
}