2023-02-28 09:46:31 +03:00

32 lines
833 B
TypeScript

import type { ProcessContext } from '@/process/types';
import { reaction } from 'mobx';
export default function reactions({ store }: ProcessContext) {
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: 'Неверно заполнены платежи',
});
if (hasPaymentsErrors) {
$tables.fingap.clear();
}
},
{
fireImmediately: true,
}
);
}