From a9cef098a33d2cff987d1453ebc95c167b8c366e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=A7=D0=B8=D0=BA=D0=B0=D0=BB=D0=BA=D0=B8=D0=BD?= Date: Wed, 23 Sep 2020 19:12:16 +0300 Subject: [PATCH] rewrite first effect --- .../CalculationStore/Effects/reaction.ts | 46 +++++++------------ src/core/config/initialFilters.ts | 4 +- 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/src/client/stores/CalculationStore/Effects/reaction.ts b/src/client/stores/CalculationStore/Effects/reaction.ts index c929dbb..39bcec2 100644 --- a/src/client/stores/CalculationStore/Effects/reaction.ts +++ b/src/client/stores/CalculationStore/Effects/reaction.ts @@ -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; + }); + } }, }), diff --git a/src/core/config/initialFilters.ts b/src/core/config/initialFilters.ts index 33def52..7f28b80 100644 --- a/src/core/config/initialFilters.ts +++ b/src/core/config/initialFilters.ts @@ -1,8 +1,6 @@ import { TElementFilter } from 'core/types/Calculation/filters'; import { TElements } from 'core/types/elements'; -const initialFilters: TElements = { - selectQuote: options => [], -}; +const initialFilters: TElements = {}; export default initialFilters;