This repository has been archived on 2025-05-09. You can view files and clone it, but cannot push or open issues or pull requests.
2022-01-12 15:35:19 +03:00

78 lines
1.8 KiB
TypeScript

import UserStore from 'client/stores/UserStore';
import {
getInsuranceOptionsQuery,
getMainOptionsQuery,
getOwnerOptionsQuery,
} from 'core/graphql/query/crm/options';
import {
getStaticDataQuery,
getSystemUserQuery,
} from 'core/graphql/query/crm/staticData';
import CrmService from 'core/services/CrmService';
import { ElementsNames } from 'core/types/Calculation/Store/elements';
import { TableValuesNames } from 'core/types/Calculation/Store/tables';
import {
IAccount,
ILead,
IOpportunity,
ISystemUser,
TCRMEntity,
} from 'core/types/Entities/crmEntities';
import { CRMEntityNames } from 'core/types/Entities/crmEntityNames';
import {
insuranceVariables,
mainOptionsVariables,
staticDataVariables,
} from './variables';
export function composeRequests() {
const mainOptionsRequest = CrmService.getCRMOptions<ElementsNames>({
query: getMainOptionsQuery,
variables: mainOptionsVariables,
});
const staticDataRequest = CrmService.getCRMEntities<
CRMEntityNames,
TCRMEntity[]
>({
query: getStaticDataQuery,
variables: staticDataVariables,
});
const domainname = UserStore.getDomainName();
const systemUserRequest = CrmService.getCRMEntities<
CRMEntityNames,
ISystemUser
>({
query: getSystemUserQuery,
variables: { domainname },
});
const ownerOptionsRequest = CrmService.getCRMOptions<
ElementsNames,
ILead & IOpportunity
>({
query: getOwnerOptionsQuery,
variables: {
statecode: 0,
domainname,
},
});
const insuranceRequest = CrmService.getCRMOptions<TableValuesNames, IAccount>(
{
query: getInsuranceOptionsQuery,
variables: insuranceVariables,
},
);
return {
mainOptionsRequest,
staticDataRequest,
systemUserRequest,
insuranceRequest,
ownerOptionsRequest,
};
}