From 267c669975e59bfba2600f6d56173000da66314e Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 7 Feb 2024 13:57:10 +0300 Subject: [PATCH] process/add-product: fixes --- apps/web/process/add-product/reactions.ts | 83 +++++++++++++---------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/apps/web/process/add-product/reactions.ts b/apps/web/process/add-product/reactions.ts index 7d26923..80003ad 100644 --- a/apps/web/process/add-product/reactions.ts +++ b/apps/web/process/add-product/reactions.ts @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/cognitive-complexity */ import { createValidationReaction } from '../tools'; import type { ProcessContext } from '../types'; import { createValidationSchema } from './validation'; @@ -227,30 +228,30 @@ export default function reactions({ store, apolloClient }: ProcessContext) { $calculation.element('selectRequirementTelematic').setValue(100_000_003).block(); } else { $calculation.element('selectRequirementTelematic').unblock(); - } - if (leaseObjectTypeId) { - const { - data: { evo_leasingobject_type }, - } = await apolloClient.query({ - query: CRMTypes.GetLeaseObjectTypeDocument, - variables: { leaseObjectTypeId }, - }); + if (leaseObjectTypeId) { + const { + data: { evo_leasingobject_type }, + } = await apolloClient.query({ + query: CRMTypes.GetLeaseObjectTypeDocument, + variables: { leaseObjectTypeId }, + }); - if (evo_leasingobject_type?.evo_id === '8') { - $calculation - .element('selectRequirementTelematic') - .setOptions( - selectRequirementTelematic.filter((x) => - [100_000_000, 100_000_001].includes(x.value) - ) - ); - } + if (evo_leasingobject_type?.evo_id === '8') { + $calculation + .element('selectRequirementTelematic') + .setOptions( + selectRequirementTelematic.filter((x) => + [100_000_000, 100_000_001].includes(x.value) + ) + ); + } - if (evo_leasingobject_type?.evo_id === '11') { - $calculation.element('selectRequirementTelematic').setValue(100_000_002).block(); - } else { - $calculation.element('selectRequirementTelematic').unblock(); + if (evo_leasingobject_type?.evo_id === '11') { + $calculation.element('selectRequirementTelematic').setValue(100_000_002).block(); + } else { + $calculation.element('selectRequirementTelematic').unblock(); + } } } } else { @@ -309,25 +310,33 @@ export default function reactions({ store, apolloClient }: ProcessContext) { if (engineType === 100_000_003) { filteredTelematicTypes = telematicTypes?.filter( (x) => - x?.evo_controls_program?.includes(100_000_003) && x.label?.toLowerCase().includes('аво') + x?.evo_controls_program?.includes(100_000_003) && + x.label?.toLowerCase().includes('аво') && + !x.label?.toLowerCase().includes('pro') ); - } - if (leaseObjectTypeId) { - const { - data: { evo_leasingobject_type }, - } = await apolloClient.query({ - query: CRMTypes.GetLeaseObjectTypeDocument, - variables: { leaseObjectTypeId }, - }); + $calculation.element('selectTracker').resetValue().block(); + $calculation.element('selectTelematic').block(); + } else { + $calculation.element('selectTracker').unblock(); + $calculation.element('selectTelematic').unblock(); - if (evo_leasingobject_type?.evo_id === '11') { - filteredTelematicTypes = telematicTypes?.filter( - (x) => - x?.evo_controls_program?.includes(100_000_002) && - x.label?.toLowerCase().includes('delta') && - !x.label?.toLowerCase().includes('pro') - ); + if (leaseObjectTypeId) { + const { + data: { evo_leasingobject_type }, + } = await apolloClient.query({ + query: CRMTypes.GetLeaseObjectTypeDocument, + variables: { leaseObjectTypeId }, + }); + + if (evo_leasingobject_type?.evo_id === '11') { + filteredTelematicTypes = telematicTypes?.filter( + (x) => + x?.evo_controls_program?.includes(100_000_002) && + x.label?.toLowerCase().includes('delta') && + !x.label?.toLowerCase().includes('pro') + ); + } } }