remove unnecessary union
This commit is contained in:
parent
9f697ea161
commit
26130621f2
@ -10,11 +10,7 @@ import {
|
||||
import { IGetEntitiesResponse } from 'core/types/Calculation/Responses';
|
||||
import { IBaseOption } from 'core/types/Calculation/Store/options';
|
||||
import { TCRMEntity } from 'core/types/Entities/crmEntities';
|
||||
import {
|
||||
CRMEntityAliases,
|
||||
TEntities,
|
||||
CRMEntityNames,
|
||||
} from 'core/types/Entities/crmEntityNames';
|
||||
import { TEntities, CRMEntityNames } from 'core/types/Entities/crmEntityNames';
|
||||
import { isPlural, singular } from 'pluralize';
|
||||
|
||||
const client = new ApolloClient({
|
||||
@ -64,6 +60,7 @@ class CalculationService {
|
||||
resEntities[targetName];
|
||||
|
||||
if (toOptions)
|
||||
//@ts-ignore
|
||||
if (toOptions.includes(targetName)) {
|
||||
if (Array.isArray(targetEnt)) {
|
||||
let optionatedEntities: (TCRMEntity & IBaseOption)[] = [];
|
||||
@ -79,7 +76,6 @@ class CalculationService {
|
||||
//@ts-ignore
|
||||
resEntities[
|
||||
//@ts-ignore
|
||||
!CRMEntityAliases.includes(targetName) &&
|
||||
isPlural(targetName)
|
||||
? singular(targetName)
|
||||
: targetName
|
||||
@ -158,9 +154,7 @@ class CalculationService {
|
||||
//@ts-ignore
|
||||
resEntities[
|
||||
//@ts-ignore
|
||||
!CRMEntityAliases.includes(targetName) && isPlural(targetName)
|
||||
? singular(targetName)
|
||||
: targetName
|
||||
isPlural(targetName) ? singular(targetName) : targetName
|
||||
] = optionatedEntities;
|
||||
} else {
|
||||
const entityOption = convertEntityToOption(
|
||||
|
||||
@ -90,7 +90,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
CalculationService.crmgqlquery({
|
||||
query: gql`
|
||||
query($evo_agent_accountid: Uuid!) {
|
||||
agent: account(accountid: $evo_agent_accountid) {
|
||||
account(accountid: $evo_agent_accountid) {
|
||||
accountid
|
||||
name
|
||||
}
|
||||
@ -99,12 +99,17 @@ const reactionEffects: IReactionEffect[] = [
|
||||
variables: {
|
||||
evo_agent_accountid: lead.evo_agent_accountid,
|
||||
},
|
||||
toOptions: ['agent'],
|
||||
toOptions: ['account'],
|
||||
}).then(({ entities }) => {
|
||||
if (entities.agent) {
|
||||
if (!Array.isArray(entities.agent)) {
|
||||
calculationStore.setOptions('selectIndAgent', [entities.agent]);
|
||||
calculationStore.setValue('indAgent', entities.agent.accountid);
|
||||
if (entities.account) {
|
||||
if (!Array.isArray(entities.account)) {
|
||||
calculationStore.setOptions('selectIndAgent', [
|
||||
entities.account,
|
||||
]);
|
||||
calculationStore.setValue(
|
||||
'indAgent',
|
||||
entities.account.accountid,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
calculationStore.setValue('indAgent', null);
|
||||
@ -120,7 +125,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
CalculationService.crmgqlquery({
|
||||
query: gql`
|
||||
query($evo_double_agent_accountid: Uuid!) {
|
||||
double_agent: account(accountid: $evo_double_agent_accountid) {
|
||||
account(accountid: $evo_double_agent_accountid) {
|
||||
accountid
|
||||
name
|
||||
}
|
||||
@ -129,16 +134,16 @@ const reactionEffects: IReactionEffect[] = [
|
||||
variables: {
|
||||
evo_double_agent_accountid: lead.evo_double_agent_accountid,
|
||||
},
|
||||
toOptions: ['double_agent'],
|
||||
toOptions: ['account'],
|
||||
}).then(({ entities }) => {
|
||||
if (entities.double_agent) {
|
||||
if (!Array.isArray(entities.double_agent)) {
|
||||
if (entities.account) {
|
||||
if (!Array.isArray(entities.account)) {
|
||||
calculationStore.setOptions('selectCalcDoubleAgent', [
|
||||
entities.double_agent,
|
||||
entities.account,
|
||||
]);
|
||||
calculationStore.setValue(
|
||||
'calcDoubleAgent',
|
||||
entities.double_agent.accountid,
|
||||
entities.account.accountid,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@ -155,7 +160,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
CalculationService.crmgqlquery({
|
||||
query: gql`
|
||||
query($evo_broker_accountid: Uuid!) {
|
||||
broker: account(accountid: $evo_broker_accountid) {
|
||||
account(accountid: $evo_broker_accountid) {
|
||||
accountid
|
||||
name
|
||||
}
|
||||
@ -164,16 +169,16 @@ const reactionEffects: IReactionEffect[] = [
|
||||
variables: {
|
||||
evo_broker_accountid: lead.evo_broker_accountid,
|
||||
},
|
||||
toOptions: ['broker'],
|
||||
toOptions: ['account'],
|
||||
}).then(({ entities }) => {
|
||||
if (entities.broker) {
|
||||
if (!Array.isArray(entities.broker)) {
|
||||
if (entities.account) {
|
||||
if (!Array.isArray(entities.account)) {
|
||||
calculationStore.setOptions('selectCalcBroker', [
|
||||
entities.broker,
|
||||
entities.account,
|
||||
]);
|
||||
calculationStore.setValue(
|
||||
'calcBroker',
|
||||
entities.broker.accountid,
|
||||
entities.account.accountid,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -187,9 +192,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
CalculationService.crmgqlquery({
|
||||
query: gql`
|
||||
query($evo_fin_department_accountid: Uuid!) {
|
||||
findepartment: account(
|
||||
accountid: $evo_fin_department_accountid
|
||||
) {
|
||||
account(accountid: $evo_fin_department_accountid) {
|
||||
accountid
|
||||
name
|
||||
}
|
||||
@ -198,16 +201,16 @@ const reactionEffects: IReactionEffect[] = [
|
||||
variables: {
|
||||
evo_fin_department_accountid: lead.evo_fin_department_accountid,
|
||||
},
|
||||
toOptions: ['findepartment'],
|
||||
toOptions: ['account'],
|
||||
}).then(({ entities }) => {
|
||||
if (entities.findepartment) {
|
||||
if (!Array.isArray(entities.findepartment)) {
|
||||
if (entities.account) {
|
||||
if (!Array.isArray(entities.account)) {
|
||||
calculationStore.setOptions('selectCalcFinDepartment', [
|
||||
entities.findepartment,
|
||||
entities.account,
|
||||
]);
|
||||
calculationStore.setValue(
|
||||
'calcFinDepartment',
|
||||
entities.findepartment.accountid,
|
||||
entities.account.accountid,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
import {
|
||||
CRMEntityAliasesUnion,
|
||||
CRMEntityNames,
|
||||
} from 'core/types/Entities/crmEntityNames';
|
||||
import { CRMEntityNames } from 'core/types/Entities/crmEntityNames';
|
||||
import { TEntityQuery } from '../Entities/query';
|
||||
import { ValuesTables } from './Store/tables';
|
||||
import { TValue, TValues } from './Store/values';
|
||||
@ -12,7 +9,7 @@ export interface IGetEntitiesRequest {
|
||||
|
||||
export interface IRequestToCRMGQL {
|
||||
query: any;
|
||||
toOptions?: (CRMEntityNames | CRMEntityAliasesUnion)[];
|
||||
toOptions?: CRMEntityNames[];
|
||||
variables: { [prop: string]: any };
|
||||
}
|
||||
|
||||
|
||||
@ -192,7 +192,7 @@ export interface IEvoCurrencyChange {
|
||||
evo_currencychange?: number;
|
||||
evo_coursedate?: Date;
|
||||
statecode?: number;
|
||||
evo_coursedate_param: any;
|
||||
evo_coursedate_param?: any;
|
||||
}
|
||||
|
||||
export interface IEvoStatusCode {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// import { ElementsNames } from 'core/types/Calculation/Store/elements';
|
||||
import { TCRMEntity } from './crmEntities';
|
||||
import { CRMEntityNames, CRMEntityAliasesUnion } from './crmEntityNames';
|
||||
import { CRMEntityNames } from './crmEntityNames';
|
||||
import { ElementsNames } from 'core/types/Calculation/Store/elements';
|
||||
|
||||
export type ComparisonOperators = {
|
||||
@ -16,7 +16,7 @@ export type TEntitiesKeys = keyof TCRMEntity;
|
||||
export type TWhere<T> = { [prop in TEntitiesKeys]?: T };
|
||||
|
||||
export type TBaseEntityQuery = {
|
||||
alias?: CRMEntityAliasesUnion | ElementsNames;
|
||||
alias?: ElementsNames;
|
||||
entityName: CRMEntityNames;
|
||||
fields: [TEntitiesKeys, ...TEntitiesKeys[]];
|
||||
relatedEntities?: TBaseEntityQuery[];
|
||||
|
||||
Reference in New Issue
Block a user