add configurator process
This commit is contained in:
parent
6ac00c17d6
commit
156d3a131a
@ -122,6 +122,44 @@ export type GetCurrencySymbolQueryVariables = Exact<{
|
||||
|
||||
export type GetCurrencySymbolQuery = { __typename?: 'Query', transactioncurrency: { __typename?: 'transactioncurrency', currencysymbol: string | null } | null };
|
||||
|
||||
export type GetLeaseObjectTypes_ProcessConfiguratorQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type GetLeaseObjectTypes_ProcessConfiguratorQuery = { __typename?: 'Query', evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null, label: string | null, value: string | null } | null> | null };
|
||||
|
||||
export type GetProduct_ProcessConfiguratorQueryVariables = Exact<{
|
||||
productId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetProduct_ProcessConfiguratorQuery = { __typename?: 'Query', evo_baseproduct: { __typename?: 'evo_baseproduct', evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null } | null };
|
||||
|
||||
export type GetSubsidy_ProcessConfiguratorQueryVariables = Exact<{
|
||||
subsidyId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetSubsidy_ProcessConfiguratorQuery = { __typename?: 'Query', subsidy: { __typename?: 'evo_subsidy', evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null, accounts: Array<{ __typename?: 'account', accountid: string | null } | null> | null } | null };
|
||||
|
||||
export type GetImportProgram_ProcessConfiguratorQueryVariables = Exact<{
|
||||
importProgramId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetImportProgram_ProcessConfiguratorQuery = { __typename?: 'Query', importProgram: { __typename?: 'evo_subsidy', evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null, accounts: Array<{ __typename?: 'account', accountid: string | null } | null> | null } | null };
|
||||
|
||||
export type GetDealers_ProcessConfiguratorQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type GetDealers_ProcessConfiguratorQuery = { __typename?: 'Query', dealers: Array<{ __typename?: 'account', accountid: string | null, label: string | null, value: string | null } | null> | null };
|
||||
|
||||
export type GetDealerPersons_ProcessConfiguratorQueryVariables = Exact<{
|
||||
dealerId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetDealerPersons_ProcessConfiguratorQuery = { __typename?: 'Query', dealerPersons: Array<{ __typename?: 'account', accountid: string | null, label: string | null, value: string | null } | null> | null };
|
||||
|
||||
export type GetRisksDataFromQuoteQueryVariables = Exact<{
|
||||
quoteId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
267
apps/web/process/configurator/reactions/filters.ts
Normal file
267
apps/web/process/configurator/reactions/filters.ts
Normal file
@ -0,0 +1,267 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { gql } from '@apollo/client';
|
||||
import type * as CRMTypes from 'graphql/crm.types';
|
||||
import { reaction } from 'mobx';
|
||||
import type { ReactionsContext } from 'process/types';
|
||||
import { normalizeOptions } from 'tools';
|
||||
|
||||
const QUERY_GET_LEASE_OBJECT_TYPES = gql`
|
||||
query GetLeaseObjectTypes_ProcessConfigurator {
|
||||
evo_leasingobject_types(statecode: 0) {
|
||||
label: evo_name
|
||||
value: evo_leasingobject_typeid
|
||||
evo_leasingobject_typeid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const QUERY_GET_PRODUCT = gql`
|
||||
query GetProduct_ProcessConfigurator($productId: Uuid!) {
|
||||
evo_baseproduct(evo_baseproductid: $productId) {
|
||||
evo_leasingobject_types {
|
||||
evo_leasingobject_typeid
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const QUERY_GET_SUBSIDY = gql`
|
||||
query GetSubsidy_ProcessConfigurator($subsidyId: Uuid!) {
|
||||
subsidy: evo_subsidy(evo_subsidyid: $subsidyId) {
|
||||
evo_leasingobject_types {
|
||||
evo_leasingobject_typeid
|
||||
}
|
||||
accounts {
|
||||
accountid
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const QUERY_GET_IMPORT_PROGRAM = gql`
|
||||
query GetImportProgram_ProcessConfigurator($importProgramId: Uuid!) {
|
||||
importProgram: evo_subsidy(evo_subsidyid: $importProgramId) {
|
||||
evo_leasingobject_types {
|
||||
evo_leasingobject_typeid
|
||||
}
|
||||
accounts {
|
||||
accountid
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const QUERY_GET_DEALERS = gql`
|
||||
query GetDealers_ProcessConfigurator {
|
||||
dealers: accounts(evo_account_type: [100000001], statecode: 0, evo_legal_form: 100000001) {
|
||||
label: name
|
||||
value: accountid
|
||||
accountid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const QUERY_GET_DEALER_PERSONS = gql`
|
||||
query GetDealerPersons_ProcessConfigurator($dealerId: Uuid!) {
|
||||
dealerPersons: salon_providers(statecode: 0, salonaccountid: $dealerId) {
|
||||
label: name
|
||||
value: accountid
|
||||
accountid
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default function commonReactions({ store, apolloClient }: ReactionsContext) {
|
||||
const { $calculation } = store;
|
||||
|
||||
reaction(
|
||||
() => {
|
||||
const { product, subsidy, importProgram, dealer } = $calculation.$values.values;
|
||||
|
||||
return {
|
||||
productId: product,
|
||||
subsidyId: subsidy,
|
||||
importProgramId: importProgram,
|
||||
dealerId: dealer,
|
||||
};
|
||||
},
|
||||
async ({ productId, subsidyId, importProgramId, dealerId }) => {
|
||||
/**
|
||||
#1
|
||||
* DYN-190 При выборе значения в поле selectSubsidy необходимо добавить
|
||||
* фильтрацию в полях при условии что selectSubsidy не равно null:
|
||||
|
||||
Тип предмета лизинга selectLeaseObjectType
|
||||
если с записью Субсидия нет связанных Типов предмета лизинга,
|
||||
то указываются все записи согласно текущей фильтрации,
|
||||
иначе указываются те записи, которые связаны с Субсидией, указанной в поле selectSubsidy
|
||||
|
||||
#2
|
||||
* На изменение поля Продукт selectProduct добавляем фильтрацию списков:
|
||||
в поле Тип предмета лизинга selectLeaseObjectType - указываются те, которые связаны с продуктом.
|
||||
Если с Продуктом нет связанных Типов предмета лизинга,
|
||||
то указывается весь список. Это надо добавить в текущие условия фильтрации данного поля
|
||||
|
||||
#3
|
||||
Тип предмета лизинга selectLeaseObjectType
|
||||
если с записью Субсидия нет связанных Типов предмета лизинга,
|
||||
то указываются все записи согласно текущей фильтрации,
|
||||
иначе указываются те записи, которые связаны с Субсидией, указанной в поле selectImportProgram
|
||||
*/
|
||||
|
||||
let {
|
||||
data: { evo_leasingobject_types: leaseObjectTypes = [] },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetLeaseObjectTypes_ProcessConfiguratorQuery,
|
||||
CRMTypes.GetLeaseObjectTypes_ProcessConfiguratorQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_LEASE_OBJECT_TYPES,
|
||||
});
|
||||
|
||||
let {
|
||||
data: { dealers = [] },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetDealers_ProcessConfiguratorQuery,
|
||||
CRMTypes.GetDealers_ProcessConfiguratorQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_DEALERS,
|
||||
});
|
||||
|
||||
let dealerPersons: CRMTypes.GetDealerPersons_ProcessConfiguratorQuery['dealerPersons'] = [];
|
||||
if (dealerId) {
|
||||
const { data } = await apolloClient.query<
|
||||
CRMTypes.GetDealerPersons_ProcessConfiguratorQuery,
|
||||
CRMTypes.GetDealerPersons_ProcessConfiguratorQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_DEALER_PERSONS,
|
||||
variables: {
|
||||
dealerId,
|
||||
},
|
||||
});
|
||||
|
||||
({ dealerPersons = [] } = data);
|
||||
}
|
||||
|
||||
if (productId) {
|
||||
const {
|
||||
data: { evo_baseproduct },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetProduct_ProcessConfiguratorQuery,
|
||||
CRMTypes.GetProduct_ProcessConfiguratorQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_PRODUCT,
|
||||
variables: {
|
||||
productId,
|
||||
},
|
||||
});
|
||||
|
||||
if (leaseObjectTypes) {
|
||||
leaseObjectTypes = leaseObjectTypes?.filter(
|
||||
(leasingObjectType) =>
|
||||
!evo_baseproduct?.evo_leasingobject_types?.length ||
|
||||
evo_baseproduct.evo_leasingobject_types.filter(
|
||||
(baseproduct_evo_leasingobject_type) =>
|
||||
baseproduct_evo_leasingobject_type?.evo_leasingobject_typeid ===
|
||||
leasingObjectType?.evo_leasingobject_typeid
|
||||
)?.length
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (subsidyId) {
|
||||
const {
|
||||
data: { subsidy },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetSubsidy_ProcessConfiguratorQuery,
|
||||
CRMTypes.GetSubsidy_ProcessConfiguratorQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_SUBSIDY,
|
||||
variables: {
|
||||
subsidyId,
|
||||
},
|
||||
});
|
||||
if (leaseObjectTypes) {
|
||||
leaseObjectTypes = leaseObjectTypes?.filter(
|
||||
(leasingObjectType) =>
|
||||
!subsidy?.evo_leasingobject_types?.length ||
|
||||
subsidy.evo_leasingobject_types.filter(
|
||||
(subsidy_evo_leasingobject_type) =>
|
||||
subsidy_evo_leasingobject_type?.evo_leasingobject_typeid ===
|
||||
leasingObjectType?.evo_leasingobject_typeid
|
||||
)?.length
|
||||
);
|
||||
}
|
||||
|
||||
if (dealers) {
|
||||
dealers = dealers.filter(
|
||||
(dealer) =>
|
||||
!subsidy?.accounts?.length ||
|
||||
subsidy.accounts.filter(
|
||||
(subsidy_account) => subsidy_account?.accountid === dealer?.accountid
|
||||
)?.length
|
||||
);
|
||||
}
|
||||
|
||||
if (dealerPersons) {
|
||||
dealerPersons = dealerPersons.filter(
|
||||
(dealerPerson) =>
|
||||
!subsidy?.accounts?.length ||
|
||||
subsidy.accounts.filter(
|
||||
(subsidy_account) => subsidy_account?.accountid === dealerPerson?.accountid
|
||||
)?.length
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (importProgramId) {
|
||||
const {
|
||||
data: { importProgram },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetImportProgram_ProcessConfiguratorQuery,
|
||||
CRMTypes.GetImportProgram_ProcessConfiguratorQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_IMPORT_PROGRAM,
|
||||
variables: {
|
||||
importProgramId,
|
||||
},
|
||||
});
|
||||
if (leaseObjectTypes) {
|
||||
leaseObjectTypes = leaseObjectTypes?.filter(
|
||||
(leasingObjectType) =>
|
||||
!importProgram?.evo_leasingobject_types?.length ||
|
||||
importProgram.evo_leasingobject_types.filter(
|
||||
(importProgram_evo_leasingobject_type) =>
|
||||
importProgram_evo_leasingobject_type?.evo_leasingobject_typeid ===
|
||||
leasingObjectType?.evo_leasingobject_typeid
|
||||
)?.length
|
||||
);
|
||||
}
|
||||
|
||||
if (dealers) {
|
||||
dealers = dealers.filter(
|
||||
(dealer) =>
|
||||
!importProgram?.accounts?.length ||
|
||||
importProgram.accounts.filter(
|
||||
(importProgram_account) => importProgram_account?.accountid === dealer?.accountid
|
||||
)?.length
|
||||
);
|
||||
}
|
||||
|
||||
if (dealerPersons) {
|
||||
dealerPersons = dealerPersons.filter(
|
||||
(dealerPerson) =>
|
||||
!importProgram?.accounts?.length ||
|
||||
importProgram.accounts.filter(
|
||||
(importProgram_account) =>
|
||||
importProgram_account?.accountid === dealerPerson?.accountid
|
||||
)?.length
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$calculation.element('selectLeaseObjectType').setOptions(normalizeOptions(leaseObjectTypes));
|
||||
$calculation.element('selectDealer').setOptions(normalizeOptions(dealers));
|
||||
$calculation.element('selectDealerPerson').setOptions(normalizeOptions(dealerPersons));
|
||||
}
|
||||
);
|
||||
}
|
||||
2
apps/web/process/configurator/reactions/index.js
Normal file
2
apps/web/process/configurator/reactions/index.js
Normal file
@ -0,0 +1,2 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
export { default as filters } from './filters';
|
||||
@ -1,5 +1,6 @@
|
||||
import loadKpReactions from 'process/load-kp/reactions';
|
||||
import * as calculateReactions from '../../calculate/reactions';
|
||||
import * as configurator from '../../configurator/reactions';
|
||||
import * as fingapReactions from '../../fingap/reactions';
|
||||
import * as leadOpportunityReactions from '../../lead-opportunity/reactions';
|
||||
import * as leasingObject from '../../leasing-object/reactions';
|
||||
@ -33,4 +34,5 @@ export default function injectDefaultReactions(context) {
|
||||
subsidyReactions.commonReactions(context);
|
||||
leasingObject.common(context);
|
||||
leasingObject.validation(context);
|
||||
configurator.filters(context);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user