process/init: fetch new options
This commit is contained in:
parent
a3fe3a5621
commit
a819140990
@ -10,7 +10,7 @@ export const rows: FormTabRows = [
|
||||
[['selectSupplierCurrency', 'tbxSupplierDiscountRub', 'tbxSupplierDiscountPerc']],
|
||||
[['tbxFirstPaymentPerc', 'tbxFirstPaymentRub']],
|
||||
[['tbxLeasingPeriod', 'tbxSaleBonus', 'tbxRedemptionPaymentSum']],
|
||||
[['selectSubsidy', 'tbxSubsidySum']],
|
||||
[['selectSubsidy', 'tbxSubsidySum'], { gridTemplateColumns: '2fr 1fr' }],
|
||||
[['selectImportProgram', 'tbxImportProgramSum', 'tbxAddEquipmentPrice']],
|
||||
[['radioLastPaymentRule'], { gridTemplateColumns: '1fr' }],
|
||||
[['tbxLastPaymentPerc', 'tbxLastPaymentRub']],
|
||||
|
||||
33
process/init/__generated__/GetMainOptions.ts
generated
Normal file
33
process/init/__generated__/GetMainOptions.ts
generated
Normal file
@ -0,0 +1,33 @@
|
||||
/* 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 {
|
||||
/**
|
||||
* Валюта. statecode по умолчанию 0
|
||||
*/
|
||||
selectSupplierCurrency: (GetMainOptions_selectSupplierCurrency | null)[] | null;
|
||||
selectProduct: (GetMainOptions_selectProduct | null)[] | null;
|
||||
}
|
||||
|
||||
export interface GetMainOptionsVariables {
|
||||
currentDate?: any | null;
|
||||
}
|
||||
23
process/init/__generated__/GetSubsidies.ts
generated
Normal file
23
process/init/__generated__/GetSubsidies.ts
generated
Normal file
@ -0,0 +1,23 @@
|
||||
/* 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,22 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: GetTransactionCurrencies
|
||||
// ====================================================
|
||||
|
||||
export interface GetTransactionCurrencies_selectSupplierCurrency {
|
||||
__typename: "transactioncurrency";
|
||||
label: string | null;
|
||||
currencysymbol: string | null;
|
||||
value: any | null;
|
||||
}
|
||||
|
||||
export interface GetTransactionCurrencies {
|
||||
/**
|
||||
* Валюта. statecode по умолчанию 0
|
||||
*/
|
||||
selectSupplierCurrency: (GetTransactionCurrencies_selectSupplierCurrency | null)[] | null;
|
||||
}
|
||||
@ -1,12 +1,17 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import type { ApolloClient, NormalizedCache } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { getDomainName } from 'services/user/tools';
|
||||
import type { User } from 'services/user/types';
|
||||
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 { GetTransactionCurrencies } from './__generated__/GetTransactionCurrencies';
|
||||
import type { GetSubsidies } from './__generated__/GetSubsidies';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
const QUERY_GET_OWNER_DATA = gql`
|
||||
query GetOwnerData($domainname: String) {
|
||||
@ -21,13 +26,37 @@ const QUERY_GET_OWNER_DATA = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
const QUERY_GET_TRANSACTION_CURRENCIES = gql`
|
||||
query GetTransactionCurrencies {
|
||||
const QUERY_GET_MAIN_OPTIONS = gql`
|
||||
query GetMainOptions($currentDate: DateTime) {
|
||||
selectSupplierCurrency: transactioncurrencies {
|
||||
label: currencyname
|
||||
currencysymbol
|
||||
value: transactioncurrencyid
|
||||
}
|
||||
|
||||
selectProduct: evo_baseproducts(
|
||||
statecode: 0
|
||||
evo_relation: [100000000]
|
||||
evo_datefrom_param: { lte: $currentDate }
|
||||
evo_dateto_param: { gte: $currentDate }
|
||||
) {
|
||||
label: evo_name
|
||||
value: evo_baseproductid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const QUERY_GET_SUBSIDIES = gql`
|
||||
query GetSubsidies($currentDate: DateTime) {
|
||||
evo_subsidies(
|
||||
statecode: 0
|
||||
evo_datefrom_param: { lte: $currentDate }
|
||||
evo_dateto_param: { gte: $currentDate }
|
||||
) {
|
||||
label: evo_name
|
||||
value: evo_subsidyid
|
||||
evo_subsidy_type
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@ -73,8 +102,11 @@ export async function getCRMData(apolloClient: ApolloClient<NormalizedCache>, us
|
||||
});
|
||||
|
||||
// prettier-ignore
|
||||
const { data: { selectSupplierCurrency } } = await apolloClient.query<GetTransactionCurrencies>({
|
||||
query: QUERY_GET_TRANSACTION_CURRENCIES,
|
||||
const { data: options } = await apolloClient.query<GetMainOptions>({
|
||||
query: QUERY_GET_MAIN_OPTIONS,
|
||||
variables: {
|
||||
currentDate: dayjs().utc().toISOString()
|
||||
}
|
||||
});
|
||||
|
||||
const {
|
||||
@ -95,11 +127,28 @@ export async function getCRMData(apolloClient: ApolloClient<NormalizedCache>, us
|
||||
},
|
||||
};
|
||||
|
||||
const { data: subsidies } = await apolloClient.query<GetSubsidies>({
|
||||
query: QUERY_GET_SUBSIDIES,
|
||||
variables: {
|
||||
currentDate: dayjs().utc().toISOString(),
|
||||
},
|
||||
});
|
||||
|
||||
const selectSubsidy = subsidies.evo_subsidies?.filter(
|
||||
(x) => x?.evo_subsidy_type && [100_000_000, 100_000_001].includes(x?.evo_subsidy_type)
|
||||
);
|
||||
|
||||
const selectImportProgram = subsidies.evo_subsidies?.filter(
|
||||
(x) => x?.evo_subsidy_type && [100_000_002].includes(x?.evo_subsidy_type)
|
||||
);
|
||||
|
||||
return {
|
||||
options: {
|
||||
selectLead,
|
||||
selectOpportunity,
|
||||
selectSupplierCurrency,
|
||||
selectSubsidy,
|
||||
selectImportProgram,
|
||||
...options,
|
||||
},
|
||||
tables: {
|
||||
insurance: insuranceData,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user