From 1db69ce4e246291ee3df021d0d51faa97d5a122e Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Mon, 6 Feb 2023 14:52:23 +0300 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D0=B0=D0=BA=D1=86=D0=B8=D1=8F=20ra?= =?UTF-8?q?dioBalanceHolder=20-=20cbxLastPaymentRedemption?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/process/price/reactions/common.ts | 24 +++++++----------- .../web/process/price/reactions/validation.ts | 25 +++++++++++++++++++ 2 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 apps/web/process/price/reactions/validation.ts diff --git a/apps/web/process/price/reactions/common.ts b/apps/web/process/price/reactions/common.ts index 8be398f..2d0718f 100644 --- a/apps/web/process/price/reactions/common.ts +++ b/apps/web/process/price/reactions/common.ts @@ -1,4 +1,3 @@ -import { MIN_LASTPAYMENT_NSIB } from '@/constants/values'; import type { ReactionsContext } from '@/process/types'; import { reaction } from 'mobx'; @@ -31,20 +30,15 @@ export default function commonReactions({ store }: ReactionsContext) { ); reaction( - () => { - const lastPaymentRub = $calculation.element('tbxLastPaymentRub').getValue(); - const insNSIB = $calculation.element('selectInsNSIB').getValue(); - - return { - insNSIB, - lastPaymentRub, - }; - }, - ({ lastPaymentRub, insNSIB }) => { - $calculation.element('tbxLastPaymentRub').validate({ - invalid: Boolean(insNSIB) && lastPaymentRub < MIN_LASTPAYMENT_NSIB, - message: `Последний платеж меньше ${MIN_LASTPAYMENT_NSIB} руб. не может быть при наличии НСИБ, укажите большее значение`, - }); + () => $calculation.element('radioBalanceHolder').getValue(), + (balanceHolder) => { + if (balanceHolder) { + if (balanceHolder === 100000001) { + $calculation.element('cbxLastPaymentRedemption').setValue(true).block(); + } else { + $calculation.element('cbxLastPaymentRedemption').unblock(); + } + } } ); } diff --git a/apps/web/process/price/reactions/validation.ts b/apps/web/process/price/reactions/validation.ts new file mode 100644 index 0000000..bb2d142 --- /dev/null +++ b/apps/web/process/price/reactions/validation.ts @@ -0,0 +1,25 @@ +import { MIN_LASTPAYMENT_NSIB } from '@/constants/values'; +import type { ReactionsContext } from '@/process/types'; +import { reaction } from 'mobx'; + +export default function commonReactions({ store }: ReactionsContext) { + const { $calculation } = store; + + reaction( + () => { + const lastPaymentRub = $calculation.element('tbxLastPaymentRub').getValue(); + const insNSIB = $calculation.element('selectInsNSIB').getValue(); + + return { + insNSIB, + lastPaymentRub, + }; + }, + ({ lastPaymentRub, insNSIB }) => { + $calculation.element('tbxLastPaymentRub').validate({ + invalid: Boolean(insNSIB) && lastPaymentRub < MIN_LASTPAYMENT_NSIB, + message: `Последний платеж меньше ${MIN_LASTPAYMENT_NSIB} руб. не может быть при наличии НСИБ, укажите большее значение`, + }); + } + ); +}