From a569586052344253896ea9a2b349d82e453bcae4 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Tue, 12 Jul 2022 11:54:16 +0300 Subject: [PATCH] process/init: fetch new options --- process/init/__generated__/GetMainOptions.ts | 24 +++++++++++++ process/init/__generated__/GetRegions.ts | 21 +++++++++++ process/init/get-data.ts | 38 +++++++++++++++++++- 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 process/init/__generated__/GetRegions.ts diff --git a/process/init/__generated__/GetMainOptions.ts b/process/init/__generated__/GetMainOptions.ts index 446aa4b..82a681d 100644 --- a/process/init/__generated__/GetMainOptions.ts +++ b/process/init/__generated__/GetMainOptions.ts @@ -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 { diff --git a/process/init/__generated__/GetRegions.ts b/process/init/__generated__/GetRegions.ts new file mode 100644 index 0000000..a8d54f3 --- /dev/null +++ b/process/init/__generated__/GetRegions.ts @@ -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; +} diff --git a/process/init/get-data.ts b/process/init/get-data.ts index 6eda786..9d53758 100644 --- a/process/init/get-data.ts +++ b/process/init/get-data.ts @@ -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, us (x) => x?.evo_subsidy_type && [100_000_002].includes(x?.evo_subsidy_type) ); + const { data: regions } = await apolloClient.query({ + 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,