From 1827b9ba54e314e2c312714ea1bd020a3fce911c Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 27 Oct 2022 08:30:24 +0300 Subject: [PATCH] process/supplier-agent: move queries closer to create-reactions --- .../supplier-agent/lib/create-reactions.ts | 30 +++++++++++++++++-- process/supplier-agent/lib/query.ts | 25 +--------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/process/supplier-agent/lib/create-reactions.ts b/process/supplier-agent/lib/create-reactions.ts index 6a683a4..00ad732 100644 --- a/process/supplier-agent/lib/create-reactions.ts +++ b/process/supplier-agent/lib/create-reactions.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ import type { ApolloClient } from '@apollo/client'; +import { gql } from '@apollo/client'; import type * as Values from 'Components/Calculation/config/map/values'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; @@ -8,10 +9,25 @@ import { reaction } from 'mobx'; import type RootStore from 'stores/root'; import { normalizeOptions } from 'tools/entity'; import { makeDisposable } from 'tools/mobx'; -import * as query from './query'; dayjs.extend(utc); +const QUERY_GET_REWARD_CONDITIONS = gql` + query GetRewardConditions($agentid: Uuid!, $currentDate: DateTime) { + evo_reward_conditions( + evo_agent_accountid: $agentid + evo_datefrom_param: { lte: $currentDate } + evo_dateto_param: { gte: $currentDate } + statecode: 0 + evo_agency_agreementid_param: { has: true } + ) { + label: evo_name + value: evo_reward_conditionid + evo_reward_summ + } + } +`; + export function fillAgentRewardReaction( store: RootStore, apolloClient: ApolloClient, @@ -39,7 +55,7 @@ export function fillAgentRewardReaction( CRMTypes.GetRewardConditionsQuery, CRMTypes.GetRewardConditionsQueryVariables >({ - query: query.QUERY_GET_REWARD_CONDITIONS, + query: QUERY_GET_REWARD_CONDITIONS, variables: { agentid: agentId, currentDate: dayjs().toISOString(), @@ -57,6 +73,14 @@ export function fillAgentRewardReaction( ); } +const QUERY_GET_REWARD_SUMM = gql` + query GetRewardSumm($conditionId: Uuid!) { + evo_reward_condition(evo_reward_conditionid: $conditionId) { + evo_reward_summ + } + } +`; + export function fillAgentRewardSummReaction( store: RootStore, apolloClient: ApolloClient, @@ -85,7 +109,7 @@ export function fillAgentRewardSummReaction( CRMTypes.GetRewardSummQuery, CRMTypes.GetRewardSummQueryVariables >({ - query: query.QUERY_GET_REWARD_SUMM, + query: QUERY_GET_REWARD_SUMM, variables: { conditionId: rewardConditionId, }, diff --git a/process/supplier-agent/lib/query.ts b/process/supplier-agent/lib/query.ts index be9bcab..79482d8 100644 --- a/process/supplier-agent/lib/query.ts +++ b/process/supplier-agent/lib/query.ts @@ -1,3 +1,4 @@ +/* eslint-disable import/prefer-default-export */ import { gql } from '@apollo/client'; export const QUERY_GET_AGENT = gql` @@ -8,27 +9,3 @@ export const QUERY_GET_AGENT = gql` } } `; - -export const QUERY_GET_REWARD_CONDITIONS = gql` - query GetRewardConditions($agentid: Uuid!, $currentDate: DateTime) { - evo_reward_conditions( - evo_agent_accountid: $agentid - evo_datefrom_param: { lte: $currentDate } - evo_dateto_param: { gte: $currentDate } - statecode: 0 - evo_agency_agreementid_param: { has: true } - ) { - label: evo_name - value: evo_reward_conditionid - evo_reward_summ - } - } -`; - -export const QUERY_GET_REWARD_SUMM = gql` - query GetRewardSumm($conditionId: Uuid!) { - evo_reward_condition(evo_reward_conditionid: $conditionId) { - evo_reward_summ - } - } -`;