28 lines
648 B
TypeScript
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,
|
|
}
|
|
);
|
|
}
|