process/price: add common reactions
This commit is contained in:
parent
d3c805adb6
commit
6172833fdb
@ -4,3 +4,4 @@ export const MIN_INSURANCE = 3000;
|
||||
|
||||
export const RATE = 7.75;
|
||||
export const MAX_LEASING_PERIOD = 60;
|
||||
export const MIN_LASTPAYMENT_NSIB = 3500;
|
||||
|
||||
@ -25,6 +25,7 @@ export default function injectDefaultReactions(context) {
|
||||
agentsReactions.validationReactions(context);
|
||||
leasebackReactions(context);
|
||||
priceReactions.computed(context);
|
||||
priceReactions.common(context);
|
||||
fingapReactions.common(context);
|
||||
fingapReactions.validation(context);
|
||||
setInitialValuesReactions(context);
|
||||
|
||||
50
apps/web/process/price/reactions/common.ts
Normal file
50
apps/web/process/price/reactions/common.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import { MIN_LASTPAYMENT_NSIB } from 'constants/values';
|
||||
import { reaction } from 'mobx';
|
||||
import type { ReactionsContext } from 'process/types';
|
||||
|
||||
export default function commonReactions({ store, apolloClient }: 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(
|
||||
() => {
|
||||
const lastPaymentRub = $calculation.element('tbxLastPaymentRub').getValue();
|
||||
const insNSIB = $calculation.element('selectInsNSIB').getValue();
|
||||
|
||||
return {
|
||||
lastPaymentRub,
|
||||
insNSIB,
|
||||
};
|
||||
},
|
||||
({ lastPaymentRub, insNSIB }) => {
|
||||
$calculation.element('tbxLastPaymentRub').validate({
|
||||
invalid: !!insNSIB && lastPaymentRub < MIN_LASTPAYMENT_NSIB,
|
||||
message: `Последний платеж меньше ${MIN_LASTPAYMENT_NSIB} руб. не может быть при наличии НСИБ, укажите большее значение`,
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -1,2 +1,2 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
export { default as common } from './common';
|
||||
export { default as computed } from './computed';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user