process/init: fetch new options

This commit is contained in:
vchikalkin 2022-07-12 11:54:16 +03:00
parent a819140990
commit a569586052
3 changed files with 82 additions and 1 deletions

View File

@ -20,12 +20,36 @@ export interface GetMainOptions_selectProduct {
value: any | null;
}
export interface GetMainOptions_selectLeaseObjectType {
__typename: "evo_leasingobject_type";
label: string | null;
value: any | null;
}
export interface GetMainOptions_selectBrand {
__typename: "evo_brand";
label: string | null;
value: any | null;
}
export interface GetMainOptions_selectDealer {
__typename: "account";
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;
selectBrand: (GetMainOptions_selectBrand | null)[] | null;
/**
* Контрагенты. statecode по умолчанию 0
*/
selectDealer: (GetMainOptions_selectDealer | null)[] | null;
}
export interface GetMainOptionsVariables {

21
process/init/__generated__/GetRegions.ts generated Normal file
View File

@ -0,0 +1,21 @@
/* 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;
}

View File

@ -9,6 +9,7 @@ import { normalizeOptions } from 'tools/entity';
import type { GetInsuranceData } from './__generated__/GetInsuranceData';
import type { GetMainOptions } from './__generated__/GetMainOptions';
import type { GetOwnerData, GetOwnerDataVariables } from './__generated__/GetOwnerData';
import type { GetRegions } from './__generated__/GetRegions';
import type { GetSubsidies } from './__generated__/GetSubsidies';
dayjs.extend(utc);
@ -43,6 +44,21 @@ const QUERY_GET_MAIN_OPTIONS = gql`
label: evo_name
value: evo_baseproductid
}
selectLeaseObjectType: evo_leasingobject_types(statecode: 0) {
label: evo_name
value: evo_leasingobject_typeid
}
selectBrand: evo_brands(statecode: 0) {
label: evo_name
value: evo_brandid
}
selectDealer: accounts(evo_account_type: [100000001], statecode: 0, evo_legal_form: 100000001) {
label: name
value: accountid
}
}
`;
@ -60,6 +76,15 @@ const QUERY_GET_SUBSIDIES = gql`
}
`;
const QUERY_GET_REGIONS = gql`
query GetRegions {
evo_regions {
label: evo_name
value: evo_regionid
}
}
`;
const QUERY_GET_INSURANCE_DATA = gql`
query GetInsuranceData($evo_account_type: [Int!]) {
osago: accounts(
@ -142,13 +167,24 @@ export async function getCRMData(apolloClient: ApolloClient<NormalizedCache>, us
(x) => x?.evo_subsidy_type && [100_000_002].includes(x?.evo_subsidy_type)
);
const { data: regions } = await apolloClient.query<GetRegions>({
query: QUERY_GET_REGIONS,
});
const selectRegionRegistration = regions.evo_regions;
const selectObjectRegionRegistration = regions.evo_regions;
const selectLegalClientRegion = regions.evo_regions;
return {
options: {
selectLead,
selectOpportunity,
...options,
selectSubsidy,
selectImportProgram,
...options,
selectRegionRegistration,
selectObjectRegionRegistration,
selectLegalClientRegion,
},
tables: {
insurance: insuranceData,