graphql: move shared queries to .graphql file

This commit is contained in:
vchikalkin 2023-02-01 16:22:30 +03:00
parent 922244d33a
commit 68a6b8d205
3 changed files with 157 additions and 191 deletions

View File

@ -0,0 +1,155 @@
query GetTransactionCurrencies {
transactioncurrencies {
label: currencyname
value: transactioncurrencyid
transactioncurrencyid
isocurrencycode
currencysymbol
}
}
query GetTarifs($currentDate: DateTime) {
evo_tarifs(
statecode: 0
evo_datefrom_param: { lte: $currentDate }
evo_dateto_param: { gte: $currentDate }
) {
label: evo_name
value: evo_tarifid
evo_tarifid
evo_baseproductid
evo_min_period
evo_max_period
evo_delivery_time
evo_min_first_payment
evo_max_first_payment
evo_min_last_payment
evo_max_last_payment
evo_used
}
}
query GetTarif($tarifId: Uuid!) {
evo_tarif(evo_tarifid: $tarifId) {
evo_irr
evo_graphtype_exception
evo_seasons_type_exception
evo_min_decreasing_perc
}
}
query GetProducts($currentDate: DateTime) {
evo_baseproducts(
statecode: 0
evo_relation: [100000000]
evo_datefrom_param: { lte: $currentDate }
evo_dateto_param: { gte: $currentDate }
) {
label: evo_name
value: evo_baseproductid
evo_baseproductid
}
}
query GetProduct($productId: Uuid!) {
evo_baseproduct(evo_baseproductid: $productId) {
evo_leasingobject_types {
evo_leasingobject_typeid
}
evo_calculation_method
evo_baseproducts {
evo_baseproductid
}
evo_brands {
evo_brandid
}
}
}
query GetSubsidy($subsidyId: Uuid!) {
subsidy: evo_subsidy(evo_subsidyid: $subsidyId) {
evo_leasingobject_types {
evo_leasingobject_typeid
}
accounts {
accountid
}
evo_brands {
evo_brandid
}
evo_models {
evo_modelid
}
}
}
query GetImportProgram($importProgramId: Uuid!) {
importProgram: evo_subsidy(evo_subsidyid: $importProgramId) {
evo_leasingobject_types {
evo_leasingobject_typeid
}
accounts {
accountid
}
evo_brands {
evo_brandid
}
evo_models {
evo_modelid
}
}
}
query GetLeaseObjectTypes {
evo_leasingobject_types(statecode: 0) {
label: evo_name
value: evo_leasingobject_typeid
evo_leasingobject_typeid
}
}
query GetBrands {
evo_brands(statecode: 0) {
label: evo_name
value: evo_brandid
evo_brandid
evo_vehicle_type
}
}
query GetDealers {
dealers: accounts(evo_account_type: [100000001], statecode: 0, evo_legal_form: 100000001) {
label: name
value: accountid
accountid
}
}
query GetDealerPersons($dealerId: Uuid!) {
dealerPersons: salon_providers(statecode: 0, salonaccountid: $dealerId) {
label: name
value: accountid
accountid
evo_inn
evo_kpp
}
}
query GetAgent($agentid: Uuid!) {
agent: account(accountid: $agentid) {
label: name
value: accountid
}
}
query GetDealerReturnLeasing($dealerId: Uuid!) {
dealer: account(accountid: $dealerId) {
evo_return_leasing_dealer
}
}
query GetQuote($quoteId: Uuid!) {
quote(quoteId: $quoteId) {
evo_baseproductid
}
}

View File

