Chika 441f9aadbd validation: show tables errors
payments: generate table on changing leasingPeriod
2022-07-09 15:10:21 +03:00

28 lines
648 B
TypeScript

import type { ApolloClient } from '@apollo/client';
import { reaction } from 'mobx';
import type RootStore from 'stores/root';
export default function paymentsReactions(store: RootStore, apolloClient: ApolloClient<object>) {
const { $calculation } = store;
reaction(
() => $calculation.$values.getValue('leasingPeriod'),
(leasingPeriod) => {
if (leasingPeriod) {
const { $tables } = store;
$tables.payments.setValues(
Array.from(
{
length: leasingPeriod,
},
() => 0
)
);
}
},
{
fireImmediately: true,
}
);
}