process/agents: extract GetAgent graphql query
This commit is contained in:
parent
3e38446eee
commit
74b125c959
22
process/agents/lib/__generated__/GetBroker.ts
generated
22
process/agents/lib/__generated__/GetBroker.ts
generated
@ -1,22 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetBroker
|
||||
// ====================================================
|
||||
|
||||
export interface GetBroker_agent {
|
||||
__typename: "account";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetBroker {
|
||||
agent: GetBroker_agent | null;
|
||||
}
|
||||
|
||||
export interface GetBrokerVariables {
|
||||
agentid: any;
|
||||
}
|
||||
22
process/agents/lib/__generated__/GetDoubleAgent.ts
generated
22
process/agents/lib/__generated__/GetDoubleAgent.ts
generated
@ -1,22 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetDoubleAgent
|
||||
// ====================================================
|
||||
|
||||
export interface GetDoubleAgent_agent {
|
||||
__typename: "account";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetDoubleAgent {
|
||||
agent: GetDoubleAgent_agent | null;
|
||||
}
|
||||
|
||||
export interface GetDoubleAgentVariables {
|
||||
agentid: any;
|
||||
}
|
||||
22
process/agents/lib/__generated__/GetFinDepartment.ts
generated
22
process/agents/lib/__generated__/GetFinDepartment.ts
generated
@ -1,22 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetFinDepartment
|
||||
// ====================================================
|
||||
|
||||
export interface GetFinDepartment_agent {
|
||||
__typename: "account";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetFinDepartment {
|
||||
agent: GetFinDepartment_agent | null;
|
||||
}
|
||||
|
||||
export interface GetFinDepartmentVariables {
|
||||
agentid: any;
|
||||
}
|
||||
@ -4,13 +4,15 @@ import { gql } from '@apollo/client';
|
||||
import type { Elements } from 'Components/Calculation/config/map/values';
|
||||
import type RootStore from 'stores/root';
|
||||
import { normalizeOptions } from 'tools/entity';
|
||||
import QueryGetAgent from './query/GetAgent.graphql';
|
||||
import type { GetAgent } from './query/__generated__/GetAgent';
|
||||
|
||||
function fillAgent(
|
||||
function makeFillAgent(
|
||||
elementName: Elements,
|
||||
queryGetAgentId: DocumentNode,
|
||||
queryGetAgent: DocumentNode
|
||||
) {
|
||||
return async function (
|
||||
return async function fillAgent(
|
||||
{ $calculation }: RootStore,
|
||||
apolloClient: ApolloClient<object>,
|
||||
leadid: string | null
|
||||
@ -33,7 +35,7 @@ function fillAgent(
|
||||
if (lead?.agentid) {
|
||||
const {
|
||||
data: { agent },
|
||||
} = await apolloClient.query({
|
||||
} = await apolloClient.query<GetAgent>({
|
||||
query: queryGetAgent,
|
||||
variables: {
|
||||
agentid: lead.agentid,
|
||||
@ -64,16 +66,11 @@ const QUERY_GET_AGENT_ACCOUNTID = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
const QUERY_GET_AGENT = gql`
|
||||
query GetAgent($agentid: Uuid!) {
|
||||
agent: account(accountid: $agentid) {
|
||||
label: name
|
||||
value: accountid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const fillIndAgent = fillAgent('selectIndAgent', QUERY_GET_AGENT_ACCOUNTID, QUERY_GET_AGENT);
|
||||
export const fillIndAgent = makeFillAgent(
|
||||
'selectIndAgent',
|
||||
QUERY_GET_AGENT_ACCOUNTID,
|
||||
QueryGetAgent
|
||||
);
|
||||
|
||||
/**
|
||||
* Если lead содержит данные,
|
||||
@ -90,19 +87,10 @@ const QUERY_GET_DOUBLE_AGENT_ACCOUNTID = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
const QUERY_GET_DOUBLE_AGENT = gql`
|
||||
query GetDoubleAgent($agentid: Uuid!) {
|
||||
agent: account(accountid: $agentid) {
|
||||
label: name
|
||||
value: accountid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const fillCalcDoubleAgent = fillAgent(
|
||||
export const fillCalcDoubleAgent = makeFillAgent(
|
||||
'selectCalcDoubleAgent',
|
||||
QUERY_GET_DOUBLE_AGENT_ACCOUNTID,
|
||||
QUERY_GET_DOUBLE_AGENT
|
||||
QueryGetAgent
|
||||
);
|
||||
|
||||
/**
|
||||
@ -119,19 +107,10 @@ const QUERY_GET_BROKER_ACCOUNTID = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
const QUERY_GET_BROKER = gql`
|
||||
query GetBroker($agentid: Uuid!) {
|
||||
agent: account(accountid: $agentid) {
|
||||
label: name
|
||||
value: accountid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const fillCalcBroker = fillAgent(
|
||||
export const fillCalcBroker = makeFillAgent(
|
||||
'selectCalcBroker',
|
||||
QUERY_GET_BROKER_ACCOUNTID,
|
||||
QUERY_GET_BROKER
|
||||
QueryGetAgent
|
||||
);
|
||||
|
||||
/**
|
||||
@ -149,17 +128,8 @@ const QUERY_GET_FIN_DEPARTMENT_ACCOUNTID = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
const QUERY_GET_FIN_DEPARTMENT = gql`
|
||||
query GetFinDepartment($agentid: Uuid!) {
|
||||
agent: account(accountid: $agentid) {
|
||||
label: name
|
||||
value: accountid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const fillFinDepartment = fillAgent(
|
||||
export const fillFinDepartment = makeFillAgent(
|
||||
'selectCalcFinDepartment',
|
||||
QUERY_GET_FIN_DEPARTMENT_ACCOUNTID,
|
||||
QUERY_GET_FIN_DEPARTMENT
|
||||
QueryGetAgent
|
||||
);
|
||||
|
||||
6
process/agents/lib/query/GetAgent.graphql
Normal file
6
process/agents/lib/query/GetAgent.graphql
Normal file
@ -0,0 +1,6 @@
|
||||
query GetAgent($agentid: Uuid!) {
|
||||
agent: account(accountid: $agentid) {
|
||||
label: name
|
||||
value: accountid
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user