@ -1,177 +0,0 @@
import { gql } from '@apollo/client';
export const QUERY_GET_TRANSACTION_CURRENCIES = gql`
query GetTransactionCurrencies {
transactioncurrencies {
label: currencyname
value: transactioncurrencyid
transactioncurrencyid
isocurrencycode
currencysymbol
}
}
`;
export const QUERY_GET_TARIFS = gql`
query GetTarifs($currentDate: DateTime) {
evo_tarifs(
statecode: 0
evo_datefrom_param: { lte: $currentDate }
evo_dateto_param: { gte: $currentDate }
) {
label: evo_name
value: evo_tarifid
evo_tarifid
evo_baseproductid
evo_min_period
evo_max_period
evo_delivery_time
evo_min_first_payment
evo_max_first_payment
evo_min_last_payment
evo_max_last_payment
evo_used
}
}
`;
export const QUERY_GET_TARIF = gql`
query GetTarif($tarifId: Uuid!) {
evo_tarif(evo_tarifid: $tarifId) {
evo_irr
evo_graphtype_exception
evo_seasons_type_exception
evo_min_decreasing_perc
}
}
`;
export const QUERY_GET_PRODUCTS = gql`
query GetProducts($currentDate: DateTime) {
evo_baseproducts(
statecode: 0
evo_relation: [100000000]
evo_datefrom_param: { lte: $currentDate }
evo_dateto_param: { gte: $currentDate }
) {
label: evo_name
value: evo_baseproductid
evo_baseproductid
}
}
`;
export const QUERY_GET_PRODUCT = gql`
query GetProduct($productId: Uuid!) {
evo_baseproduct(evo_baseproductid: $productId) {
evo_leasingobject_types {
evo_leasingobject_typeid
}
evo_calculation_method
evo_baseproducts {
evo_baseproductid
}
evo_brands {
evo_brandid
}
}
}
`;
export const QUERY_GET_SUBSIDY = gql`
query GetSubsidy($subsidyId: Uuid!) {
subsidy: evo_subsidy(evo_subsidyid: $subsidyId) {
evo_leasingobject_types {
evo_leasingobject_typeid
}
accounts {
accountid
}
evo_brands {
evo_brandid
}
evo_models {
evo_modelid
}
}
}
`;
export const QUERY_GET_IMPORT_PROGRAM = gql`
query GetImportProgram($importProgramId: Uuid!) {
importProgram: evo_subsidy(evo_subsidyid: $importProgramId) {
evo_leasingobject_types {
evo_leasingobject_typeid
}
accounts {
accountid
}
evo_brands {
evo_brandid
}
evo_models {
evo_modelid
}
}
}
`;
export const QUERY_GET_LEASE_OBJECT_TYPES = gql`
query GetLeaseObjectTypes {
evo_leasingobject_types(statecode: 0) {
label: evo_name
value: evo_leasingobject_typeid
evo_leasingobject_typeid
}
}
`;
export const QUERY_GET_BRANDS = gql`
query GetBrands {
evo_brands(statecode: 0) {
label: evo_name
value: evo_brandid
evo_brandid
evo_vehicle_type
}
}
`;
export const QUERY_GET_DEALERS = gql`
query GetDealers {
dealers: accounts(evo_account_type: [100000001], statecode: 0, evo_legal_form: 100000001) {
label: name
value: accountid
accountid
}
}
`;
export const QUERY_GET_DEALER_PERSONS = gql`
query GetDealerPersons($dealerId: Uuid!) {
dealerPersons: salon_providers(statecode: 0, salonaccountid: $dealerId) {
label: name
value: accountid
accountid
evo_inn
evo_kpp
}
}
`;
export const QUERY_GET_AGENT = gql`
query GetAgent($agentid: Uuid!) {
agent: account(accountid: $agentid) {
label: name
value: accountid
}
}
`;
export const QUERY_GET_DEALER_RETURN_LEASING = gql`
query GetDealerReturnLeasing($dealerId: Uuid!) {
dealer: account(accountid: $dealerId) {
evo_return_leasing_dealer
}
}
`;

View File

@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { gql } from '@apollo/client';
import { radioGraphType, selectSeasonType } from 'config/default-options';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
@ -12,14 +11,6 @@ import { normalizeOptions } from 'tools';
dayjs.extend(utc);
const QUERY_GET_QUOTE = gql`
query GetQuote($quoteId: Uuid!) {
quote(quoteId: $quoteId) {
evo_baseproductid
}
}
`;
export default function commonReactions({ store, apolloClient }: ReactionsContext) {
const { $calculation } = store;
@ -339,11 +330,8 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex
let quote: CRMTypes.GetQuoteQuery['quote'] = null;
if (quoteId) {
const { data } = await apolloClient.query<
CRMTypes.GetQuoteQuery,
CRMTypes.GetQuoteQueryVariables
>({
query: QUERY_GET_QUOTE,
const { data } = await apolloClient.query({
query: CRMTypes.GetQuoteDocument,
variables: {
quoteId,
},