45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import type { ReactionsContext } from '@/process/types';
|
|
import { reaction } from 'mobx';
|
|
|
|
export default function commonReactions({ store }: ReactionsContext) {
|
|
const { $calculation } = store;
|
|
|
|
reaction(
|
|
() => $calculation.element('radioLastPaymentRule').getValue(),
|
|
(lastPaymentRule) => {
|
|
switch (lastPaymentRule) {
|
|
case 100_000_000: {
|
|
$calculation.element('tbxLastPaymentPerc').block();
|
|
$calculation.element('tbxLastPaymentRub').unblock();
|
|
break;
|
|
}
|
|
case 100_000_001: {
|
|
$calculation.element('tbxLastPaymentPerc').unblock();
|
|
$calculation.element('tbxLastPaymentRub').block();
|
|
break;
|
|
}
|
|
default: {
|
|
$calculation.element('tbxLastPaymentPerc').block();
|
|
$calculation.element('tbxLastPaymentRub').block();
|
|
}
|
|
}
|
|
},
|
|
{
|
|
fireImmediately: true,
|
|
}
|
|
);
|
|
|
|
reaction(
|
|
() => $calculation.element('radioBalanceHolder').getValue(),
|
|
(balanceHolder) => {
|
|
if (balanceHolder) {
|
|
if (balanceHolder === 100000001) {
|
|
$calculation.element('cbxLastPaymentRedemption').setValue(true).block();
|
|
} else {
|
|
$calculation.element('cbxLastPaymentRedemption').unblock();
|
|
}
|
|
}
|
|
}
|
|
);
|
|
}
|