process/agents: fill selectDealerRewardCondition
This commit is contained in:
parent
0f23662df0
commit
7fdd21af22
24
process/agents/reactions/__generated__/GetDealerRewardCondition.ts
generated
Normal file
24
process/agents/reactions/__generated__/GetDealerRewardCondition.ts
generated
Normal file
@ -0,0 +1,24 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetDealerRewardCondition
|
||||
// ====================================================
|
||||
|
||||
export interface GetDealerRewardCondition_evo_reward_conditions {
|
||||
__typename: "evo_reward_condition";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
evo_reward_summ: any | null;
|
||||
}
|
||||
|
||||
export interface GetDealerRewardCondition {
|
||||
evo_reward_conditions: (GetDealerRewardCondition_evo_reward_conditions | null)[] | null;
|
||||
}
|
||||
|
||||
export interface GetDealerRewardConditionVariables {
|
||||
agentid: any;
|
||||
currentDate?: any | null;
|
||||
}
|
||||
21
process/agents/reactions/__generated__/GetDealerRewardSumm.ts
generated
Normal file
21
process/agents/reactions/__generated__/GetDealerRewardSumm.ts
generated
Normal file
@ -0,0 +1,21 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetDealerRewardSumm
|
||||
// ====================================================
|
||||
|
||||
export interface GetDealerRewardSumm_evo_reward_condition {
|
||||
__typename: "evo_reward_condition";
|
||||
evo_reward_summ: any | null;
|
||||
}
|
||||
|
||||
export interface GetDealerRewardSumm {
|
||||
evo_reward_condition: GetDealerRewardSumm_evo_reward_condition | null;
|
||||
}
|
||||
|
||||
export interface GetDealerRewardSummVariables {
|
||||
conditionId: any;
|
||||
}
|
||||
@ -1,5 +1,8 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import type { ApolloClient } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
import type RootStore from 'stores/root';
|
||||
import { normalizeOptions } from 'tools/entity';
|
||||
@ -8,6 +11,10 @@ import QUERY_GET_AGENT from '../lib/query/get-agent';
|
||||
import type { GetAgent } from '../lib/query/__generated__/GetAgent';
|
||||
import type { GetBrokerAccountIdFromDealer } from './__generated__/GetBrokerAccountIdFromDealer';
|
||||
import type { GetDealerPerson } from './__generated__/GetDealerPerson';
|
||||
import type { GetDealerRewardCondition } from './__generated__/GetDealerRewardCondition';
|
||||
import type { GetDealerRewardSumm } from './__generated__/GetDealerRewardSumm';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export default function commonReactions(store: RootStore, apolloClient: ApolloClient<object>) {
|
||||
const { $calculation } = store;
|
||||
@ -51,7 +58,6 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
}
|
||||
|
||||
const {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
data: { salon_providers },
|
||||
} = await apolloClient.query<GetDealerPerson>({
|
||||
query: QUERY_GET_DEALER_PERSON,
|
||||
@ -117,6 +123,79 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
* Заполняем selectDealerRewardCondition
|
||||
*/
|
||||
|
||||
const QUERY_GET_DEALER_REWARD_CONDITIONS = gql`
|
||||
query GetDealerRewardCondition($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
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
reaction(
|
||||
() => $calculation.getElementValue('selectDealerPerson'),
|
||||
async (dealerPersonId) => {
|
||||
if (!dealerPersonId) {
|
||||
$calculation.resetElement('selectDealerRewardCondition');
|
||||
|
||||
return;
|
||||
}
|
||||
const {
|
||||
data: { evo_reward_conditions },
|
||||
} = await apolloClient.query<GetDealerRewardCondition>({
|
||||
query: QUERY_GET_DEALER_REWARD_CONDITIONS,
|
||||
variables: {
|
||||
agentid: dealerPersonId,
|
||||
currentDate: dayjs().toISOString(),
|
||||
},
|
||||
});
|
||||
|
||||
if (evo_reward_conditions?.length) {
|
||||
$calculation.setElementOptions(
|
||||
'selectDealerRewardCondition',
|
||||
normalizeOptions(evo_reward_conditions)
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const QUERY_GET_DEALER_REWARD_SUMM = gql`
|
||||
query GetDealerRewardSumm($conditionId: Uuid!) {
|
||||
evo_reward_condition(evo_reward_conditionid: $conditionId) {
|
||||
evo_reward_summ
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
reaction(
|
||||
() => $calculation.getElementValue('selectDealerRewardCondition'),
|
||||
async (dealerRewardConditionId) => {
|
||||
if (!dealerRewardConditionId) {
|
||||
$calculation.resetElement('tbxDealerRewardSumm');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_reward_condition },
|
||||
} = await apolloClient.query<GetDealerRewardSumm>({
|
||||
query: QUERY_GET_DEALER_REWARD_SUMM,
|
||||
variables: {
|
||||
conditionId: dealerRewardConditionId,
|
||||
},
|
||||
});
|
||||
|
||||
$calculation.setElementValue('tbxDealerRewardSumm', evo_reward_condition?.evo_reward_summ);
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Заполняем selectDealerBrokerRewardCondition
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user