process/supplier-agent: move queries closer to create-reactions

This commit is contained in:
Chika 2022-10-27 08:30:24 +03:00
parent 2ecd64b2fb
commit 1827b9ba54
2 changed files with 28 additions and 27 deletions

View File

@ -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<object>,
@ -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<object>,
@ -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,
},

View File

@ -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
}
}
`;