rewrite first effect

This commit is contained in:
Владислав Чикалкин 2020-09-23 19:12:16 +03:00
parent bfe3f635d8
commit a9cef098a3
2 changed files with 17 additions and 33 deletions

View File

@ -13,19 +13,14 @@ const reactionEffects: IReactionEffect[] = [
x => x.value === leadId,
);
if (lead)
if (lead) {
CalculationService.getEntityOptions({
entityName: 'opportunity',
fields: undefined,
where: { opportunityid: lead.evo_opportunityid || null },
})
.then(opportunities => {
console.log(
'opportunities',
lead?.evo_opportunityid || '',
opportunities,
);
if (opportunities) {
console.log('opportunities', opportunities);
calculationStore.setOptions('selectOpportunity', opportunities);
calculationStore.setValue(
'opportunity',
@ -37,29 +32,20 @@ const reactionEffects: IReactionEffect[] = [
throw err;
});
// 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);
// }
CalculationService.getEntityOptions({
entityName: 'quote',
where: {
evo_leadid: leadId,
},
})
.then(quotes => {
console.log('quotes', quotes);
calculationStore.setOptions('selectQuote', quotes);
})
.catch(err => {
throw err;
});
}
},
}),

View File

@ -1,8 +1,6 @@
import { TElementFilter } from 'core/types/Calculation/filters';
import { TElements } from 'core/types/elements';
const initialFilters: TElements<TElementFilter> = {
selectQuote: options => [],
};
const initialFilters: TElements<TElementFilter> = {};
export default initialFilters;