add filter to selectBrand

This commit is contained in:
vchikalkin 2021-06-03 13:49:10 +03:00
parent 6b52faa502
commit da6ba87416

View File

@ -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,
),
),
);
},