From 81a10296a96afc29f9661cfe40b628302ebd8e68 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Mon, 30 Jan 2023 17:25:45 +0300 Subject: [PATCH] =?UTF-8?q?bdc360f:=20=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/config/default-options.ts | 47 ++++++++++--------- .../process/configurator/reactions/filters.ts | 18 +++---- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/apps/web/config/default-options.ts b/apps/web/config/default-options.ts index 8d02a62..d63f7c5 100644 --- a/apps/web/config/default-options.ts +++ b/apps/web/config/default-options.ts @@ -46,6 +46,30 @@ export const selectHighSeasonStart = Array.from( }) ); +export const radioGraphType = [ + { + label: 'аннуитет', + value: 100_000_000, + }, + { + label: 'дегрессия (ступенчатая)', + value: 100_000_001, + }, + { + label: 'равноубывающий', + value: 100_000_002, + }, + { + label: 'сезонный', + value: 100_000_003, + }, + { + label: 'легкий старт', + value: 100_000_004, + disabled: true, + }, +]; + const defaultOptions: CalculationOptions = { radioLastPaymentRule: [ { @@ -73,28 +97,7 @@ const defaultOptions: CalculationOptions = { }, ], - radioGraphType: [ - { - label: 'аннуитет', - value: 100_000_000, - }, - { - label: 'дегрессия (ступенчатая)', - value: 100_000_001, - }, - { - label: 'равноубывающий', - value: 100_000_002, - }, - { - label: 'сезонный', - value: 100_000_003, - }, - { - label: 'легкий старт', - value: 100_000_004, - }, - ], + radioGraphType, selectSeasonType, diff --git a/apps/web/process/configurator/reactions/filters.ts b/apps/web/process/configurator/reactions/filters.ts index ff4d640..7fa0824 100644 --- a/apps/web/process/configurator/reactions/filters.ts +++ b/apps/web/process/configurator/reactions/filters.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ import { gql } from '@apollo/client'; -import { selectSeasonType } from 'config/default-options'; +import { radioGraphType, selectSeasonType } from 'config/default-options'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import type * as CRMTypes from 'graphql/crm.types'; @@ -323,15 +323,15 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex ({ evo_tarif } = data); } - const filteredGraphTypes = $calculation - .element('radioGraphType') - .getOptions() - .map((type) => ({ - ...type, - disabled: evo_tarif?.evo_graphtype_exception?.includes(type.value), - })); + if (evo_tarif?.evo_graphtype_exception?.length) { + const filteredGraphTypes = radioGraphType.filter( + (type) => !evo_tarif?.evo_graphtype_exception?.includes(type.value) + ); - $calculation.element('radioGraphType').setOptions(filteredGraphTypes); + $calculation.element('radioGraphType').setOptions(filteredGraphTypes); + } else { + $calculation.element('radioGraphType').resetOptions(); + } } );