From cc1f07d9e4807ede6a52a3b2583e1b9d21fa6414 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 19 Apr 2023 23:43:44 +0300 Subject: [PATCH] =?UTF-8?q?options:=20add=20graphType=20=D0=B8=D0=BD=D0=B4?= =?UTF-8?q?=D0=B8=D0=B2=D0=B8=D0=B4=D1=83=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/config/default-options.ts | 4 ++++ .../process/configurator/reactions/filters.ts | 22 ++++++++++++------- apps/web/process/payments/reactions/common.ts | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/web/config/default-options.ts b/apps/web/config/default-options.ts index 15f6026..f1f9570 100644 --- a/apps/web/config/default-options.ts +++ b/apps/web/config/default-options.ts @@ -68,6 +68,10 @@ export const radioGraphType = [ label: 'легкий старт', value: 100_000_004, }, + { + label: 'индивидуальный график', + value: 100_000_005, + }, ]; export const selectObjectCategoryTax = [ diff --git a/apps/web/process/configurator/reactions/filters.ts b/apps/web/process/configurator/reactions/filters.ts index 5b708d9..8dcc8ed 100644 --- a/apps/web/process/configurator/reactions/filters.ts +++ b/apps/web/process/configurator/reactions/filters.ts @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/cognitive-complexity */ import { radioCalcType, radioGraphType, selectSeasonType } from '@/config/default-options'; import * as CRMTypes from '@/graphql/crm.types'; import { SEASON_TYPES } from '@/process/payments/lib/seasons-constants'; @@ -11,7 +12,7 @@ import { diff } from 'radash'; dayjs.extend(utc); export default function reactions({ store, apolloClient, user }: ProcessContext) { - const { $calculation } = store; + const { $calculation, $process } = store; reaction( () => $calculation.$values.getValues(['dealer', 'importProgram', 'product', 'subsidy']), @@ -20,7 +21,6 @@ export default function reactions({ store, apolloClient, user }: ProcessContext) subsidy: subsidyId, importProgram: importProgramId, dealer: dealerId, - // eslint-disable-next-line sonarjs/cognitive-complexity }) => { /** * #1 @@ -241,15 +241,21 @@ export default function reactions({ store, apolloClient, user }: ProcessContext) ({ evo_tarif } = data); } - if (evo_tarif?.evo_graphtype_exception?.length) { - const filteredGraphTypes = radioGraphType.filter( + let options = radioGraphType; + if (!$process.has('Unlimited')) { + options = options.filter((x) => x.value !== 100_000_005); + } + + if (!$process.has('Unlimited') && evo_tarif?.evo_graphtype_exception?.length) { + options = options.filter( (type) => !evo_tarif?.evo_graphtype_exception?.includes(type.value) ); - - $calculation.element('radioGraphType').setOptions(filteredGraphTypes); - } else { - $calculation.element('radioGraphType').resetOptions(); } + + $calculation.element('radioGraphType').setOptions(options); + }, + { + fireImmediately: true, } ); diff --git a/apps/web/process/payments/reactions/common.ts b/apps/web/process/payments/reactions/common.ts index 419fa05..a9de31d 100644 --- a/apps/web/process/payments/reactions/common.ts +++ b/apps/web/process/payments/reactions/common.ts @@ -53,7 +53,7 @@ export default function reactions({ store }: ProcessContext) { }; }, ({ graphType, leasingPeriod }) => { - if (graphType === 100_000_000) { + if ([100_000_000, 100_000_005].includes(graphType)) { const middlePayments: Row[] = Array.from( { length: leasingPeriod - 2,