From ff465ae65eedaace7f70e15570bcd88ef997515a Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Mon, 30 Jan 2023 11:37:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B2=20=D0=BF=D0=BE=D0=BB=D0=B5=20=D0=A2?= =?UTF-8?q?=D0=B8=D0=BF=20=D0=B4=D0=B5=D0=B3=D1=80=D0=B5=D1=81=D1=81=D0=B8?= =?UTF-8?q?=D0=B8/=D1=81=D0=B5=D0=B7=D0=BE=D0=BD=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=B8=20selectSeasonType=20=D0=B4=D0=BE=D0=BB=D0=B6=D0=BD?= =?UTF-8?q?=D1=8B=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=D1=81=D1=8F=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20?= =?UTF-8?q?=D1=82=D0=B5=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?,=20=20=20=20*=20=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=8B=D1=85=20?= =?UTF-8?q?=D0=BD=D0=B5=D1=82=20=D0=B2=20=D0=BC=D0=B0=D1=81=D1=81=D0=B8?= =?UTF-8?q?=D0=B2=D0=B5=20=D0=BF=D0=BE=D0=BB=D1=8F=20"=D0=9D=D0=B5=D0=B4?= =?UTF-8?q?=D0=BE=D0=BF=D1=83=D1=81=D1=82=D0=B8=D0=BC=D1=8B=D0=B5=20=D0=A2?= =?UTF-8?q?=D0=B8=D0=BF=D1=8B=20=D0=B4=D0=B5=D0=B3=D1=80=D0=B5=D1=81=D1=81?= =?UTF-8?q?=D0=B8=D0=B9/=D1=81=D0=B5=D0=B7=D0=BE=D0=BD=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B8"=20evo=5Fseasons=5Ftype=5Fexception=20=20=20=20*?= =?UTF-8?q?=20(=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B2?= =?UTF-8?q?=20=D1=82=D0=B5=D0=BA=D1=83=D1=89=D1=83=D1=8E=20=D1=84=D0=B8?= =?UTF-8?q?=D0=BB=D1=8C=D1=82=D1=80=D0=B0=D1=86=D0=B8=D1=8E=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/graphql/crm.types.ts | 2 +- apps/web/process/configurator/lib/query.ts | 1 + .../process/configurator/reactions/filters.ts | 47 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/apps/web/graphql/crm.types.ts b/apps/web/graphql/crm.types.ts index 4eeee4d..fb796b3 100644 --- a/apps/web/graphql/crm.types.ts +++ b/apps/web/graphql/crm.types.ts @@ -127,7 +127,7 @@ export type GetTarif_ProcessConfiguratorQueryVariables = Exact<{ }>; -export type GetTarif_ProcessConfiguratorQuery = { __typename?: 'Query', evo_tarif: { __typename?: 'evo_tarif', evo_irr: number | null, evo_graphtype_exception: Array | null } | null }; +export type GetTarif_ProcessConfiguratorQuery = { __typename?: 'Query', evo_tarif: { __typename?: 'evo_tarif', evo_irr: number | null, evo_graphtype_exception: Array | null, evo_seasons_type_exception: Array | null } | null }; export type GetLeaseObjectTypes_ProcessConfiguratorQueryVariables = Exact<{ [key: string]: never; }>; diff --git a/apps/web/process/configurator/lib/query.ts b/apps/web/process/configurator/lib/query.ts index 14e052e..211dbc1 100644 --- a/apps/web/process/configurator/lib/query.ts +++ b/apps/web/process/configurator/lib/query.ts @@ -6,6 +6,7 @@ export const QUERY_GET_TARIF = gql` evo_tarif(evo_tarifid: $tarifId) { evo_irr evo_graphtype_exception + evo_seasons_type_exception } } `; diff --git a/apps/web/process/configurator/reactions/filters.ts b/apps/web/process/configurator/reactions/filters.ts index 7a9a814..d140f2e 100644 --- a/apps/web/process/configurator/reactions/filters.ts +++ b/apps/web/process/configurator/reactions/filters.ts @@ -2,7 +2,9 @@ import { gql } from '@apollo/client'; import type * as CRMTypes from 'graphql/crm.types'; import { reaction } from 'mobx'; +import { SEASON_TYPES } from 'process/payments/lib/seasons-constants'; import type { ReactionsContext } from 'process/types'; +import { diff } from 'radash'; import { normalizeOptions } from 'tools'; import { QUERY_GET_TARIF } from '../lib/query'; @@ -302,4 +304,49 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex $calculation.element('radioGraphType').setOptions(filteredGraphTypes); } ); + + /** + * в поле Тип дегрессии/сезонности selectSeasonType должны отображаться только те значения, + * которых нет в массиве поля "Недопустимые Типы дегрессий/сезонности" evo_seasons_type_exception + * (добавить в текущую фильтрацию поля) + */ + reaction( + () => ({ + tarif: $calculation.element('selectTarif').getValue(), + graphType: $calculation.element('radioGraphType').getValue(), + }), + async ({ tarif, graphType }) => { + let evo_tarif: CRMTypes.GetTarif_ProcessConfiguratorQuery['evo_tarif'] = null; + + if (tarif) { + const { data } = await apolloClient.query< + CRMTypes.GetTarif_ProcessConfiguratorQuery, + CRMTypes.GetTarif_ProcessConfiguratorQueryVariables + >({ + query: QUERY_GET_TARIF, + variables: { + tarifId: tarif, + }, + }); + + ({ evo_tarif } = data); + } + + const seasonTypesExeption = evo_tarif?.evo_seasons_type_exception || []; + let seasonTypes: Array = []; + + if (graphType === 100_000_001 || graphType === 100_000_003) { + seasonTypes = SEASON_TYPES[graphType]; + } + + const allowedSeasonTypes = diff(seasonTypes, seasonTypesExeption); + + const filteredSeasonTypesOptions = $calculation + .element('selectSeasonType') + .getOptions() + .filter((seasonTypeOption) => allowedSeasonTypes.includes(seasonTypeOption.value)); + + $calculation.element('selectSeasonType').setOptions(filteredSeasonTypesOptions); + } + ); }