From 5b82522f13450908b43391e05bbc010a28c118c7 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: Thu, 24 Sep 2020 16:49:28 +0300 Subject: [PATCH] effect for indAgent=>reward condition --- .../CalculationStore/Effects/reaction.ts | 88 +++++++++++++++++++ src/core/fakeData/entityFakes.ts | 19 ++++ src/core/types/Entities/index.ts | 1 + 3 files changed, 108 insertions(+) diff --git a/src/client/stores/CalculationStore/Effects/reaction.ts b/src/client/stores/CalculationStore/Effects/reaction.ts index a1bbbd7..9ef587e 100644 --- a/src/client/stores/CalculationStore/Effects/reaction.ts +++ b/src/client/stores/CalculationStore/Effects/reaction.ts @@ -200,6 +200,94 @@ const reactionEffects: IReactionEffect[] = [ }, }), + calculationStore => ({ + expression: () => { + const { agent } = calculationStore.values; + return agent; + }, + effect: agentid => { + if (!agentid) { + calculationStore.setStatus('selectDoubleAgent', Status.Disabled); + } else { + calculationStore.setStatus('selectDoubleAgent', Status.Default); + } + }, + }), + + calculationStore => ({ + expression: () => { + const { newClient } = calculationStore.values; + return newClient; + }, + effect: newClient => { + if (newClient && newClient.length > 0) { + calculationStore.setValue('account', null); + calculationStore.setValue('contactClient', null); + calculationStore.setStatus('selectAccount', Status.Disabled); + calculationStore.setStatus('selectContactClient', Status.Disabled); + } else { + calculationStore.setStatus('selectAccount', Status.Default); + calculationStore.setStatus('selectContactClient', Status.Default); + } + }, + }), + + calculationStore => ({ + expression: () => { + const { account } = calculationStore.values; + return account; + }, + effect: account => { + if (account && account.length > 0) { + calculationStore.setStatus('tbxNewClient', Status.Disabled); + calculationStore.setValue('newClient', null); + } else { + calculationStore.setStatus('tbxNewClient', Status.Default); + } + }, + }), + + calculationStore => ({ + expression: () => { + const { indAgent } = calculationStore.values; + return indAgent; + }, + effect: indAgentId => { + if (!indAgentId) { + calculationStore.setValue('indAgentRewardCondition', null); + calculationStore.setStatus( + 'selectIndAgentRewardCondition', + Status.Disabled, + ); + } else { + calculationStore.setValue('indAgentRewardCondition', null); + calculationStore.setStatus( + 'selectIndAgentRewardCondition', + Status.Default, + ); + CalculationService.getEntityOptions({ + entityName: 'evo_reward_condition', + where: { + statecode: 0, + // TODO < > текущей даты + // evo_datefrom: new Date(), + // evo_dateto: new Date(), + evo_agent_accountid: indAgentId, + }, + }) + .then(reward_conditions => { + calculationStore.setOptions( + 'selectIndAgentRewardCondition', + reward_conditions, + ); + }) + .catch(err => { + throw err; + }); + } + }, + }), + calculationStore => ({ expression: () => { const { channel } = calculationStore.values; diff --git a/src/core/fakeData/entityFakes.ts b/src/core/fakeData/entityFakes.ts index 9e78878..f05a41c 100644 --- a/src/core/fakeData/entityFakes.ts +++ b/src/core/fakeData/entityFakes.ts @@ -58,6 +58,9 @@ const TOWN_2_ID = faker.random.uuid(); const TOWN_3_ID = faker.random.uuid(); const TOWN_4_ID = faker.random.uuid(); +const REWARD_CONDITION_1_ID = faker.random.uuid(); +const REWARD_CONDITION_2_ID = faker.random.uuid(); + /** * Fake Consts */ @@ -329,6 +332,22 @@ const entityFakeData: { statecode: 0, }, ], + evo_reward_condition: [ + { + statecode: 0, + evo_agent_accountid: ACCOUNT_6_ID, + evo_reward_conditionid: REWARD_CONDITION_1_ID, + evo_name: 'Не более 1.5%', + evo_reward_summ: 1.5, + }, + { + statecode: 0, + evo_agent_accountid: ACCOUNT_6_ID, + evo_reward_conditionid: REWARD_CONDITION_2_ID, + evo_name: 'Не более 2%', + evo_reward_summ: 2, + }, + ], }; export default entityFakeData; diff --git a/src/core/types/Entities/index.ts b/src/core/types/Entities/index.ts index b2c854b..8d26628 100644 --- a/src/core/types/Entities/index.ts +++ b/src/core/types/Entities/index.ts @@ -89,6 +89,7 @@ export interface IEvoRewardCondition extends IBaseOption { evo_dateto?: Date; evo_agent_accountid?: string; evo_double_agent_accountid?: string; + evo_reward_summ?: number; statecode?: number; }