From 9e225d897ede1361465e0d80ea1dbdb087fc20c7 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Mon, 20 Feb 2023 12:57:59 +0300 Subject: [PATCH] organize exports pt 2 --- apps/web/config/process/default.ts | 45 +++++++++++++++++++ apps/web/config/process/index.ts | 1 + apps/web/pages/index.jsx | 14 +++--- apps/web/process/bonuses/reactions/common.ts | 4 +- .../process/bonuses/reactions/lib/helper.ts | 4 +- .../process/bonuses/reactions/validation.ts | 4 +- .../web/process/calculate/reactions/common.ts | 4 +- .../process/calculate/reactions/validation.ts | 4 +- .../process/configurator/reactions/filters.ts | 4 +- .../configurator/reactions/validation.ts | 4 +- .../process/configurator/reactions/values.ts | 4 +- apps/web/process/create-kp/reactions.ts | 4 +- apps/web/process/fingap/reactions/common.ts | 4 +- .../process/fingap/reactions/validation.ts | 4 +- .../inject-reactions/hooks.js => hooks.ts} | 6 +-- apps/web/process/init/get-data/index.js | 3 -- .../init/{get-data => }/get-initial-data.ts | 0 .../init/{get-data => }/get-insurance-data.js | 0 .../init/{get-data => }/get-main-data.js | 0 apps/web/process/init/index.js | 3 ++ .../process/init/inject-reactions/default.js | 42 ----------------- .../lead-opportunity/reactions/common.ts | 4 +- .../lead-opportunity/reactions/urls.ts | 4 +- .../leasing-object/reactions/common.ts | 4 +- .../leasing-object/reactions/validation.ts | 4 +- .../leasing-without-kasko/reactions.ts | 4 +- apps/web/process/load-kp/reactions.ts | 4 +- apps/web/process/payments/reactions/common.ts | 4 +- .../process/payments/reactions/validation.ts | 4 +- apps/web/process/price/reactions/common.ts | 4 +- apps/web/process/price/reactions/computed.ts | 4 +- .../web/process/price/reactions/validation.ts | 4 +- .../subsidy-import-program/reactions.ts | 4 +- apps/web/process/subsidy/reactions.ts | 4 +- .../supplier-agent/reactions/agents.ts | 6 +-- .../process/supplier-agent/reactions/index.ts | 6 +-- .../supplier-agent/reactions/leaseback.ts | 4 +- .../supplier-agent/reactions/supplier.ts | 6 +-- apps/web/process/types.ts | 2 +- apps/web/process/used-pl/reactions.ts | 4 +- apps/web/trpc/routers/quote.ts | 4 +- 41 files changed, 123 insertions(+), 119 deletions(-) create mode 100644 apps/web/config/process/default.ts create mode 100644 apps/web/config/process/index.ts rename apps/web/process/{init/inject-reactions/hooks.js => hooks.ts} (73%) delete mode 100644 apps/web/process/init/get-data/index.js rename apps/web/process/init/{get-data => }/get-initial-data.ts (100%) rename apps/web/process/init/{get-data => }/get-insurance-data.js (100%) rename apps/web/process/init/{get-data => }/get-main-data.js (100%) create mode 100644 apps/web/process/init/index.js delete mode 100644 apps/web/process/init/inject-reactions/default.js diff --git a/apps/web/config/process/default.ts b/apps/web/config/process/default.ts new file mode 100644 index 0000000..249ec21 --- /dev/null +++ b/apps/web/config/process/default.ts @@ -0,0 +1,45 @@ +import * as bonuses from '@/process/bonuses'; +import * as calculate from '@/process/calculate'; +import * as configurator from '@/process/configurator'; +import * as createKP from '@/process/create-kp'; +import * as fingap from '@/process/fingap'; +import { useProcess } from '@/process/hooks'; +import * as leadOpportunity from '@/process/lead-opportunity'; +import * as leasingObject from '@/process/leasing-object'; +import * as leasingWithoutKasko from '@/process/leasing-without-kasko'; +import * as loadKP from '@/process/load-kp'; +import * as payments from '@/process/payments'; +import * as price from '@/process/price'; +import * as subsidy from '@/process/subsidy'; +import * as subsidyImportProgram from '@/process/subsidy-import-program'; +import * as supplierAgent from '@/process/supplier-agent'; +import * as usedPl from '@/process/used-pl'; + +export default function useReactions() { + useProcess(leadOpportunity.common); + useProcess(leadOpportunity.urls); + useProcess(loadKP.common); + useProcess(calculate.common); + useProcess(calculate.validation); + useProcess(supplierAgent.common); + useProcess(supplierAgent.validation); + useProcess(price.common); + useProcess(price.computed); + useProcess(price.validation); + useProcess(fingap.common); + useProcess(fingap.validation); + useProcess(loadKP.common); + useProcess(leasingWithoutKasko.common); + useProcess(subsidy.common); + useProcess(leasingObject.common); + useProcess(leasingObject.validation); + useProcess(configurator.filters); + useProcess(configurator.values); + useProcess(configurator.validation); + useProcess(createKP.common); + useProcess(bonuses.common); + useProcess(bonuses.validation); + useProcess(usedPl.common); + useProcess(subsidyImportProgram.common); + useProcess(payments.common); +} diff --git a/apps/web/config/process/index.ts b/apps/web/config/process/index.ts new file mode 100644 index 0000000..ab201ad --- /dev/null +++ b/apps/web/config/process/index.ts @@ -0,0 +1 @@ +export { default as useDefaultReactions } from './default'; diff --git a/apps/web/pages/index.jsx b/apps/web/pages/index.jsx index 5671f53..3cb4704 100644 --- a/apps/web/pages/index.jsx +++ b/apps/web/pages/index.jsx @@ -3,16 +3,14 @@ import initializeApollo from '@/apollo/client'; import * as Calculation from '@/Components/Calculation'; import { CRMError } from '@/Components/Common/Error'; import Output from '@/Components/Output'; -import * as getData from '@/process/init/get-data'; -import { useReactions } from '@/process/init/inject-reactions/hooks'; +import { useDefaultReactions } from '@/config/process'; +import * as init from '@/process/init'; import { min } from '@/styles/mq'; import { dehydrate, QueryClient } from '@tanstack/react-query'; import Head from 'next/head'; import styled from 'styled-components'; import { Box } from 'ui/grid'; -const { getInitialData, useInsuranceData, useMainData } = getData; - const Grid = styled(Box)` display: flex; flex-direction: column; @@ -38,9 +36,9 @@ const Grid = styled(Box)` `; function Home({ error }) { - useMainData(); - useInsuranceData(); - useReactions(); + init.useMainData(); + init.useInsuranceData(); + useDefaultReactions(); if (error) return ; @@ -71,7 +69,7 @@ export const getServerSideProps = async ({ req }) => { const apolloClient = initializeApollo(); try { - const { values, options } = await getInitialData(apolloClient, user); + const { values, options } = await init.getInitialData(apolloClient, user); return { props: { diff --git a/apps/web/process/bonuses/reactions/common.ts b/apps/web/process/bonuses/reactions/common.ts index 65e2a37..93a4fdc 100644 --- a/apps/web/process/bonuses/reactions/common.ts +++ b/apps/web/process/bonuses/reactions/common.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import type { ReactionsContext } from '../../types'; +import type { ProcessContext } from '../../types'; import helper from './lib/helper'; import { makeDisposable } from '@/../../packages/tools'; import * as CRMTypes from '@/graphql/crm.types'; @@ -9,7 +9,7 @@ import { reaction } from 'mobx'; dayjs.extend(utc); -export default function reactions(context: ReactionsContext) { +export default function reactions(context: ProcessContext) { const { store, apolloClient } = context; const { $calculation, $process } = store; const { getCoefficient } = helper(context); diff --git a/apps/web/process/bonuses/reactions/lib/helper.ts b/apps/web/process/bonuses/reactions/lib/helper.ts index d9bd337..4536fee 100644 --- a/apps/web/process/bonuses/reactions/lib/helper.ts +++ b/apps/web/process/bonuses/reactions/lib/helper.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import type { ReactionsContext } from '../../../types'; +import type { ProcessContext } from '../../../types'; import { getUser } from '@/api/user/query'; import type { ElementsTypes } from '@/Components/Calculation/config/map/values'; import { STALE_TIME } from '@/constants/request'; @@ -8,7 +8,7 @@ import dayjs from 'dayjs'; export type ProductId = ElementsTypes['selectProduct']; -export default function helper({ apolloClient, queryClient }: ReactionsContext) { +export default function helper({ apolloClient, queryClient }: ProcessContext) { return { async getCoefficient(productId: ProductId) { if (!productId) { diff --git a/apps/web/process/bonuses/reactions/validation.ts b/apps/web/process/bonuses/reactions/validation.ts index b01132e..961c169 100644 --- a/apps/web/process/bonuses/reactions/validation.ts +++ b/apps/web/process/bonuses/reactions/validation.ts @@ -1,9 +1,9 @@ import helper from './lib/helper'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; import { round } from 'tools'; -export default function reactions(context: ReactionsContext) { +export default function reactions(context: ProcessContext) { const { store } = context; const { $calculation } = store; const { getCoefficient } = helper(context); diff --git a/apps/web/process/calculate/reactions/common.ts b/apps/web/process/calculate/reactions/common.ts index bd09384..aa940f3 100644 --- a/apps/web/process/calculate/reactions/common.ts +++ b/apps/web/process/calculate/reactions/common.ts @@ -1,10 +1,10 @@ /* eslint-disable @typescript-eslint/naming-convention */ import * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; import { formatter } from 'tools'; -export default function reactions({ store, apolloClient }: ReactionsContext) { +export default function reactions({ store, apolloClient }: ProcessContext) { const { $calculation } = store; reaction( diff --git a/apps/web/process/calculate/reactions/validation.ts b/apps/web/process/calculate/reactions/validation.ts index c34384e..1ace7fb 100644 --- a/apps/web/process/calculate/reactions/validation.ts +++ b/apps/web/process/calculate/reactions/validation.ts @@ -1,7 +1,7 @@ import types from '@/Components/Calculation/config/elements-types'; import type * as Values from '@/Components/Calculation/config/map/values'; import type * as Insurance from '@/Components/Calculation/Form/Insurance/InsuranceTable/types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; import type { BaseOption } from 'ui/elements/types'; @@ -13,7 +13,7 @@ function hasInvalidValueOrOptions(value: unknown, options: Array x.value === value); } -export default function reactions({ store }: ReactionsContext) { +export default function reactions({ store }: ProcessContext) { const { $calculation, $tables } = store; reaction( diff --git a/apps/web/process/configurator/reactions/filters.ts b/apps/web/process/configurator/reactions/filters.ts index 2f1a3d1..0959194 100644 --- a/apps/web/process/configurator/reactions/filters.ts +++ b/apps/web/process/configurator/reactions/filters.ts @@ -2,7 +2,7 @@ import { radioGraphType, selectSeasonType } from '@/config/default-options'; import * as CRMTypes from '@/graphql/crm.types'; import { SEASON_TYPES } from '@/process/payments/lib/seasons-constants'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import { reaction } from 'mobx'; @@ -11,7 +11,7 @@ import { normalizeOptions } from 'tools'; dayjs.extend(utc); -export default function reactions({ store, apolloClient }: ReactionsContext) { +export default function reactions({ store, apolloClient }: ProcessContext) { const { $calculation } = store; reaction( diff --git a/apps/web/process/configurator/reactions/validation.ts b/apps/web/process/configurator/reactions/validation.ts index de338e7..9e24896 100644 --- a/apps/web/process/configurator/reactions/validation.ts +++ b/apps/web/process/configurator/reactions/validation.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/naming-convention */ import * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; -export default function reactions({ store, apolloClient }: ReactionsContext) { +export default function reactions({ store, apolloClient }: ProcessContext) { const { $calculation } = store; /** * На изменение поля Процет убывания платежей tbxParmentsDecreasePercent необходимо заложить проверку: diff --git a/apps/web/process/configurator/reactions/values.ts b/apps/web/process/configurator/reactions/values.ts index b4de4bc..26c217c 100644 --- a/apps/web/process/configurator/reactions/values.ts +++ b/apps/web/process/configurator/reactions/values.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ import * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import { reaction } from 'mobx'; @@ -8,7 +8,7 @@ import { makeDisposable, normalizeOptions } from 'tools'; dayjs.extend(utc); -export default function valuesReactions({ store, apolloClient }: ReactionsContext) { +export default function valuesReactions({ store, apolloClient }: ProcessContext) { const { $calculation, $process } = store; reaction( diff --git a/apps/web/process/create-kp/reactions.ts b/apps/web/process/create-kp/reactions.ts index c397f89..c3370ea 100644 --- a/apps/web/process/create-kp/reactions.ts +++ b/apps/web/process/create-kp/reactions.ts @@ -1,7 +1,7 @@ -import type { ReactionsContext } from '../types'; +import type { ProcessContext } from '../types'; import { reaction } from 'mobx'; -export function common({ store }: ReactionsContext) { +export function common({ store }: ProcessContext) { const { $calculation } = store; reaction( diff --git a/apps/web/process/fingap/reactions/common.ts b/apps/web/process/fingap/reactions/common.ts index 18d47e7..2d43f07 100644 --- a/apps/web/process/fingap/reactions/common.ts +++ b/apps/web/process/fingap/reactions/common.ts @@ -4,7 +4,7 @@ import type { RequestFinGAP } from '@/api/core/types'; import type { Risk } from '@/Components/Calculation/Form/Insurance/FinGAPTable/types'; import { STALE_TIME } from '@/constants/request'; import type * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import { gql } from '@apollo/client'; import type { QueryFunctionContext } from '@tanstack/react-query'; import dayjs from 'dayjs'; @@ -14,7 +14,7 @@ import { flatten } from 'tools/object'; dayjs.extend(utc); -export default function reactions({ store, apolloClient, queryClient }: ReactionsContext) { +export default function reactions({ store, apolloClient, queryClient }: ProcessContext) { const { $calculation, $tables } = store; // Расчет итоговой суммы ФинГАП и запись в таблицу страхования reaction( diff --git a/apps/web/process/fingap/reactions/validation.ts b/apps/web/process/fingap/reactions/validation.ts index 1937dbe..3f8df5f 100644 --- a/apps/web/process/fingap/reactions/validation.ts +++ b/apps/web/process/fingap/reactions/validation.ts @@ -1,7 +1,7 @@ -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; -export default function reactions({ store }: ReactionsContext) { +export default function reactions({ store }: ProcessContext) { const { $tables } = store; reaction( diff --git a/apps/web/process/init/inject-reactions/hooks.js b/apps/web/process/hooks.ts similarity index 73% rename from apps/web/process/init/inject-reactions/hooks.js rename to apps/web/process/hooks.ts index f9edc69..6202234 100644 --- a/apps/web/process/init/inject-reactions/hooks.js +++ b/apps/web/process/hooks.ts @@ -1,15 +1,15 @@ -import injectDefaultReactions from './default'; +import type { ProcessContext } from '@/process/types'; import { useStore } from '@/stores/hooks'; import { trpcPureClient } from '@/trpc/client'; import { useApolloClient } from '@apollo/client'; import { useQueryClient } from '@tanstack/react-query'; -export function useReactions() { +export function useProcess(reactions: (context: ProcessContext) => void) { const store = useStore(); const apolloClient = useApolloClient(); const queryClient = useQueryClient(); - injectDefaultReactions({ + reactions({ apolloClient, queryClient, store, diff --git a/apps/web/process/init/get-data/index.js b/apps/web/process/init/get-data/index.js deleted file mode 100644 index 8829509..0000000 --- a/apps/web/process/init/get-data/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export { getInitialData } from './get-initial-data'; -export { useInsuranceData } from './get-insurance-data'; -export { useMainData } from './get-main-data'; diff --git a/apps/web/process/init/get-data/get-initial-data.ts b/apps/web/process/init/get-initial-data.ts similarity index 100% rename from apps/web/process/init/get-data/get-initial-data.ts rename to apps/web/process/init/get-initial-data.ts diff --git a/apps/web/process/init/get-data/get-insurance-data.js b/apps/web/process/init/get-insurance-data.js similarity index 100% rename from apps/web/process/init/get-data/get-insurance-data.js rename to apps/web/process/init/get-insurance-data.js diff --git a/apps/web/process/init/get-data/get-main-data.js b/apps/web/process/init/get-main-data.js similarity index 100% rename from apps/web/process/init/get-data/get-main-data.js rename to apps/web/process/init/get-main-data.js diff --git a/apps/web/process/init/index.js b/apps/web/process/init/index.js new file mode 100644 index 0000000..eee9f13 --- /dev/null +++ b/apps/web/process/init/index.js @@ -0,0 +1,3 @@ +export * from './get-initial-data'; +export * from './get-insurance-data'; +export * from './get-main-data'; diff --git a/apps/web/process/init/inject-reactions/default.js b/apps/web/process/init/inject-reactions/default.js deleted file mode 100644 index 78fc437..0000000 --- a/apps/web/process/init/inject-reactions/default.js +++ /dev/null @@ -1,42 +0,0 @@ -import * as bonuses from '../../bonuses'; -import * as calculate from '../../calculate'; -import * as configurator from '../../configurator'; -import * as createKP from '../../create-kp'; -import * as fingap from '../../fingap'; -import * as leadOpportunity from '../../lead-opportunity'; -import * as leasingObject from '../../leasing-object'; -import * as leasingWithoutKasko from '../../leasing-without-kasko'; -import * as loadKP from '../../load-kp'; -import * as price from '../../price'; -import * as subsidy from '../../subsidy'; -import * as subsidyImportProgram from '../../subsidy-import-program'; -import * as agents from '../../supplier-agent'; -import * as usedPl from '../../used-pl'; - -export default function injectDefaultReactions(context) { - leadOpportunity.common(context); - leadOpportunity.urls(context); - loadKP.common(context); - calculate.validation(context); - calculate.common(context); - agents.common(context); - agents.validation(context); - price.computed(context); - price.common(context); - price.validation(context); - fingap.common(context); - fingap.validation(context); - loadKP.common(context); - leasingWithoutKasko.common(context); - subsidy.common(context); - leasingObject.common(context); - leasingObject.validation(context); - configurator.filters(context); - configurator.values(context); - configurator.validation(context); - createKP.common(context); - bonuses.common(context); - bonuses.validation(context); - usedPl.common(context); - subsidyImportProgram.common(context); -} diff --git a/apps/web/process/lead-opportunity/reactions/common.ts b/apps/web/process/lead-opportunity/reactions/common.ts index d4ff64d..5cff530 100644 --- a/apps/web/process/lead-opportunity/reactions/common.ts +++ b/apps/web/process/lead-opportunity/reactions/common.ts @@ -1,10 +1,10 @@ import * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; import { normalizeOptions } from 'tools/entity'; import { makeDisposable } from 'tools/mobx'; -export default function reactions({ store, apolloClient }: ReactionsContext) { +export default function reactions({ store, apolloClient }: ProcessContext) { const { $calculation, $process } = store; /** diff --git a/apps/web/process/lead-opportunity/reactions/urls.ts b/apps/web/process/lead-opportunity/reactions/urls.ts index fc46c57..a369178 100644 --- a/apps/web/process/lead-opportunity/reactions/urls.ts +++ b/apps/web/process/lead-opportunity/reactions/urls.ts @@ -1,11 +1,11 @@ /* eslint-disable no-negated-condition */ import type { Elements } from '@/Components/Calculation/config/map/values'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import type { DocumentNode } from '@apollo/client'; import { gql } from '@apollo/client'; import { reaction } from 'mobx'; -export default function reactions({ store, apolloClient }: ReactionsContext) { +export default function reactions({ store, apolloClient }: ProcessContext) { const { $calculation } = store; /** diff --git a/apps/web/process/leasing-object/reactions/common.ts b/apps/web/process/leasing-object/reactions/common.ts index 8100bfe..7e0ec09 100644 --- a/apps/web/process/leasing-object/reactions/common.ts +++ b/apps/web/process/leasing-object/reactions/common.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/naming-convention */ import * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; import { intersects } from 'radash'; import { normalizeOptions } from 'tools'; -export default function reactions({ store, apolloClient }: ReactionsContext) { +export default function reactions({ store, apolloClient }: ProcessContext) { const { $calculation } = store; reaction( diff --git a/apps/web/process/leasing-object/reactions/validation.ts b/apps/web/process/leasing-object/reactions/validation.ts index 9b55cf3..a981034 100644 --- a/apps/web/process/leasing-object/reactions/validation.ts +++ b/apps/web/process/leasing-object/reactions/validation.ts @@ -1,10 +1,10 @@ /* eslint-disable @typescript-eslint/naming-convention */ import * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import ValidationHelper from '@/stores/validation/helper'; import { autorun, reaction } from 'mobx'; -export default function reactions({ store, apolloClient }: ReactionsContext) { +export default function reactions({ store, apolloClient }: ProcessContext) { const { $calculation } = store; /** diff --git a/apps/web/process/leasing-without-kasko/reactions.ts b/apps/web/process/leasing-without-kasko/reactions.ts index 89f2e22..a7d6177 100644 --- a/apps/web/process/leasing-without-kasko/reactions.ts +++ b/apps/web/process/leasing-without-kasko/reactions.ts @@ -1,7 +1,7 @@ /* eslint-disable canonical/sort-keys */ /* eslint-disable @typescript-eslint/naming-convention */ import type * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import { gql } from '@apollo/client'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; @@ -42,7 +42,7 @@ const QUERY_GET_LEASING_WITHOUT_KASKO_OPTIONS = gql` } `; -export function common({ store, apolloClient }: ReactionsContext) { +export function common({ store, apolloClient }: ProcessContext) { const { $calculation, $tables } = store; reaction( diff --git a/apps/web/process/load-kp/reactions.ts b/apps/web/process/load-kp/reactions.ts index 4f5db8a..c8f7811 100644 --- a/apps/web/process/load-kp/reactions.ts +++ b/apps/web/process/load-kp/reactions.ts @@ -1,11 +1,11 @@ -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import extend from '@/stores/tables/insurance/tools'; import { reaction } from 'mobx'; import message from 'ui/elements/message'; const key = 'KP_LOADING_INFO'; -export function common({ store, trpcClient }: ReactionsContext) { +export function common({ store, trpcClient }: ProcessContext) { const { $calculation, $process, $tables } = store; reaction( diff --git a/apps/web/process/payments/reactions/common.ts b/apps/web/process/payments/reactions/common.ts index 2bcb6d5..d58a3bf 100644 --- a/apps/web/process/payments/reactions/common.ts +++ b/apps/web/process/payments/reactions/common.ts @@ -2,7 +2,7 @@ import * as seasonsConstants from '../lib/seasons-constants'; import * as seasonsTools from '../lib/seasons-tools'; import { selectHighSeasonStart } from '@/config/default-options'; import { MIN_PAYMENT } from '@/constants/values'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import type { Row } from '@/stores/tables/payments/types'; import { comparer, reaction, toJS } from 'mobx'; import { shift } from 'radash'; @@ -20,7 +20,7 @@ const { const { DEFAULT_SEASONS_VALUES, FORBIDDEN_HIGH_SEASON_START, SEASONS_PERIOD_NUMBER } = seasonsConstants; -export default function reactions({ store }: ReactionsContext) { +export default function reactions({ store }: ProcessContext) { const { $calculation, $tables, $process } = store; reaction( diff --git a/apps/web/process/payments/reactions/validation.ts b/apps/web/process/payments/reactions/validation.ts index 66fd6af..7d6eefb 100644 --- a/apps/web/process/payments/reactions/validation.ts +++ b/apps/web/process/payments/reactions/validation.ts @@ -1,10 +1,10 @@ import validatePaymentsTable from '../lib/validation'; import { MIN_LASTPAYMENT_NSIB } from '@/constants/values'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import ValidationHelper from '@/stores/validation/helper'; import { comparer, reaction, toJS } from 'mobx'; -export default function reactions({ store }: ReactionsContext) { +export default function reactions({ store }: ProcessContext) { const { $calculation, $tables } = store; const validationHelper = new ValidationHelper(); diff --git a/apps/web/process/price/reactions/common.ts b/apps/web/process/price/reactions/common.ts index d551b1c..a227432 100644 --- a/apps/web/process/price/reactions/common.ts +++ b/apps/web/process/price/reactions/common.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/naming-convention */ import { VAT } from '@/constants/values'; import * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; import { makeDisposable } from 'tools'; -export default function reactions({ store, apolloClient }: ReactionsContext) { +export default function reactions({ store, apolloClient }: ProcessContext) { const { $calculation, $process } = store; reaction( diff --git a/apps/web/process/price/reactions/computed.ts b/apps/web/process/price/reactions/computed.ts index 6747108..af76d14 100644 --- a/apps/web/process/price/reactions/computed.ts +++ b/apps/web/process/price/reactions/computed.ts @@ -1,13 +1,13 @@ /* eslint-disable @typescript-eslint/naming-convention */ import * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import { autorun } from 'mobx'; dayjs.extend(utc); -export default function reactions({ store, apolloClient }: ReactionsContext) { +export default function reactions({ store, apolloClient }: ProcessContext) { const { $calculation } = store; autorun( diff --git a/apps/web/process/price/reactions/validation.ts b/apps/web/process/price/reactions/validation.ts index b1d1313..8860c17 100644 --- a/apps/web/process/price/reactions/validation.ts +++ b/apps/web/process/price/reactions/validation.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/naming-convention */ import { VAT } from '@/constants/values'; import * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; import { round } from 'tools'; -export default function reactions({ store, apolloClient }: ReactionsContext) { +export default function reactions({ store, apolloClient }: ProcessContext) { const { $calculation } = store; reaction( diff --git a/apps/web/process/subsidy-import-program/reactions.ts b/apps/web/process/subsidy-import-program/reactions.ts index 4094c76..40af966 100644 --- a/apps/web/process/subsidy-import-program/reactions.ts +++ b/apps/web/process/subsidy-import-program/reactions.ts @@ -1,10 +1,10 @@ /* eslint-disable no-negated-condition */ /* eslint-disable @typescript-eslint/naming-convention */ -import type { ReactionsContext } from '../types'; +import type { ProcessContext } from '../types'; import * as CRMTypes from '@/graphql/crm.types'; import { reaction } from 'mobx'; -export function common({ store, apolloClient }: ReactionsContext) { +export function common({ store, apolloClient }: ProcessContext) { const { $calculation } = store; /** diff --git a/apps/web/process/subsidy/reactions.ts b/apps/web/process/subsidy/reactions.ts index 9da8808..e5209ff 100644 --- a/apps/web/process/subsidy/reactions.ts +++ b/apps/web/process/subsidy/reactions.ts @@ -1,5 +1,5 @@ import * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import { reaction } from 'mobx'; /** @@ -19,7 +19,7 @@ import { reaction } from 'mobx'; */ /* eslint-enable */ -export function common({ store, apolloClient }: ReactionsContext) { +export function common({ store, apolloClient }: ProcessContext) { const { $calculation } = store; reaction( diff --git a/apps/web/process/supplier-agent/reactions/agents.ts b/apps/web/process/supplier-agent/reactions/agents.ts index 3dd8766..000750d 100644 --- a/apps/web/process/supplier-agent/reactions/agents.ts +++ b/apps/web/process/supplier-agent/reactions/agents.ts @@ -3,7 +3,7 @@ import * as createReactions from '../lib/create-reactions'; import * as fillAgentsFromLead from '../lib/fill-agents-from-lead'; import * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import { autorun, reaction } from 'mobx'; @@ -29,7 +29,7 @@ class Helper { }; } -export function common({ store, apolloClient }: ReactionsContext) { +export function common({ store, apolloClient }: ProcessContext) { const { $calculation, $process } = store; /** @@ -522,7 +522,7 @@ export function common({ store, apolloClient }: ReactionsContext) { } } -export function validation({ store, apolloClient }: ReactionsContext) { +export function validation({ store, apolloClient }: ProcessContext) { const { $calculation } = store; validateAgentRewardSumm(store, apolloClient, { diff --git a/apps/web/process/supplier-agent/reactions/index.ts b/apps/web/process/supplier-agent/reactions/index.ts index d64d699..52e9725 100644 --- a/apps/web/process/supplier-agent/reactions/index.ts +++ b/apps/web/process/supplier-agent/reactions/index.ts @@ -1,15 +1,15 @@ import * as agents from './agents'; import * as leaseback from './leaseback'; import * as supplier from './supplier'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; -function common(context: ReactionsContext) { +function common(context: ProcessContext) { agents.common(context); leaseback.common(context); supplier.common(context); } -function validation(context: ReactionsContext) { +function validation(context: ProcessContext) { agents.validation(context); supplier.validation(context); } diff --git a/apps/web/process/supplier-agent/reactions/leaseback.ts b/apps/web/process/supplier-agent/reactions/leaseback.ts index c5c1f91..ce8ff98 100644 --- a/apps/web/process/supplier-agent/reactions/leaseback.ts +++ b/apps/web/process/supplier-agent/reactions/leaseback.ts @@ -1,8 +1,8 @@ import * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import { autorun, reaction } from 'mobx'; -export function common({ store, apolloClient }: ReactionsContext) { +export function common({ store, apolloClient }: ProcessContext) { const { $calculation, $tables } = store; /** * Дополнить реакцию на изменение поля Салон приобретения selectDealer: diff --git a/apps/web/process/supplier-agent/reactions/supplier.ts b/apps/web/process/supplier-agent/reactions/supplier.ts index 86ff612..bbb50f7 100644 --- a/apps/web/process/supplier-agent/reactions/supplier.ts +++ b/apps/web/process/supplier-agent/reactions/supplier.ts @@ -1,6 +1,6 @@ import * as createReactions from '../lib/create-reactions'; import * as CRMTypes from '@/graphql/crm.types'; -import type { ReactionsContext } from '@/process/types'; +import type { ProcessContext } from '@/process/types'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import { reaction } from 'mobx'; @@ -9,7 +9,7 @@ import { normalizeOptions } from 'tools/entity'; dayjs.extend(utc); -export function common({ store, apolloClient }: ReactionsContext) { +export function common({ store, apolloClient }: ProcessContext) { const { $calculation, $process } = store; /** @@ -158,7 +158,7 @@ export function common({ store, apolloClient }: ReactionsContext) { ); } -export function validation({ store, apolloClient }: ReactionsContext) { +export function validation({ store, apolloClient }: ProcessContext) { createReactions.validateAgentRewardSumm(store, apolloClient, { rewardConditionField: 'selectDealerRewardCondition', rewardSummField: 'tbxDealerRewardSumm', diff --git a/apps/web/process/types.ts b/apps/web/process/types.ts index bc301bf..11f66d8 100644 --- a/apps/web/process/types.ts +++ b/apps/web/process/types.ts @@ -3,7 +3,7 @@ import type { TRPCPureClient } from '@/trpc/types'; import type { ApolloClient } from '@apollo/client'; import type { QueryClient } from '@tanstack/react-query'; -export type ReactionsContext = { +export type ProcessContext = { apolloClient: ApolloClient; queryClient: QueryClient; store: RootStore; diff --git a/apps/web/process/used-pl/reactions.ts b/apps/web/process/used-pl/reactions.ts index 132b907..50c88da 100644 --- a/apps/web/process/used-pl/reactions.ts +++ b/apps/web/process/used-pl/reactions.ts @@ -1,10 +1,10 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import type { ReactionsContext } from '../types'; +import type { ProcessContext } from '../types'; import * as CRMTypes from '@/graphql/crm.types'; import ValidationHelper from '@/stores/validation/helper'; import { reaction } from 'mobx'; -export function common({ store, apolloClient }: ReactionsContext) { +export function common({ store, apolloClient }: ProcessContext) { const { $calculation } = store; /** diff --git a/apps/web/trpc/routers/quote.ts b/apps/web/trpc/routers/quote.ts index 359e6ea..46f5ff1 100644 --- a/apps/web/trpc/routers/quote.ts +++ b/apps/web/trpc/routers/quote.ts @@ -6,7 +6,7 @@ import * as bonuses from '@/process/bonuses'; import * as configurator from '@/process/configurator'; import * as fingapProcess from '@/process/fingap'; import * as leasingObject from '@/process/leasing-object'; -import { GetQuoteDataInputSchema, GetQuoteDataOutputSchema } from '@/process/load-kp'; +import * as loadKP from '@/process/load-kp'; import * as paymentsProcess from '@/process/payments'; import * as price from '@/process/price'; import * as supplierAgent from '@/process/supplier-agent'; @@ -15,6 +15,8 @@ import { shake } from 'radash'; const DEFAULT_OSAGO_ROW = defaultInsuranceValues.find((x) => x.key === 'osago'); const DEFAULT_KASKO_ROW = defaultInsuranceValues.find((x) => x.key === 'kasko'); +const { GetQuoteDataInputSchema, GetQuoteDataOutputSchema } = loadKP; + const quoteRouter = t.router({ getData: t.procedure .input(GetQuoteDataInputSchema)