add filter to selectBrand
This commit is contained in:
parent
6b52faa502
commit
da6ba87416
@ -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,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user