From 8bdbbaab514b2331ba101e21a4c9e1171b632f6c Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 31 Jan 2024 10:27:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=95=D1=81=D0=BB=D0=B8=20=D0=9F=D0=BB=D0=B0?= =?UTF-8?q?=D0=B2=D0=B0=D1=8E=D1=89=D0=B0=D1=8F=20=D1=81=D1=82=D0=B0=D0=B2?= =?UTF-8?q?=D0=BA=D0=B0=20=3D=20=D0=94=D0=B0=20=D0=B8=20=D0=9B=D0=B8=D0=B7?= =?UTF-8?q?=D0=B8=D0=BD=D0=B3=20=D0=B1=D0=B5=D0=B7=20=D0=9A=D0=90=D0=A1?= =?UTF-8?q?=D0=9A=D0=9E=20=D1=81=D0=BE=D0=B4=D0=B5=D1=80=D0=B6=D0=B8=D1=82?= =?UTF-8?q?=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit то выводить сообщение "При плавающей ставке нельзя оформлять Лизинг без КАСКО" --- apps/web/process/configurator/validation.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/web/process/configurator/validation.ts b/apps/web/process/configurator/validation.ts index 5572c06..2cbd57f 100644 --- a/apps/web/process/configurator/validation.ts +++ b/apps/web/process/configurator/validation.ts @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/cognitive-complexity */ import type { ValidationContext } from '../types'; import elementsProps from '@/Components/Calculation/config/elements-props'; import { getElementName } from '@/Components/Calculation/config/map/values'; @@ -24,6 +25,7 @@ const Schema = ValuesSchema.pick({ finDepartmentRewardSumm: true, firstPaymentPerc: true, firstPaymentRub: true, + floatingRate: true, importProgramSum: true, importerRewardPerc: true, importerRewardRub: true, @@ -38,6 +40,7 @@ const Schema = ValuesSchema.pick({ leaseObjectPriceWthtVAT: true, leaseObjectYear: true, leasingPeriod: true, + leasingWithoutKasko: true, maxMass: true, maxPriceChange: true, maxSpeed: true, @@ -93,6 +96,19 @@ export function createValidationSchema({ apolloClient }: ValidationContext) { } } + /** + * Если Плавающая ставка = Да и Лизинг без КАСКО содержит данные, + * то выводить сообщение "При плавающей ставке нельзя оформлять Лизинг без КАСКО" + */ + const { floatingRate, leasingWithoutKasko } = values; + if (floatingRate && leasingWithoutKasko) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: 'При плавающей ставке нельзя оформлять Лизинг без КАСКО', + path: ['selectLeasingWithoutKasko'], + }); + } + (Object.keys(values) as Values[]).forEach((valueName) => { const elementName = getElementName(valueName); if (elementName) {