2023-02-06 12:19:39 +03:00

28 lines
775 B
TypeScript

import type { ReactionsContext } from '@/process/types';
import { reaction } from 'mobx';
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 {
finGAPInsuranceCompany,
hasPaymentsErrors,
};
},
({ hasPaymentsErrors, finGAPInsuranceCompany }) => {
$tables.fingap.validate({
invalid: finGAPInsuranceCompany !== null && hasPaymentsErrors,
message: 'Неверно заполнены платежи',
});
},
{
fireImmediately: true,
}
);
}