graphql: migrate to @graphql-codegen/cli
This commit is contained in:
parent
122dd3d6e8
commit
f9df16bd2f
@ -6,5 +6,4 @@ package-lock.json
|
||||
**/*.test.js
|
||||
coverage
|
||||
mocks
|
||||
graphql
|
||||
**/__generated__
|
||||
graphql
|
||||
@ -1,2 +1,12 @@
|
||||
overwrite: true
|
||||
schema: './graphql/crm.schema.graphql'
|
||||
documents: '**/*.{graphql,js,ts,jsx,tsx}'
|
||||
generates:
|
||||
./graphql/crm.types.ts:
|
||||
plugins:
|
||||
- typescript
|
||||
- typescript-operations
|
||||
config:
|
||||
onlyOperationTypes: true
|
||||
useTypeImports: true
|
||||
# exclude: './graphql/crm.schema.graphql'
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
.next
|
||||
public
|
||||
graphql
|
||||
**/__generated__
|
||||
graphql
|
||||
@ -1,21 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetCurrencySymbol
|
||||
// ====================================================
|
||||
|
||||
export interface GetCurrencySymbol_transactioncurrency {
|
||||
__typename: "transactioncurrency";
|
||||
currencysymbol: string | null;
|
||||
}
|
||||
|
||||
export interface GetCurrencySymbol {
|
||||
transactioncurrency: GetCurrencySymbol_transactioncurrency | null;
|
||||
}
|
||||
|
||||
export interface GetCurrencySymbolVariables {
|
||||
currencyid: any;
|
||||
}
|
||||
@ -1,9 +1,8 @@
|
||||
import { gql, useApolloClient } from '@apollo/client';
|
||||
import type * as CRMTypes from 'graphql/crm.types';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { useState } from 'react';
|
||||
import { useStore } from 'stores/hooks';
|
||||
// prettier-ignore
|
||||
import type { GetCurrencySymbol, GetCurrencySymbolVariables } from './__generated__/GetCurrencySymbol';
|
||||
|
||||
const QUERY_GET_CURRENCY_SYMBOL = gql`
|
||||
query GetCurrencySymbol($currencyid: Uuid!) {
|
||||
@ -24,7 +23,7 @@ const CurrencyAddon = observer(() => {
|
||||
|
||||
if (!currencyid) return null;
|
||||
|
||||
query<GetCurrencySymbol, GetCurrencySymbolVariables>({
|
||||
query<CRMTypes.GetCurrencySymbolQuery, CRMTypes.GetCurrencySymbolQueryVariables>({
|
||||
query: QUERY_GET_CURRENCY_SYMBOL,
|
||||
variables: {
|
||||
currencyid,
|
||||
|
||||
@ -3,7 +3,7 @@ module.exports = {
|
||||
client: {
|
||||
service: {
|
||||
name: 'crmgraphql',
|
||||
// url: process.env.NEXT_PUBLIC_URL_CRM_GRAPHQL_DIRECT,
|
||||
url: process.env.NEXT_PUBLIC_URL_CRM_GRAPHQL_DIRECT,
|
||||
localSchemaFile: './graphql/crm.schema.graphql',
|
||||
},
|
||||
excludes: ['graphql/**/*'],
|
||||
|
||||
249
graphql/crm.types.ts
Normal file
249
graphql/crm.types.ts
Normal file
@ -0,0 +1,249 @@
|
||||
export type Maybe<T> = T | null;
|
||||
export type InputMaybe<T> = Maybe<T>;
|
||||
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
||||
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
|
||||
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
|
||||
/** All built-in and custom scalars, mapped to their actual values */
|
||||
export type Scalars = {
|
||||
ID: string;
|
||||
String: string;
|
||||
Boolean: boolean;
|
||||
Int: number;
|
||||
Float: number;
|
||||
/** The `DateTime` scalar represents an ISO-8601 compliant date time type. */
|
||||
DateTime: any;
|
||||
/** The built-in `Decimal` scalar type. */
|
||||
Decimal: any;
|
||||
/** The multiplier path scalar represents a valid GraphQL multiplier path string. */
|
||||
MultiplierPath: any;
|
||||
Uuid: any;
|
||||
};
|
||||
|
||||
export type ConditionInput = {
|
||||
conditions?: InputMaybe<Array<InputMaybe<ConditionInput>>>;
|
||||
filters?: InputMaybe<Array<InputMaybe<FilterInput>>>;
|
||||
logicoperation: LogicOperation;
|
||||
};
|
||||
|
||||
export type DateParamInput = {
|
||||
eq?: InputMaybe<Scalars['DateTime']>;
|
||||
gt?: InputMaybe<Scalars['DateTime']>;
|
||||
gte?: InputMaybe<Scalars['DateTime']>;
|
||||
lt?: InputMaybe<Scalars['DateTime']>;
|
||||
lte?: InputMaybe<Scalars['DateTime']>;
|
||||
};
|
||||
|
||||
export type DecimalParamInput = {
|
||||
eq?: InputMaybe<Scalars['Decimal']>;
|
||||
gt?: InputMaybe<Scalars['Decimal']>;
|
||||
gte?: InputMaybe<Scalars['Decimal']>;
|
||||
lt?: InputMaybe<Scalars['Decimal']>;
|
||||
lte?: InputMaybe<Scalars['Decimal']>;
|
||||
};
|
||||
|
||||
export type EntityDataInput = {
|
||||
fields?: InputMaybe<Array<InputMaybe<EntityFieldInput>>>;
|
||||
id?: InputMaybe<Scalars['Uuid']>;
|
||||
logicalName?: InputMaybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type EntityFieldInput = {
|
||||
activitypartiesvalue?: InputMaybe<Array<InputMaybe<ActivitypartyInput>>>;
|
||||
boolvalue?: InputMaybe<Scalars['Boolean']>;
|
||||
datetimevalue?: InputMaybe<Scalars['DateTime']>;
|
||||
decimalvalue?: InputMaybe<Scalars['Decimal']>;
|
||||
guidvalue?: InputMaybe<Scalars['Uuid']>;
|
||||
intarrayvalue?: InputMaybe<Array<Scalars['Int']>>;
|
||||
intvalue?: InputMaybe<Scalars['Int']>;
|
||||
key?: InputMaybe<Scalars['String']>;
|
||||
stringvalue?: InputMaybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type FilterInput = {
|
||||
fieldname?: InputMaybe<Scalars['String']>;
|
||||
guidvalues?: InputMaybe<Array<InputMaybe<Scalars['Uuid']>>>;
|
||||
intvalues?: InputMaybe<Array<Scalars['Int']>>;
|
||||
operation: FilterOperation;
|
||||
stringvalues?: InputMaybe<Array<InputMaybe<Scalars['String']>>>;
|
||||
};
|
||||
|
||||
export enum FilterOperation {
|
||||
Contains = 'CONTAINS',
|
||||
Equal = 'EQUAL',
|
||||
Isnull = 'ISNULL',
|
||||
Lessorequalthen = 'LESSOREQUALTHEN',
|
||||
Lessthen = 'LESSTHEN',
|
||||
Moreorequalthen = 'MOREOREQUALTHEN',
|
||||
Morethen = 'MORETHEN',
|
||||
Notcontains = 'NOTCONTAINS'
|
||||
}
|
||||
|
||||
export type GuidParamInput = {
|
||||
eq?: InputMaybe<Scalars['Uuid']>;
|
||||
has?: InputMaybe<Scalars['Boolean']>;
|
||||
in?: InputMaybe<Array<Scalars['Uuid']>>;
|
||||
};
|
||||
|
||||
export enum LogicOperation {
|
||||
And = 'AND',
|
||||
Or = 'OR'
|
||||
}
|
||||
|
||||
export type OrderByInput = {
|
||||
fieldName?: InputMaybe<Scalars['String']>;
|
||||
sortingType: SortingType;
|
||||
};
|
||||
|
||||
export enum SortingType {
|
||||
Asc = 'ASC',
|
||||
Desc = 'DESC'
|
||||
}
|
||||
|
||||
export type StringParamInput = {
|
||||
eq?: InputMaybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type ActivitypartyInput = {
|
||||
addressused?: InputMaybe<Scalars['String']>;
|
||||
createdon?: InputMaybe<Scalars['DateTime']>;
|
||||
modifiedon?: InputMaybe<Scalars['DateTime']>;
|
||||
participationtypemask?: InputMaybe<Scalars['Int']>;
|
||||
partyid_account?: InputMaybe<Scalars['Uuid']>;
|
||||
partyid_contact?: InputMaybe<Scalars['Uuid']>;
|
||||
partyid_evo_contract?: InputMaybe<Scalars['Uuid']>;
|
||||
partyid_queue?: InputMaybe<Scalars['Uuid']>;
|
||||
partyid_systemuser?: InputMaybe<Scalars['Uuid']>;
|
||||
};
|
||||
|
||||
export type GetCurrencySymbolQueryVariables = Exact<{
|
||||
currencyid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetCurrencySymbolQuery = { __typename?: 'Query', transactioncurrency?: { __typename?: 'transactioncurrency', currencysymbol?: string | null } | null };
|
||||
|
||||
export type GetDealerPersonQueryVariables = Exact<{
|
||||
dealerId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetDealerPersonQuery = { __typename?: 'Query', salon_providers?: Array<{ __typename?: 'account', label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetBrokerAccountIdFromDealerQueryVariables = Exact<{
|
||||
dealerId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetBrokerAccountIdFromDealerQuery = { __typename?: 'Query', dealer?: { __typename?: 'account', evo_broker_accountid?: any | null } | null };
|
||||
|
||||
export type GetAgentQueryVariables = Exact<{
|
||||
agentid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetAgentQuery = { __typename?: 'Query', agent?: { __typename?: 'account', label?: string | null, value?: any | null } | null };
|
||||
|
||||
export type GetRewardConditionsQueryVariables = Exact<{
|
||||
agentid: Scalars['Uuid'];
|
||||
currentDate?: InputMaybe<Scalars['DateTime']>;
|
||||
}>;
|
||||
|
||||
|
||||
export type GetRewardConditionsQuery = { __typename?: 'Query', evo_reward_conditions?: Array<{ __typename?: 'evo_reward_condition', evo_reward_summ?: any | null, label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetRewardSummQueryVariables = Exact<{
|
||||
conditionId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetRewardSummQuery = { __typename?: 'Query', evo_reward_condition?: { __typename?: 'evo_reward_condition', evo_reward_summ?: any | null } | null };
|
||||
|
||||
export type GetAddproductTypesQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type GetAddproductTypesQuery = { __typename?: 'Query', evo_addproduct_types?: Array<{ __typename?: 'evo_addproduct_type', evo_graph_price?: any | null, evo_product_type?: number | null, label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetBrandsQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type GetBrandsQuery = { __typename?: 'Query', selectBrand?: Array<{ __typename?: 'evo_brand', label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetDealersQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type GetDealersQuery = { __typename?: 'Query', selectDealer?: Array<{ __typename?: 'account', label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetInsuranceDataQueryVariables = Exact<{
|
||||
evo_account_type?: InputMaybe<Array<Scalars['Int']> | Scalars['Int']>;
|
||||
}>;
|
||||
|
||||
|
||||
export type GetInsuranceDataQuery = { __typename?: 'Query', osago?: Array<{ __typename?: 'account', value?: any | null, label?: string | null } | null> | null, kasko?: Array<{ __typename?: 'account', value?: any | null, label?: string | null } | null> | null, fingap?: Array<{ __typename?: 'account', value?: any | null, label?: string | null } | null> | null };
|
||||
|
||||
export type GetMainOptionsQueryVariables = Exact<{
|
||||
currentDate?: InputMaybe<Scalars['DateTime']>;
|
||||
}>;
|
||||
|
||||
|
||||
export type GetMainOptionsQuery = { __typename?: 'Query', selectSupplierCurrency?: Array<{ __typename?: 'transactioncurrency', currencysymbol?: string | null, label?: string | null, value?: any | null } | null> | null, selectProduct?: Array<{ __typename?: 'evo_baseproduct', label?: string | null, value?: any | null } | null> | null, selectLeaseObjectType?: Array<{ __typename?: 'evo_leasingobject_type', label?: string | null, value?: any | null } | null> | null, selectGPSBrand?: Array<{ __typename?: 'evo_gps_brand', label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetSubsidiesQueryVariables = Exact<{
|
||||
currentDate?: InputMaybe<Scalars['DateTime']>;
|
||||
}>;
|
||||
|
||||
|
||||
export type GetSubsidiesQuery = { __typename?: 'Query', evo_subsidies?: Array<{ __typename?: 'evo_subsidy', evo_subsidy_type?: number | null, label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetRegionsQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type GetRegionsQuery = { __typename?: 'Query', evo_regions?: Array<{ __typename?: 'evo_region', label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetOwnerDataQueryVariables = Exact<{
|
||||
domainname?: InputMaybe<Scalars['String']>;
|
||||
}>;
|
||||
|
||||
|
||||
export type GetOwnerDataQuery = { __typename?: 'Query', selectLead?: Array<{ __typename?: 'lead', label?: string | null, value?: any | null } | null> | null, selectOpportunity?: Array<{ __typename?: 'opportunity', label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetOpportunityByLeadQueryVariables = Exact<{
|
||||
leadid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetOpportunityByLeadQuery = { __typename?: 'Query', lead?: { __typename?: 'lead', evo_opportunityidData?: { __typename?: 'opportunity', label?: string | null, value?: any | null } | null } | null };
|
||||
|
||||
export type GetLeadidByOpportunityQueryVariables = Exact<{
|
||||
opportunityid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetLeadidByOpportunityQuery = { __typename?: 'Query', opportunity?: { __typename?: 'opportunity', evo_leadid?: any | null } | null };
|
||||
|
||||
export type GetQuotesByLeadQueryVariables = Exact<{
|
||||
leadid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetQuotesByLeadQuery = { __typename?: 'Query', quotes?: Array<{ __typename?: 'quote', label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetLeadUrlQueryVariables = Exact<{
|
||||
id: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetLeadUrlQuery = { __typename?: 'Query', entity?: { __typename?: 'lead', link?: string | null } | null };
|
||||
|
||||
export type GetOpportunityUrlQueryVariables = Exact<{
|
||||
id: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetOpportunityUrlQuery = { __typename?: 'Query', entity?: { __typename?: 'opportunity', link?: string | null } | null };
|
||||
|
||||
export type GetQuoteUrlQueryVariables = Exact<{
|
||||
id: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetQuoteUrlQuery = { __typename?: 'Query', entity?: { __typename?: 'quote', link?: string | null } | null };
|
||||
@ -10,7 +10,7 @@
|
||||
"lint:fix": "next lint -- --fix",
|
||||
"prettier": "prettier --write .",
|
||||
"precommit": "yarn prettier && yarn lint:fix",
|
||||
"graphql:codegen": "apollo client:codegen --target typescript --globalTypesFile types/graphql.ts",
|
||||
"graphql:codegen": "graphql-codegen --config .graphqlrc.yml",
|
||||
"graphql:schema": "dotenv -e .env.local apollo client:download-schema graphql/crm.schema.graphql",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
@ -22,7 +22,7 @@
|
||||
"antd": "^4.21.3",
|
||||
"axios": "^0.27.2",
|
||||
"dayjs": "^1.11.2",
|
||||
"graphql": "14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0",
|
||||
"graphql": "^16.6.0",
|
||||
"less": "^4.1.2",
|
||||
"less-loader": "^10.2.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
@ -41,6 +41,9 @@
|
||||
"use-debounce": "^8.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@graphql-codegen/cli": "2.12.0",
|
||||
"@graphql-codegen/typescript": "2.7.3",
|
||||
"@graphql-codegen/typescript-operations": "2.5.3",
|
||||
"@types/lodash-es": "^4.17.6",
|
||||
"@types/node": "18.7.18",
|
||||
"@types/react": "18.0.20",
|
||||
@ -49,7 +52,7 @@
|
||||
"@types/styled-components": "^5.1.25",
|
||||
"@typescript-eslint/eslint-plugin": "^5.37.0",
|
||||
"@typescript-eslint/parser": "^5.37.0",
|
||||
"apollo": "^2.33.10",
|
||||
"apollo": "^2.34.0",
|
||||
"dotenv-cli": "^6.0.0",
|
||||
"eslint": "8.23.1",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
|
||||
@ -2,18 +2,16 @@
|
||||
import type { ApolloClient, DocumentNode } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
import type { Elements } from 'Components/Calculation/config/map/values';
|
||||
import type { GetAgentQuery, GetAgentQueryVariables } from 'graphql/crm.types';
|
||||
import type RootStore from 'stores/root';
|
||||
import { normalizeOptions } from 'tools/entity';
|
||||
import QUERY_GET_AGENT from './query/get-agent';
|
||||
import QUERY_GET_BROKER_ACCOUNTID from './query/get-broker-accountid';
|
||||
import type { GetAgent } from './query/__generated__/GetAgent';
|
||||
|
||||
function makeFillAgent(
|
||||
function makeFillAgentFromLead(
|
||||
elementName: Elements,
|
||||
queryGetAgentId: DocumentNode,
|
||||
queryGetAgent: DocumentNode
|
||||
) {
|
||||
return async function fillAgent(
|
||||
return async function fillAgentFromLead(
|
||||
{ $calculation }: RootStore,
|
||||
apolloClient: ApolloClient<object>,
|
||||
leadid: string | null
|
||||
@ -36,7 +34,7 @@ function makeFillAgent(
|
||||
if (lead?.agentid) {
|
||||
const {
|
||||
data: { agent },
|
||||
} = await apolloClient.query<GetAgent>({
|
||||
} = await apolloClient.query<GetAgentQuery, GetAgentQueryVariables>({
|
||||
query: queryGetAgent,
|
||||
variables: {
|
||||
agentid: lead.agentid,
|
||||
@ -53,23 +51,32 @@ function makeFillAgent(
|
||||
};
|
||||
}
|
||||
|
||||
const QUERY_GET_AGENT = gql`
|
||||
query GetAgent($agentid: Uuid!) {
|
||||
agent: account(accountid: $agentid) {
|
||||
label: name
|
||||
value: accountid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* Если lead содержит данные,
|
||||
* то indAgent заполняется ссылкой на карточку Контрагент (account),
|
||||
* записанную в поле Интереса "Агент" (lead.evo_agent_accountid → account),
|
||||
* иначе очищать поле калькулятора indAgent
|
||||
*/
|
||||
const QUERY_GET_AGENT_ACCOUNTID = gql`
|
||||
query GetAgentAccountId($leadid: Uuid!) {
|
||||
const QUERY_GET_AGENT_ACCOUNTID_FROM_LEAD = gql`
|
||||
query GetAgentAccountIdFromLead($leadid: Uuid!) {
|
||||
lead(leadid: $leadid) {
|
||||
agentid: evo_agent_accountid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const fillIndAgent = makeFillAgent(
|
||||
export const fillIndAgent = makeFillAgentFromLead(
|
||||
'selectIndAgent',
|
||||
QUERY_GET_AGENT_ACCOUNTID,
|
||||
QUERY_GET_AGENT_ACCOUNTID_FROM_LEAD,
|
||||
QUERY_GET_AGENT
|
||||
);
|
||||
|
||||
@ -88,7 +95,7 @@ const QUERY_GET_DOUBLE_AGENT_ACCOUNTID = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const fillCalcDoubleAgent = makeFillAgent(
|
||||
export const fillCalcDoubleAgent = makeFillAgentFromLead(
|
||||
'selectCalcDoubleAgent',
|
||||
QUERY_GET_DOUBLE_AGENT_ACCOUNTID,
|
||||
QUERY_GET_AGENT
|
||||
@ -100,9 +107,17 @@ export const fillCalcDoubleAgent = makeFillAgent(
|
||||
* иначе очищать поле калькулятора calcBroker
|
||||
*/
|
||||
|
||||
export const fillCalcBroker = makeFillAgent(
|
||||
const QUERY_GET_BROKER_ACCOUNTID_FROM_LEAD = gql`
|
||||
query GetBrokerAccountId($leadid: Uuid!) {
|
||||
lead(leadid: $leadid) {
|
||||
agentid: evo_broker_accountid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const fillCalcBroker = makeFillAgentFromLead(
|
||||
'selectCalcBroker',
|
||||
QUERY_GET_BROKER_ACCOUNTID,
|
||||
QUERY_GET_BROKER_ACCOUNTID_FROM_LEAD,
|
||||
QUERY_GET_AGENT
|
||||
);
|
||||
|
||||
@ -121,7 +136,7 @@ const QUERY_GET_FIN_DEPARTMENT_ACCOUNTID = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const fillFinDepartment = makeFillAgent(
|
||||
export const fillFinDepartment = makeFillAgentFromLead(
|
||||
'selectCalcFinDepartment',
|
||||
QUERY_GET_FIN_DEPARTMENT_ACCOUNTID,
|
||||
QUERY_GET_AGENT
|
||||
@ -1,21 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetBrokerAccountIdFromDealer
|
||||
// ====================================================
|
||||
|
||||
export interface GetBrokerAccountIdFromDealer_dealer {
|
||||
__typename: "account";
|
||||
evo_broker_accountid: any | null;
|
||||
}
|
||||
|
||||
export interface GetBrokerAccountIdFromDealer {
|
||||
dealer: GetBrokerAccountIdFromDealer_dealer | null;
|
||||
}
|
||||
|
||||
export interface GetBrokerAccountIdFromDealerVariables {
|
||||
dealerId: any;
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetDealerPerson
|
||||
// ====================================================
|
||||
|
||||
export interface GetDealerPerson_salon_providers {
|
||||
__typename: "account";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetDealerPerson {
|
||||
/**
|
||||
* Поставщики ЮЛ салона. statecode по умолчанию 0
|
||||
*/
|
||||
salon_providers: (GetDealerPerson_salon_providers | null)[] | null;
|
||||
}
|
||||
|
||||
export interface GetDealerPersonVariables {
|
||||
dealerId: any;
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetRewardConditions
|
||||
// ====================================================
|
||||
|
||||
export interface GetRewardConditions_evo_reward_conditions {
|
||||
__typename: "evo_reward_condition";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
evo_reward_summ: any | null;
|
||||
}
|
||||
|
||||
export interface GetRewardConditions {
|
||||
evo_reward_conditions: (GetRewardConditions_evo_reward_conditions | null)[] | null;
|
||||
}
|
||||
|
||||
export interface GetRewardConditionsVariables {
|
||||
agentid: any;
|
||||
currentDate?: any | null;
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetRewardSumm
|
||||
// ====================================================
|
||||
|
||||
export interface GetRewardSumm_evo_reward_condition {
|
||||
__typename: "evo_reward_condition";
|
||||
evo_reward_summ: any | null;
|
||||
}
|
||||
|
||||
export interface GetRewardSumm {
|
||||
evo_reward_condition: GetRewardSumm_evo_reward_condition | null;
|
||||
}
|
||||
|
||||
export interface GetRewardSummVariables {
|
||||
conditionId: any;
|
||||
}
|
||||
@ -3,16 +3,11 @@ import type { ApolloClient } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import type * as CRMTypes from 'graphql/crm.types';
|
||||
import { reaction } from 'mobx';
|
||||
import type RootStore from 'stores/root';
|
||||
import { normalizeOptions } from 'tools/entity';
|
||||
import * as fillAgentsFromLead from './lib/fill-agents-from-lead';
|
||||
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 { GetRewardConditions } from './__generated__/GetRewardConditions';
|
||||
import type { GetRewardSumm } from './__generated__/GetRewardSumm';
|
||||
import * as fillAgentsFromLead from '../lib/fill-agents-from-lead';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
@ -60,7 +55,10 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
|
||||
const {
|
||||
data: { salon_providers },
|
||||
} = await apolloClient.query<GetDealerPerson>({
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetDealerPersonQuery,
|
||||
CRMTypes.GetDealerPersonQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_DEALER_PERSON,
|
||||
variables: {
|
||||
dealerId,
|
||||
@ -78,7 +76,7 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
* Заполняем selectDealerBroker
|
||||
*/
|
||||
|
||||
const QUERY_GET_BROKER_ACCOUNTID = gql`
|
||||
const QUERY_GET_BROKER_ACCOUNTID_FROM_DEALER = gql`
|
||||
query GetBrokerAccountIdFromDealer($dealerId: Uuid!) {
|
||||
dealer: account(accountid: $dealerId) {
|
||||
evo_broker_accountid
|
||||
@ -86,6 +84,15 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
}
|
||||
`;
|
||||
|
||||
const QUERY_GET_AGENT = gql`
|
||||
query GetAgent($agentid: Uuid!) {
|
||||
agent: account(accountid: $agentid) {
|
||||
label: name
|
||||
value: accountid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
reaction(
|
||||
() => $calculation.getElementValue('selectDealerPerson'),
|
||||
async (dealerPersonId) => {
|
||||
@ -93,17 +100,22 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
return;
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
const { data: { dealer } } = await apolloClient.query<GetBrokerAccountIdFromDealer>({
|
||||
query: QUERY_GET_BROKER_ACCOUNTID,
|
||||
const {
|
||||
data: { dealer },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetBrokerAccountIdFromDealerQuery,
|
||||
CRMTypes.GetBrokerAccountIdFromDealerQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_BROKER_ACCOUNTID_FROM_DEALER,
|
||||
variables: {
|
||||
dealerId: dealerPersonId,
|
||||
},
|
||||
});
|
||||
|
||||
if (dealer?.evo_broker_accountid) {
|
||||
// prettier-ignore
|
||||
const { data: { agent: dealerBroker } } = await apolloClient.query<GetAgent>({
|
||||
const {
|
||||
data: { agent: dealerBroker },
|
||||
} = await apolloClient.query<CRMTypes.GetAgentQuery, CRMTypes.GetAgentQueryVariables>({
|
||||
query: QUERY_GET_AGENT,
|
||||
variables: {
|
||||
agentid: dealer?.evo_broker_accountid,
|
||||
@ -150,7 +162,10 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
}
|
||||
const {
|
||||
data: { evo_reward_conditions },
|
||||
} = await apolloClient.query<GetRewardConditions>({
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetRewardConditionsQuery,
|
||||
CRMTypes.GetRewardConditionsQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_REWARD_CONDITIONS,
|
||||
variables: {
|
||||
agentid: dealerPersonId,
|
||||
@ -186,7 +201,10 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
|
||||
const {
|
||||
data: { evo_reward_condition },
|
||||
} = await apolloClient.query<GetRewardSumm>({
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetRewardSummQuery,
|
||||
CRMTypes.GetRewardSummQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_REWARD_SUMM,
|
||||
variables: {
|
||||
conditionId: rewardConditionId,
|
||||
@ -212,7 +230,10 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
}
|
||||
const {
|
||||
data: { evo_reward_conditions },
|
||||
} = await apolloClient.query<GetRewardConditions>({
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetRewardConditionsQuery,
|
||||
CRMTypes.GetRewardConditionsQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_REWARD_CONDITIONS,
|
||||
variables: {
|
||||
agentid: dealerBrokerId,
|
||||
@ -240,7 +261,10 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
|
||||
const {
|
||||
data: { evo_reward_condition },
|
||||
} = await apolloClient.query<GetRewardSumm>({
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetRewardSummQuery,
|
||||
CRMTypes.GetRewardSummQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_REWARD_SUMM,
|
||||
variables: {
|
||||
conditionId: rewardConditionId,
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetAgentAccountId
|
||||
// ====================================================
|
||||
|
||||
export interface GetAgentAccountId_lead {
|
||||
__typename: "lead";
|
||||
agentid: any | null;
|
||||
}
|
||||
|
||||
export interface GetAgentAccountId {
|
||||
/**
|
||||
* Лизинговые сделки. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName
|
||||
*/
|
||||
lead: GetAgentAccountId_lead | null;
|
||||
}
|
||||
|
||||
export interface GetAgentAccountIdVariables {
|
||||
leadid: any;
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetDoubleAgentAccountId
|
||||
// ====================================================
|
||||
|
||||
export interface GetDoubleAgentAccountId_lead {
|
||||
__typename: "lead";
|
||||
agentid: any | null;
|
||||
}
|
||||
|
||||
export interface GetDoubleAgentAccountId {
|
||||
/**
|
||||
* Лизинговые сделки. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName
|
||||
*/
|
||||
lead: GetDoubleAgentAccountId_lead | null;
|
||||
}
|
||||
|
||||
export interface GetDoubleAgentAccountIdVariables {
|
||||
leadid: any;
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetFinDepartmentAccountId
|
||||
// ====================================================
|
||||
|
||||
export interface GetFinDepartmentAccountId_lead {
|
||||
__typename: "lead";
|
||||
agentid: any | null;
|
||||
}
|
||||
|
||||
export interface GetFinDepartmentAccountId {
|
||||
/**
|
||||
* Лизинговые сделки. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName
|
||||
*/
|
||||
lead: GetFinDepartmentAccountId_lead | null;
|
||||
}
|
||||
|
||||
export interface GetFinDepartmentAccountIdVariables {
|
||||
leadid: any;
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetAgent
|
||||
// ====================================================
|
||||
|
||||
export interface GetAgent_agent {
|
||||
__typename: "account";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetAgent {
|
||||
agent: GetAgent_agent | null;
|
||||
}
|
||||
|
||||
export interface GetAgentVariables {
|
||||
agentid: any;
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetBrokerAccountId
|
||||
// ====================================================
|
||||
|
||||
export interface GetBrokerAccountId_lead {
|
||||
__typename: "lead";
|
||||
agentid: any | null;
|
||||
}
|
||||
|
||||
export interface GetBrokerAccountId {
|
||||
/**
|
||||
* Лизинговые сделки. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName
|
||||
*/
|
||||
lead: GetBrokerAccountId_lead | null;
|
||||
}
|
||||
|
||||
export interface GetBrokerAccountIdVariables {
|
||||
leadid: any;
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
const QUERY_GET_AGENT = gql`
|
||||
query GetAgent($agentid: Uuid!) {
|
||||
agent: account(accountid: $agentid) {
|
||||
label: name
|
||||
value: accountid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default QUERY_GET_AGENT;
|
||||
@ -1,11 +0,0 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
const QUERY_GET_BROKER_ACCOUNTID = gql`
|
||||
query GetBrokerAccountId($leadid: Uuid!) {
|
||||
lead(leadid: $leadid) {
|
||||
agentid: evo_broker_accountid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default QUERY_GET_BROKER_ACCOUNTID;
|
||||
@ -1,20 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetAddproductTypes
|
||||
// ====================================================
|
||||
|
||||
export interface GetAddproductTypes_evo_addproduct_types {
|
||||
__typename: "evo_addproduct_type";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
evo_graph_price: any | null;
|
||||
evo_product_type: number | null;
|
||||
}
|
||||
|
||||
export interface GetAddproductTypes {
|
||||
evo_addproduct_types: (GetAddproductTypes_evo_addproduct_types | null)[] | null;
|
||||
}
|
||||
18
process/init/get-data/__generated__/GetBrands.ts
generated
18
process/init/get-data/__generated__/GetBrands.ts
generated
@ -1,18 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetBrands
|
||||
// ====================================================
|
||||
|
||||
export interface GetBrands_selectBrand {
|
||||
__typename: "evo_brand";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetBrands {
|
||||
selectBrand: (GetBrands_selectBrand | null)[] | null;
|
||||
}
|
||||
21
process/init/get-data/__generated__/GetDealers.ts
generated
21
process/init/get-data/__generated__/GetDealers.ts
generated
@ -1,21 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetDealers
|
||||
// ====================================================
|
||||
|
||||
export interface GetDealers_selectDealer {
|
||||
__typename: "account";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetDealers {
|
||||
/**
|
||||
* Контрагенты. statecode по умолчанию 0
|
||||
*/
|
||||
selectDealer: (GetDealers_selectDealer | null)[] | null;
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetInsuranceData
|
||||
// ====================================================
|
||||
|
||||
export interface GetInsuranceData_osago {
|
||||
__typename: "account";
|
||||
value: any | null;
|
||||
label: string | null;
|
||||
}
|
||||
|
||||
export interface GetInsuranceData_kasko {
|
||||
__typename: "account";
|
||||
value: any | null;
|
||||
label: string | null;
|
||||
}
|
||||
|
||||
export interface GetInsuranceData_fingap {
|
||||
__typename: "account";
|
||||
value: any | null;
|
||||
label: string | null;
|
||||
}
|
||||
|
||||
export interface GetInsuranceData {
|
||||
/**
|
||||
* Контрагенты. statecode по умолчанию 0
|
||||
*/
|
||||
osago: (GetInsuranceData_osago | null)[] | null;
|
||||
/**
|
||||
* Контрагенты. statecode по умолчанию 0
|
||||
*/
|
||||
kasko: (GetInsuranceData_kasko | null)[] | null;
|
||||
/**
|
||||
* Контрагенты. statecode по умолчанию 0
|
||||
*/
|
||||
fingap: (GetInsuranceData_fingap | null)[] | null;
|
||||
}
|
||||
|
||||
export interface GetInsuranceDataVariables {
|
||||
evo_account_type?: number[] | null;
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetMainOptions
|
||||
// ====================================================
|
||||
|
||||
export interface GetMainOptions_selectSupplierCurrency {
|
||||
__typename: "transactioncurrency";
|
||||
label: string | null;
|
||||
currencysymbol: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetMainOptions_selectProduct {
|
||||
__typename: "evo_baseproduct";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetMainOptions_selectLeaseObjectType {
|
||||
__typename: "evo_leasingobject_type";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetMainOptions_selectGPSBrand {
|
||||
__typename: "evo_gps_brand";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetMainOptions {
|
||||
/**
|
||||
* Валюта. statecode по умолчанию 0
|
||||
*/
|
||||
selectSupplierCurrency: (GetMainOptions_selectSupplierCurrency | null)[] | null;
|
||||
selectProduct: (GetMainOptions_selectProduct | null)[] | null;
|
||||
selectLeaseObjectType: (GetMainOptions_selectLeaseObjectType | null)[] | null;
|
||||
selectGPSBrand: (GetMainOptions_selectGPSBrand | null)[] | null;
|
||||
}
|
||||
|
||||
export interface GetMainOptionsVariables {
|
||||
currentDate?: any | null;
|
||||
}
|
||||
32
process/init/get-data/__generated__/GetOwnerData.ts
generated
32
process/init/get-data/__generated__/GetOwnerData.ts
generated
@ -1,32 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetOwnerData
|
||||
// ====================================================
|
||||
|
||||
export interface GetOwnerData_selectLead {
|
||||
__typename: "lead";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetOwnerData_selectOpportunity {
|
||||
__typename: "opportunity";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetOwnerData {
|
||||
/**
|
||||
* Интересы. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName
|
||||
*/
|
||||
selectLead: (GetOwnerData_selectLead | null)[] | null;
|
||||
selectOpportunity: (GetOwnerData_selectOpportunity | null)[] | null;
|
||||
}
|
||||
|
||||
export interface GetOwnerDataVariables {
|
||||
domainname?: string | null;
|
||||
}
|
||||
21
process/init/get-data/__generated__/GetRegions.ts
generated
21
process/init/get-data/__generated__/GetRegions.ts
generated
@ -1,21 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetRegions
|
||||
// ====================================================
|
||||
|
||||
export interface GetRegions_evo_regions {
|
||||
__typename: "evo_region";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetRegions {
|
||||
/**
|
||||
* Регион. statecode по умолчанию 0
|
||||
*/
|
||||
evo_regions: (GetRegions_evo_regions | null)[] | null;
|
||||
}
|
||||
23
process/init/get-data/__generated__/GetSubsidies.ts
generated
23
process/init/get-data/__generated__/GetSubsidies.ts
generated
@ -1,23 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetSubsidies
|
||||
// ====================================================
|
||||
|
||||
export interface GetSubsidies_evo_subsidies {
|
||||
__typename: "evo_subsidy";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
evo_subsidy_type: number | null;
|
||||
}
|
||||
|
||||
export interface GetSubsidies {
|
||||
evo_subsidies: (GetSubsidies_evo_subsidies | null)[] | null;
|
||||
}
|
||||
|
||||
export interface GetSubsidiesVariables {
|
||||
currentDate?: any | null;
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
import type { ApolloClient } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
import type { GetAddproductTypes } from './__generated__/GetAddproductTypes';
|
||||
import type { GetAddproductTypesQuery } from 'graphql/crm.types';
|
||||
|
||||
const QUERY_GET_ADDPRODUCT_TYPES = gql`
|
||||
query GetAddproductTypes {
|
||||
@ -14,7 +14,7 @@ const QUERY_GET_ADDPRODUCT_TYPES = gql`
|
||||
`;
|
||||
|
||||
export default async function getAddProductTypes(apolloClient: ApolloClient<object>) {
|
||||
const { data: addproductTypes } = await apolloClient.query<GetAddproductTypes>({
|
||||
const { data: addproductTypes } = await apolloClient.query<GetAddproductTypesQuery>({
|
||||
query: QUERY_GET_ADDPRODUCT_TYPES,
|
||||
});
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import type { ApolloClient } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
import type { GetBrands } from './__generated__/GetBrands';
|
||||
import type { GetBrandsQuery } from 'graphql/crm.types';
|
||||
|
||||
const QUERY_GET_BRANDS = gql`
|
||||
query GetBrands {
|
||||
@ -14,7 +14,7 @@ const QUERY_GET_BRANDS = gql`
|
||||
export default async function getBrands(apolloClient: ApolloClient<object>) {
|
||||
const {
|
||||
data: { selectBrand },
|
||||
} = await apolloClient.query<GetBrands>({
|
||||
} = await apolloClient.query<GetBrandsQuery>({
|
||||
query: QUERY_GET_BRANDS,
|
||||
});
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import type { ApolloClient } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
import type { GetDealers } from './__generated__/GetDealers';
|
||||
import type { GetDealersQuery } from 'graphql/crm.types';
|
||||
|
||||
const QUERY_GET_DEALERS = gql`
|
||||
query GetDealers {
|
||||
@ -14,7 +14,7 @@ const QUERY_GET_DEALERS = gql`
|
||||
export default async function getDealers(apolloClient: ApolloClient<object>) {
|
||||
const {
|
||||
data: { selectDealer },
|
||||
} = await apolloClient.query<GetDealers>({
|
||||
} = await apolloClient.query<GetDealersQuery>({
|
||||
query: QUERY_GET_DEALERS,
|
||||
});
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import type { ApolloClient } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
import type { GetInsuranceData } from './__generated__/GetInsuranceData';
|
||||
import type { GetInsuranceDataQuery } from 'graphql/crm.types';
|
||||
|
||||
const QUERY_GET_INSURANCE_DATA = gql`
|
||||
query GetInsuranceData($evo_account_type: [Int!]) {
|
||||
@ -34,7 +34,7 @@ const QUERY_GET_INSURANCE_DATA = gql`
|
||||
`;
|
||||
|
||||
export default async function getInsuranceData(apolloClient: ApolloClient<object>) {
|
||||
const { data: insuranceData } = await apolloClient.query<GetInsuranceData>({
|
||||
const { data: insuranceData } = await apolloClient.query<GetInsuranceDataQuery>({
|
||||
query: QUERY_GET_INSURANCE_DATA,
|
||||
});
|
||||
|
||||
|
||||
@ -3,9 +3,7 @@ import type { ApolloClient } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import type { GetMainOptions } from './__generated__/GetMainOptions';
|
||||
import type { GetRegions } from './__generated__/GetRegions';
|
||||
import type { GetSubsidies } from './__generated__/GetSubsidies';
|
||||
import type * as CRMTypes from 'graphql/crm.types';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
@ -63,15 +61,20 @@ const QUERY_GET_REGIONS = gql`
|
||||
`;
|
||||
|
||||
export default async function getMainData(apolloClient: ApolloClient<object>) {
|
||||
// prettier-ignore
|
||||
const { data: mainOptions } = await apolloClient.query<GetMainOptions>({
|
||||
query: QUERY_GET_MAIN_OPTIONS,
|
||||
variables: {
|
||||
currentDate: dayjs().utc().toISOString()
|
||||
}
|
||||
});
|
||||
const { data: mainOptions } = await apolloClient.query<
|
||||
CRMTypes.GetMainOptionsQuery,
|
||||
CRMTypes.GetMainOptionsQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_MAIN_OPTIONS,
|
||||
variables: {
|
||||
currentDate: dayjs().utc().toISOString(),
|
||||
},
|
||||
});
|
||||
|
||||
const { data: subsidies } = await apolloClient.query<GetSubsidies>({
|
||||
const { data: subsidies } = await apolloClient.query<
|
||||
CRMTypes.GetSubsidiesQuery,
|
||||
CRMTypes.GetSubsidiesQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_SUBSIDIES,
|
||||
variables: {
|
||||
currentDate: dayjs().utc().toISOString(),
|
||||
@ -85,7 +88,10 @@ export default async function getMainData(apolloClient: ApolloClient<object>) {
|
||||
(x) => x?.evo_subsidy_type && [100_000_002].includes(x?.evo_subsidy_type)
|
||||
);
|
||||
|
||||
const { data: regions } = await apolloClient.query<GetRegions>({
|
||||
const { data: regions } = await apolloClient.query<
|
||||
CRMTypes.GetRegionsQuery,
|
||||
CRMTypes.GetRegionsQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_REGIONS,
|
||||
});
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import type { ApolloClient, NormalizedCache } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
import type { User } from 'api/user/types';
|
||||
import type { GetOwnerData, GetOwnerDataVariables } from './__generated__/GetOwnerData';
|
||||
import type { GetOwnerDataQuery, GetOwnerDataQueryVariables } from 'graphql/crm.types';
|
||||
|
||||
const QUERY_GET_OWNER_DATA = gql`
|
||||
query GetOwnerData($domainname: String) {
|
||||
@ -20,7 +20,10 @@ export default async function getOwnerData(
|
||||
apolloClient: ApolloClient<NormalizedCache>,
|
||||
user: User
|
||||
) {
|
||||
const { data: ownerData } = await apolloClient.query<GetOwnerData, GetOwnerDataVariables>({
|
||||
const { data: ownerData } = await apolloClient.query<
|
||||
GetOwnerDataQuery,
|
||||
GetOwnerDataQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_OWNER_DATA,
|
||||
variables: {
|
||||
domainname: user.domainName,
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetLeadUrl
|
||||
// ====================================================
|
||||
|
||||
export interface GetLeadUrl_entity {
|
||||
__typename: "lead";
|
||||
link: string | null;
|
||||
}
|
||||
|
||||
export interface GetLeadUrl {
|
||||
/**
|
||||
* Лизинговые сделки. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName
|
||||
*/
|
||||
entity: GetLeadUrl_entity | null;
|
||||
}
|
||||
|
||||
export interface GetLeadUrlVariables {
|
||||
id: any;
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetLeadidByOpportunity
|
||||
// ====================================================
|
||||
|
||||
export interface GetLeadidByOpportunity_opportunity {
|
||||
__typename: "opportunity";
|
||||
evo_leadid: any | null;
|
||||
}
|
||||
|
||||
export interface GetLeadidByOpportunity {
|
||||
opportunity: GetLeadidByOpportunity_opportunity | null;
|
||||
}
|
||||
|
||||
export interface GetLeadidByOpportunityVariables {
|
||||
opportunityid: any;
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetOpportunityByLead
|
||||
// ====================================================
|
||||
|
||||
export interface GetOpportunityByLead_lead_evo_opportunityidData {
|
||||
__typename: "opportunity";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetOpportunityByLead_lead {
|
||||
__typename: "lead";
|
||||
evo_opportunityidData: GetOpportunityByLead_lead_evo_opportunityidData | null;
|
||||
}
|
||||
|
||||
export interface GetOpportunityByLead {
|
||||
/**
|
||||
* Лизинговые сделки. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName
|
||||
*/
|
||||
lead: GetOpportunityByLead_lead | null;
|
||||
}
|
||||
|
||||
export interface GetOpportunityByLeadVariables {
|
||||
leadid: any;
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetOpportunityUrl
|
||||
// ====================================================
|
||||
|
||||
export interface GetOpportunityUrl_entity {
|
||||
__typename: "opportunity";
|
||||
link: string | null;
|
||||
}
|
||||
|
||||
export interface GetOpportunityUrl {
|
||||
entity: GetOpportunityUrl_entity | null;
|
||||
}
|
||||
|
||||
export interface GetOpportunityUrlVariables {
|
||||
id: any;
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetQuoteUrl
|
||||
// ====================================================
|
||||
|
||||
export interface GetQuoteUrl_entity {
|
||||
__typename: "quote";
|
||||
link: string | null;
|
||||
}
|
||||
|
||||
export interface GetQuoteUrl {
|
||||
entity: GetQuoteUrl_entity | null;
|
||||
}
|
||||
|
||||
export interface GetQuoteUrlVariables {
|
||||
id: any;
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetQuotesByLead
|
||||
// ====================================================
|
||||
|
||||
export interface GetQuotesByLead_quotes {
|
||||
__typename: "quote";
|
||||
label: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetQuotesByLead {
|
||||
/**
|
||||
* Предложения. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName
|
||||
*/
|
||||
quotes: (GetQuotesByLead_quotes | null)[] | null;
|
||||
}
|
||||
|
||||
export interface GetQuotesByLeadVariables {
|
||||
leadid: any;
|
||||
}
|
||||
@ -1,11 +1,9 @@
|
||||
import type { ApolloClient } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
import type * as CRMTypes from 'graphql/crm.types';
|
||||
import { reaction } from 'mobx';
|
||||
import type RootStore from 'stores/root';
|
||||
import { normalizeOptions } from 'tools/entity';
|
||||
import type { GetLeadidByOpportunity } from './__generated__/GetLeadidByOpportunity';
|
||||
import type { GetOpportunityByLead } from './__generated__/GetOpportunityByLead';
|
||||
import type { GetQuotesByLead } from './__generated__/GetQuotesByLead';
|
||||
|
||||
export default function commonReactions(store: RootStore, apolloClient: ApolloClient<object>) {
|
||||
const { $calculation } = store;
|
||||
@ -39,7 +37,10 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
|
||||
const {
|
||||
data: { lead },
|
||||
} = await apolloClient.query<GetOpportunityByLead>({
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetOpportunityByLeadQuery,
|
||||
CRMTypes.GetOpportunityByLeadQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_OPPORTUNITY_BY_LEAD,
|
||||
variables: {
|
||||
leadid,
|
||||
@ -76,7 +77,10 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
if (leadid) {
|
||||
const {
|
||||
data: { lead },
|
||||
} = await apolloClient.query<GetOpportunityByLead>({
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetOpportunityByLeadQuery,
|
||||
CRMTypes.GetOpportunityByLeadQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_OPPORTUNITY_BY_LEAD,
|
||||
variables: {
|
||||
leadid,
|
||||
@ -89,7 +93,10 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
}
|
||||
|
||||
if (opportunityid) {
|
||||
const { data } = await apolloClient.query<GetLeadidByOpportunity>({
|
||||
const { data } = await apolloClient.query<
|
||||
CRMTypes.GetLeadidByOpportunityQuery,
|
||||
CRMTypes.GetLeadidByOpportunityQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_LEADID_BY_OPPORTUNITY,
|
||||
variables: {
|
||||
opportunityid,
|
||||
@ -123,7 +130,10 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl
|
||||
if (leadid) {
|
||||
const {
|
||||
data: { quotes },
|
||||
} = await apolloClient.query<GetQuotesByLead>({
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetQuotesByLeadQuery,
|
||||
CRMTypes.GetQuotesByLeadQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_QUOTES_BY_LEAD,
|
||||
variables: {
|
||||
leadid,
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import type { BaseOption } from 'Elements/types';
|
||||
|
||||
export function normalizeOptions(options: any[] | null) {
|
||||
if (options === null) return [];
|
||||
export function normalizeOptions(options: any[] | null | undefined) {
|
||||
if (options === null || options === undefined) return [];
|
||||
|
||||
return options as BaseOption[];
|
||||
}
|
||||
|
||||
@ -19,5 +19,5 @@
|
||||
},
|
||||
"files": ["types/graphql.d.ts"],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
|
||||
"exclude": ["node_modules", "**/__generated__", "./types/graphql.ts"]
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
3
types/graphql.d.ts
vendored
3
types/graphql.d.ts
vendored
@ -1,5 +1,6 @@
|
||||
declare module '*.graphql' {
|
||||
import { DocumentNode } from 'graphql';
|
||||
import type { DocumentNode } from 'graphql';
|
||||
|
||||
const Schema: DocumentNode;
|
||||
|
||||
export = Schema;
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
//==============================================================
|
||||
// START Enums and Input Objects
|
||||
//==============================================================
|
||||
|
||||
//==============================================================
|
||||
// END Enums and Input Objects
|
||||
//==============================================================
|
||||
Loading…
x
Reference in New Issue
Block a user