lead reaction(part)
This commit is contained in:
parent
9c0b1104f2
commit
d290a9c563
@ -2,6 +2,42 @@ import { IReactionEffect } from 'core/types/effect';
|
||||
import { Status } from 'core/types/statuses';
|
||||
|
||||
const reactionEffects: IReactionEffect[] = [
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { values } = calculationStore;
|
||||
return values.lead;
|
||||
},
|
||||
effect: leadId => {
|
||||
const lead = calculationStore.options.selectLead?.find(
|
||||
x => x.value === leadId,
|
||||
);
|
||||
|
||||
if (leadId && lead?.evo_opportunityid) {
|
||||
const opportunity = calculationStore.options.selectOpportunity?.find(
|
||||
o => o.value === lead?.evo_opportunityid,
|
||||
);
|
||||
if (opportunity) {
|
||||
calculationStore.setValue('opportunity', opportunity.value);
|
||||
} else {
|
||||
calculationStore.setValue('opportunity', null);
|
||||
}
|
||||
} else {
|
||||
calculationStore.setValue('opportunity', null);
|
||||
}
|
||||
|
||||
if (leadId && lead) {
|
||||
calculationStore.setFilter('selectQuote', quotes => {
|
||||
return quotes.filter(q => q.evo_leadid === leadId);
|
||||
});
|
||||
} else {
|
||||
calculationStore.setFilter('selectQuote', quotes => {
|
||||
return [];
|
||||
});
|
||||
calculationStore.setValue('quote', null);
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { channel } = calculationStore.values;
|
||||
@ -68,8 +104,8 @@ const reactionEffects: IReactionEffect[] = [
|
||||
calculationStore.setValue('broker', undefined);
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
export default reactionEffects;
|
||||
|
||||
@ -289,13 +289,15 @@ const calculationFakeData: TElements<TElementOption[]> = {
|
||||
},
|
||||
{
|
||||
name: '150_ООО "Некромант',
|
||||
id: 'nekrolead',
|
||||
value: 'nekrolead',
|
||||
id: 'nekroLead',
|
||||
value: 'nekroLead',
|
||||
evo_opportunityid: 'nekroOpportunity',
|
||||
},
|
||||
{
|
||||
name: '200_ООО "Кардинал',
|
||||
id: 'kardinalLead',
|
||||
value: 'kardinalLead',
|
||||
evo_opportunityid: 'kardinalOpportunity',
|
||||
},
|
||||
],
|
||||
selectOpportunity: [
|
||||
@ -326,11 +328,13 @@ const calculationFakeData: TElements<TElementOption[]> = {
|
||||
name: '6789_ООО "Некромант"',
|
||||
id: 'nekroQuote',
|
||||
value: 'nekroQuote',
|
||||
evo_leadid: 'nekroLead',
|
||||
},
|
||||
{
|
||||
name: '8765_ООО "Кардинал',
|
||||
id: 'kardinalQuote',
|
||||
value: 'kardinalQuote',
|
||||
evo_leadid: 'kardinalLead',
|
||||
},
|
||||
],
|
||||
selectBroker: [
|
||||
|
||||
Reference in New Issue
Block a user