diff --git a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts index 48cf0b2..2148a5f 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts @@ -1,4 +1,5 @@ import { openNotification } from 'client/Elements/Notification'; +import { compose } from 'core/tools/func'; import { IReactionEffect } from 'core/types/Calculation/Store/effect'; import { Process } from 'core/types/Calculation/Store/process'; import { ElementStatus } from 'core/types/statuses'; @@ -1674,9 +1675,12 @@ const reactionEffects: IReactionEffect[] = [ calculationStore => ({ expression: () => { - return calculationStore.getOption('selectLeaseObjectType'); + return { + leaseObjectType: calculationStore.getOption('selectLeaseObjectType'), + product: calculationStore.getOption('selectProduct'), + }; }, - effect: leaseObjectType => { + effect: ({ leaseObjectType, product }) => { calculationStore.setStatus( 'selectBrand', leaseObjectType ? ElementStatus.Default : ElementStatus.Disabled, @@ -1685,12 +1689,29 @@ const reactionEffects: IReactionEffect[] = [ if (calculationStore.getOptions('selectBrand')) calculationStore.setFilter('selectBrand', options => options.filter( - option => - option.evo_vehicle_type && - intersection( - option.evo_vehicle_type?.filter(x => x > 0), - leaseObjectType.evo_vehicle_type, - ).length > 0, + compose( + option => { + if ( + product && + product.evo_brands && + product.evo_brands.length > 0 + ) { + return ( + product.evo_brands + .map(x => x.evo_brandid) + .includes(option.evo_brandid) && option + ); + } + return option; + }, + + option => + option.evo_vehicle_type && + intersection( + option.evo_vehicle_type?.filter(x => x > 0), + leaseObjectType.evo_vehicle_type, + ).length > 0, + ), ), ); },