From 86c9bdb113106dd2ffb8588d2400043b8ba4a6c2 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 2 Mar 2023 15:16:10 +0300 Subject: [PATCH] process: add insurance reactions --- .../Calculation/Form/Insurance/config.ts | 2 +- .../Calculation/config/elements-components.ts | 2 - .../Calculation/config/elements-props.tsx | 4 - .../Calculation/config/elements-titles.ts | 2 - .../Calculation/config/elements-types.ts | 2 - .../Calculation/config/map/values.ts | 2 - apps/web/config/default-options.ts | 186 +++++++++--------- apps/web/config/default-statuses.ts | 1 - apps/web/config/default-values.ts | 2 - apps/web/config/process/default.ts | 2 + apps/web/config/schema/values.ts | 2 - apps/web/graphql/crm.query.graphql | 7 + apps/web/graphql/crm.types.ts | 8 + apps/web/process/insurance/index.ts | 1 + apps/web/process/insurance/reactions.ts | 112 +++++++++++ .../lead-opportunity/reactions/common.ts | 24 --- 16 files changed, 219 insertions(+), 140 deletions(-) create mode 100644 apps/web/process/insurance/reactions.ts diff --git a/apps/web/Components/Calculation/Form/Insurance/config.ts b/apps/web/Components/Calculation/Form/Insurance/config.ts index d689749..5e69762 100644 --- a/apps/web/Components/Calculation/Form/Insurance/config.ts +++ b/apps/web/Components/Calculation/Form/Insurance/config.ts @@ -6,7 +6,7 @@ export const title = 'Страхование'; export const rows: FormTabRows = [ [['tbxLeaseObjectYear', 'selectLeaseObjectUseFor', 'selectLegalClientRegion']], [['selectEngineType', 'tbxInsFranchise', 'selectLegalClientTown']], - [['selectLeaseObjectCategory', 'tbxMileage', 'tbxINNForCalc']], + [['selectLeaseObjectCategory', 'tbxMileage']], [['tbxLeaseObjectMotorPower', 'cbxWithTrailer', 'selectGPSBrand']], [['tbxEngineVolume', 'cbxInsDecentral', 'selectGPSModel']], [['selectLeasingWithoutKasko', 'selectInsNSIB']], diff --git a/apps/web/Components/Calculation/config/elements-components.ts b/apps/web/Components/Calculation/config/elements-components.ts index 52f00df..e01376e 100644 --- a/apps/web/Components/Calculation/config/elements-components.ts +++ b/apps/web/Components/Calculation/config/elements-components.ts @@ -79,12 +79,10 @@ const components = wrapComponentsMap({ cbxInsUnlimitDrivers: e.Switch, tbxInsAgeDrivers: e.InputNumber, tbxInsExpDrivers: e.InputNumber, - tbxINNForCalc: e.InputNumber, selectGPSBrand: e.Select, selectGPSModel: e.Select, selectRegionRegistration: e.Select, selectTownRegistration: e.Select, - radioInfuranceOPF: e.Radio, selectRegistration: e.Select, selectInsNSIB: e.Select, selectRequirementTelematic: e.Select, diff --git a/apps/web/Components/Calculation/config/elements-props.tsx b/apps/web/Components/Calculation/config/elements-props.tsx index e4933e5..94aca18 100644 --- a/apps/web/Components/Calculation/config/elements-props.tsx +++ b/apps/web/Components/Calculation/config/elements-props.tsx @@ -425,10 +425,6 @@ const props: Partial = { showSearch: true, optionFilterProp: 'label', }, - radioInfuranceOPF: { - optionType: 'button', - buttonStyle: 'solid', - }, radioGraphType: { spaceProps: { direction: 'vertical', diff --git a/apps/web/Components/Calculation/config/elements-titles.ts b/apps/web/Components/Calculation/config/elements-titles.ts index ef7dd2a..555f2bc 100644 --- a/apps/web/Components/Calculation/config/elements-titles.ts +++ b/apps/web/Components/Calculation/config/elements-titles.ts @@ -74,7 +74,6 @@ const titles: Record = { selectGPSModel: 'Модель GPS', selectRegionRegistration: 'Регион регистрации', selectTownRegistration: 'Город регистрации', - radioInfuranceOPF: 'ОПФ для расчета страховки', radioInsKaskoType: 'Тип страхования КАСКО', cbxInsDecentral: 'Децентрализованное страхование', tbxInsFranchise: 'Франшиза', @@ -116,7 +115,6 @@ const titles: Record = { selectObjectCategoryTax: 'Кат. по ТР ТС 018/2011', selectObjectTypeTax: 'Тип ТС для ТН', radioTypePTS: 'Тип ПТС', - tbxINNForCalc: 'ИНН контрагента', selectLegalClientRegion: 'Регион по юр.адресу клиента', selectLegalClientTown: 'Город по юр.адресу клиента', selectSubsidy: 'Субсидия', diff --git a/apps/web/Components/Calculation/config/elements-types.ts b/apps/web/Components/Calculation/config/elements-types.ts index 3fdc4ed..c8675d6 100644 --- a/apps/web/Components/Calculation/config/elements-types.ts +++ b/apps/web/Components/Calculation/config/elements-types.ts @@ -81,7 +81,6 @@ const types = wrapElementsTypes({ cbxInsUnlimitDrivers: t.Value, tbxInsAgeDrivers: t.Value, tbxInsExpDrivers: t.Value, - tbxINNForCalc: t.Value, cbxLastPaymentRedemption: t.Value, cbxPriceWithDiscount: t.Value, cbxFullPriceWithDiscount: t.Value, @@ -156,7 +155,6 @@ const types = wrapElementsTypes({ radioGraphType: t.Options, radioDeliveryTime: t.Options, radioInsKaskoType: t.Options, - radioInfuranceOPF: t.Options, selectRequirementTelematic: t.Options, radioQuoteContactGender: t.Options, radioCalcType: t.Options, diff --git a/apps/web/Components/Calculation/config/map/values.ts b/apps/web/Components/Calculation/config/map/values.ts index ed7a9fd..14b79e2 100644 --- a/apps/web/Components/Calculation/config/map/values.ts +++ b/apps/web/Components/Calculation/config/map/values.ts @@ -80,14 +80,12 @@ const elementsToValues = wrapElementsMap({ selectGPSModel: 'GPSModel', selectRegionRegistration: 'regionRegistration', selectTownRegistration: 'townRegistration', - radioInfuranceOPF: 'infuranceOPF', radioInsKaskoType: 'insKaskoType', cbxInsDecentral: 'insDecentral', tbxInsFranchise: 'insFranchise', cbxInsUnlimitDrivers: 'insUnlimitDrivers', tbxInsAgeDrivers: 'insAgeDrivers', tbxInsExpDrivers: 'insExpDrivers', - tbxINNForCalc: 'INNForCalc', cbxLastPaymentRedemption: 'lastPaymentRedemption', cbxPriceWithDiscount: 'priceWithDiscount', cbxFullPriceWithDiscount: 'fullPriceWithDiscount', diff --git a/apps/web/config/default-options.ts b/apps/web/config/default-options.ts index 3951f64..0f9d68b 100644 --- a/apps/web/config/default-options.ts +++ b/apps/web/config/default-options.ts @@ -97,6 +97,93 @@ export const selectObjectCategoryTax = [ value: 100_000_000 + i, })); +export const selectLeaseObjectUseFor = alphabetical( + [ + { + 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, + }, + { + label: 'Для доставки продуктов конечному потребителю', + value: 100_000_005, + }, + { + label: 'Для обучения вождению', + value: 100_000_006, + }, + { + label: 'Маршрутные такси / Рейсовые автобусы', + value: 100_000_007, + }, + { + label: 'Междугородние перевозки', + value: 100_000_008, + }, + { + label: 'Для перевозки крупногабаритных грузов', + value: 100_000_009, + }, + { + label: 'Для перевозки малогабаритных грузов', + value: 100_000_010, + }, + { + label: 'Для перевозки сотрудников других организаций (водитель ЛП)', + value: 100_000_011, + }, + { + label: 'Для перевозки сотрудников ЛП', + value: 100_000_012, + }, + { + label: 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.', + value: 100_000_013, + }, + { + label: 'Дорожно-строительная техника', + value: 100_000_014, + }, + { + label: 'Жилищно-коммунальное хозяйство', + value: 100_000_015, + }, + { + label: 'Лесное хозяйство', + value: 100_000_016, + }, + { + label: 'Подъёмно-транспортная отрасль', + value: 100_000_017, + }, + { + label: 'Сельское хозяйство', + value: 100_000_018, + }, + { + label: 'Строительство', + value: 100_000_019, + }, + ], + (objectUseFor) => objectUseFor.label.toLowerCase(), + 'asc' +); + const defaultOptions: CalculationOptions = { radioLastPaymentRule: [ { @@ -187,103 +274,7 @@ const defaultOptions: CalculationOptions = { }, ], - selectLeaseObjectUseFor: alphabetical( - [ - { - 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, - }, - { - label: 'Для доставки продуктов конечному потребителю', - value: 100_000_005, - }, - { - label: 'Для обучения вождению', - value: 100_000_006, - }, - { - label: 'Маршрутные такси / Рейсовые автобусы', - value: 100_000_007, - }, - { - label: 'Междугородние перевозки', - value: 100_000_008, - }, - { - label: 'Для перевозки крупногабаритных грузов', - value: 100_000_009, - }, - { - label: 'Для перевозки малогабаритных грузов', - value: 100_000_010, - }, - { - label: 'Для перевозки сотрудников других организаций (водитель ЛП)', - value: 100_000_011, - }, - { - label: 'Для перевозки сотрудников ЛП', - value: 100_000_012, - }, - { - label: 'Для экскурсионных перевозок в т.ч. на торжества; трансфер в аэропорт и пр.', - value: 100_000_013, - }, - { - label: 'Дорожно-строительная техника', - value: 100_000_014, - }, - { - label: 'Жилищно-коммунальное хозяйство', - value: 100_000_015, - }, - { - label: 'Лесное хозяйство', - value: 100_000_016, - }, - { - label: 'Подъёмно-транспортная отрасль', - value: 100_000_017, - }, - { - label: 'Сельское хозяйство', - value: 100_000_018, - }, - { - label: 'Строительство', - value: 100_000_019, - }, - ], - (objectUseFor) => objectUseFor.label.toLowerCase(), - 'asc' - ), - - radioInfuranceOPF: [ - { - label: 'ЮЛ', - value: 100_000_000, - }, - { - label: 'ИП', - value: 100_000_001, - }, - ], + selectLeaseObjectUseFor, radioInsKaskoType: [ { @@ -461,7 +452,6 @@ const defaultOptions: CalculationOptions = { cbxInsUnlimitDrivers: [], tbxInsAgeDrivers: [], tbxInsExpDrivers: [], - tbxINNForCalc: [], cbxLastPaymentRedemption: [], cbxPriceWithDiscount: [], cbxFullPriceWithDiscount: [], diff --git a/apps/web/config/default-statuses.ts b/apps/web/config/default-statuses.ts index b47b4d4..b1a271b 100644 --- a/apps/web/config/default-statuses.ts +++ b/apps/web/config/default-statuses.ts @@ -102,7 +102,6 @@ const defaultStatuses: CalculationStatuses = { tbxFinDepartmentRewardSumm: 'Disabled', tbxFirstPaymentPerc: 'Default', tbxFirstPaymentRub: 'Default', - tbxINNForCalc: 'Disabled', tbxIRR_Perc: 'Default', tbxImportProgramSum: 'Default', tbxImporterRewardPerc: 'Disabled', diff --git a/apps/web/config/default-values.ts b/apps/web/config/default-values.ts index 7f4dee4..bb3e758 100644 --- a/apps/web/config/default-values.ts +++ b/apps/web/config/default-values.ts @@ -55,8 +55,6 @@ const defaultValues: CalculationValues = { indAgent: null, indAgentRewardCondition: null, indAgentRewardSumm: 0, - infuranceOPF: null, - INNForCalc: 0, insAgeDrivers: 0, insDecentral: false, insExpDrivers: 0, diff --git a/apps/web/config/process/default.ts b/apps/web/config/process/default.ts index 5b30aec..25c9010 100644 --- a/apps/web/config/process/default.ts +++ b/apps/web/config/process/default.ts @@ -6,6 +6,7 @@ import * as createKP from '@/process/create-kp'; import * as fingap from '@/process/fingap'; import * as gibdd from '@/process/gibdd'; import { useProcess } from '@/process/hooks'; +import * as insurance from '@/process/insurance'; import * as leadOpportunity from '@/process/lead-opportunity'; import * as leasingObject from '@/process/leasing-object'; import * as leasingWithoutKasko from '@/process/leasing-without-kasko'; @@ -35,4 +36,5 @@ export default function useReactions() { useProcess(payments); useProcess(gibdd); useProcess(addProduct); + useProcess(insurance); } diff --git a/apps/web/config/schema/values.ts b/apps/web/config/schema/values.ts index f05826c..9e60346 100644 --- a/apps/web/config/schema/values.ts +++ b/apps/web/config/schema/values.ts @@ -52,8 +52,6 @@ const ValuesSchema = z indAgent: z.string().nullable(), indAgentRewardCondition: z.string().nullable(), indAgentRewardSumm: z.number(), - infuranceOPF: z.number().nullable(), - INNForCalc: z.number(), insAgeDrivers: z.number(), insDecentral: z.boolean(), insExpDrivers: z.number(), diff --git a/apps/web/graphql/crm.query.graphql b/apps/web/graphql/crm.query.graphql index d0c23d8..38442c8 100644 --- a/apps/web/graphql/crm.query.graphql +++ b/apps/web/graphql/crm.query.graphql @@ -249,6 +249,13 @@ query GetGPSBrands { } } +query GetGPSModels($gpsBrandId: Uuid!) { + evo_gps_models(evo_gps_brandid: $gpsBrandId) { + label: evo_name + value: evo_gps_modelid + } +} + query GetLeaseObjectTypes { evo_leasingobject_types(statecode: 0) { label: evo_name diff --git a/apps/web/graphql/crm.types.ts b/apps/web/graphql/crm.types.ts index 6384842..e480eaf 100644 --- a/apps/web/graphql/crm.types.ts +++ b/apps/web/graphql/crm.types.ts @@ -264,6 +264,13 @@ export type GetGpsBrandsQueryVariables = Exact<{ [key: string]: never; }>; export type GetGpsBrandsQuery = { __typename?: 'Query', evo_gps_brands: Array<{ __typename?: 'evo_gps_brand', label: string | null, value: string | null } | null> | null }; +export type GetGpsModelsQueryVariables = Exact<{ + gpsBrandId: Scalars['Uuid']; +}>; + + +export type GetGpsModelsQuery = { __typename?: 'Query', evo_gps_models: Array<{ __typename?: 'evo_gps_model', label: string | null, value: string | null } | null> | null }; + export type GetLeaseObjectTypesQueryVariables = Exact<{ [key: string]: never; }>; @@ -593,6 +600,7 @@ export const GetRegionsDocument = {"kind":"Document","definitions":[{"kind":"Ope export const GetRegionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetRegion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_region"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_regionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_oktmo"}},{"kind":"Field","name":{"kind":"Name","value":"accounts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accountid"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetTownsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetTowns"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_towns"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_regionid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"regionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_fias_id"}},{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_townid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_businessunit_evolution"}}]}}]}}]} as unknown as DocumentNode; export const GetGpsBrandsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGPSBrands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_gps_brands"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_gps_brandid"}}]}}]}}]} as unknown as DocumentNode; +export const GetGpsModelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetGPSModels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"gpsBrandId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_gps_models"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_gps_brandid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"gpsBrandId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_gps_modelid"}}]}}]}}]} as unknown as DocumentNode; export const GetLeaseObjectTypesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectTypes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_types"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_leasingobject_typeid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_typeid"}}]}}]}}]} as unknown as DocumentNode; export const GetLeaseObjectTypeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetLeaseObjectType"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Uuid"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_leasingobject_type"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"evo_leasingobject_typeid"},"value":{"kind":"Variable","name":{"kind":"Name","value":"leaseObjectTypeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}},{"kind":"Field","name":{"kind":"Name","value":"evo_id"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type_tax"}},{"kind":"Field","name":{"kind":"Name","value":"evo_category_tr"}}]}}]}}]} as unknown as DocumentNode; export const GetBrandsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetBrands"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"evo_brands"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statecode"},"value":{"kind":"IntValue","value":"0"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"label"},"name":{"kind":"Name","value":"evo_name"}},{"kind":"Field","alias":{"kind":"Name","value":"value"},"name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_brandid"}},{"kind":"Field","name":{"kind":"Name","value":"evo_vehicle_type"}}]}}]}}]} as unknown as DocumentNode; diff --git a/apps/web/process/insurance/index.ts b/apps/web/process/insurance/index.ts index f5291d5..e05ea2d 100644 --- a/apps/web/process/insurance/index.ts +++ b/apps/web/process/insurance/index.ts @@ -1 +1,2 @@ export * from './get-kp-data'; +export * as reactions from './reactions'; diff --git a/apps/web/process/insurance/reactions.ts b/apps/web/process/insurance/reactions.ts new file mode 100644 index 0000000..b19a284 --- /dev/null +++ b/apps/web/process/insurance/reactions.ts @@ -0,0 +1,112 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +import type { ProcessContext } from '../types'; +import { normalizeOptions } from '@/../../packages/tools'; +import { selectLeaseObjectUseFor } from '@/config/default-options'; +import * as CRMTypes from '@/graphql/crm.types'; +import { reaction } from 'mobx'; + +export function common({ store, apolloClient }: ProcessContext) { + const { $calculation } = store; + + reaction( + () => $calculation.element('selectGPSBrand').getValue(), + async (gpsBrandId) => { + if (!gpsBrandId) { + $calculation.element('selectGPSModel').resetValue(); + + return; + } + + const { + data: { evo_gps_models }, + } = await apolloClient.query({ + query: CRMTypes.GetGpsModelsDocument, + variables: { + gpsBrandId, + }, + }); + + if (evo_gps_models) { + $calculation.element('selectGPSModel').setOptions(normalizeOptions(evo_gps_models)); + } + } + ); + + reaction( + () => $calculation.element('selectLeaseObjectCategory').getValue(), + (leaseObjectCategory) => { + switch (leaseObjectCategory) { + case 100_000_000: { + $calculation + .element('selectLeaseObjectUseFor') + .setOptions( + selectLeaseObjectUseFor.filter((x) => [100_000_000, 100_000_002].includes(x.value)) + ); + break; + } + case 100_000_001: { + $calculation + .element('selectLeaseObjectUseFor') + .setOptions( + selectLeaseObjectUseFor.filter((x) => + [ + 100_000_000, 100_000_001, 100_000_002, 100_000_003, 100_000_004, 100_000_005, + 100_000_006, 100_000_007, 100_000_008, 100_000_009, 100_000_010, 100_000_011, + 100_000_012, 100_000_013, + ].includes(x.value) + ) + ); + break; + } + case 100_000_002: { + $calculation + .element('selectLeaseObjectUseFor') + .setOptions( + selectLeaseObjectUseFor.filter((x) => + [ + 100_000_002, 100_000_004, 100_000_005, 100_000_006, 100_000_009, 100_000_010, + ].includes(x.value) + ) + ); + break; + } + case 100_000_003: { + $calculation + .element('selectLeaseObjectUseFor') + .setOptions( + selectLeaseObjectUseFor.filter((x) => + [ + 100_000_002, 100_000_004, 100_000_006, 100_000_007, 100_000_008, 100_000_011, + 100_000_012, 100_000_013, + ].includes(x.value) + ) + ); + break; + } + case 100_000_004: { + $calculation + .element('selectLeaseObjectUseFor') + .setOptions( + selectLeaseObjectUseFor.filter((x) => [100_000_002, 100_000_009].includes(x.value)) + ); + break; + } + default: { + $calculation + .element('selectLeaseObjectUseFor') + .setOptions( + selectLeaseObjectUseFor.filter((x) => + [ + 100_000_014, 100_000_015, 100_000_016, 100_000_017, 100_000_018, 100_000_019, + ].includes(x.value) + ) + ); + break; + } + } + }, + { + fireImmediately: true, + } + ); +} diff --git a/apps/web/process/lead-opportunity/reactions/common.ts b/apps/web/process/lead-opportunity/reactions/common.ts index 5cff530..f249b1b 100644 --- a/apps/web/process/lead-opportunity/reactions/common.ts +++ b/apps/web/process/lead-opportunity/reactions/common.ts @@ -110,28 +110,4 @@ export default function reactions({ store, apolloClient }: ProcessContext) { } } ); - - reaction( - () => $calculation.element('selectLead').getValue(), - async (leadid) => { - if (!leadid) { - $calculation.element('tbxINNForCalc').resetValue(); - - return; - } - - const { - data: { lead }, - } = await apolloClient.query({ - query: CRMTypes.GetLeadDocument, - variables: { leadid }, - }); - - if (lead?.evo_inn) { - $calculation.element('tbxINNForCalc').setValue(Number.parseInt(lead?.evo_inn, 10)); - } else { - $calculation.element('tbxINNForCalc').resetValue(); - } - } - ); }