diff --git a/.graphqlrc.yml b/.graphqlrc.yml
index c31d185..09678b1 100644
--- a/.graphqlrc.yml
+++ b/.graphqlrc.yml
@@ -1,3 +1,3 @@
schema:
- - ./src/core/graphql/schemas/crm.graphql
+ - ./src/core/services/CrmService/graphql/schema.graphql
documents: src/**/*.{graphql,js,ts,jsx,tsx}
diff --git a/apollo.config.js b/apollo.config.js
index dea1bb4..50c23c2 100644
--- a/apollo.config.js
+++ b/apollo.config.js
@@ -3,8 +3,8 @@ module.exports = {
service: {
name: 'crmgraphql',
url: 'http://localhost/crmgraphql/',
- // localSchemaFile: 'src/core/graphql/schemas/crm.graphql',
+ // localSchemaFile: 'src/core/services/CrmService/graphql/schema.graphql',
},
- excludes: ['src/core/graphql/schemas/**/*.*'],
+ excludes: ['src/core/services/CrmService/graphql/schema.graphql'],
},
};
diff --git a/package.json b/package.json
index 2badc9c..6055d41 100644
--- a/package.json
+++ b/package.json
@@ -26,8 +26,7 @@
"rebass": "^4.0.7",
"styled-components": "^5.2.3",
"typescript": "^4.5.4",
- "use-debounce": "^6.0.1",
- "validator": "^13.5.2"
+ "use-debounce": "^6.0.1"
},
"devDependencies": {
"@storybook/addon-actions": "^6.2.9",
@@ -61,7 +60,7 @@
},
"scripts": {
"graphql:codegen": "apollo client:codegen --target typescript",
- "graphql:update-schema": "apollo client:download-schema src/core/graphql/schemas/crm.graphql",
+ "graphql:update-schema": "apollo client:download-schema src/core/services/CrmService/graphql/schema.graphql",
"test": "react-scripts test",
"eject": "react-scripts eject",
"start": "dotenv -e .env craco start",
diff --git a/src/client/Components/Calculation/ELT/index.jsx b/src/client/Components/Calculation/ELT/index.jsx
deleted file mode 100644
index dd03955..0000000
--- a/src/client/Components/Calculation/ELT/index.jsx
+++ /dev/null
@@ -1,7 +0,0 @@
-import { lazy } from 'react';
-
-const Content = lazy(() => import('./Content'));
-
-const ELT = () => ;
-
-export default ELT;
diff --git a/src/client/Components/Calculation/ELT/Content/Components/Controls/BottomControls.jsx b/src/client/Containers/Calculation/Components/ELT/Components/Controls/BottomControls.jsx
similarity index 96%
rename from src/client/Components/Calculation/ELT/Content/Components/Controls/BottomControls.jsx
rename to src/client/Containers/Calculation/Components/ELT/Components/Controls/BottomControls.jsx
index 7525746..0a5efe3 100644
--- a/src/client/Components/Calculation/ELT/Content/Components/Controls/BottomControls.jsx
+++ b/src/client/Containers/Calculation/Components/ELT/Components/Controls/BottomControls.jsx
@@ -3,7 +3,7 @@ import Button from 'client/Elements/Button';
import { openNotification } from 'client/Elements/Notification';
import { useStores } from 'client/hooks/useStores';
import { Process } from 'core/types/Calculation/Store/process';
-import { ElementStatus } from 'core/types/statuses';
+import { ElementStatus } from 'types/elements';
const BottomControls = ({ insType, onSelectRow, selectedKey }) => {
const { calculationStore } = useStores();
diff --git a/src/client/Components/Calculation/ELT/Content/Components/Controls/TopControls.jsx b/src/client/Containers/Calculation/Components/ELT/Components/Controls/TopControls.jsx
similarity index 95%
rename from src/client/Components/Calculation/ELT/Content/Components/Controls/TopControls.jsx
rename to src/client/Containers/Calculation/Components/ELT/Components/Controls/TopControls.jsx
index 710394b..c54dc55 100644
--- a/src/client/Components/Calculation/ELT/Content/Components/Controls/TopControls.jsx
+++ b/src/client/Containers/Calculation/Components/ELT/Components/Controls/TopControls.jsx
@@ -3,8 +3,8 @@ import Button from 'client/Elements/Button';
import { PrimaryText } from 'client/Elements/Text';
import { useStores } from 'client/hooks/useStores';
import { Flex } from 'client/UIKit/grid';
-import { ElementStatus } from 'core/types/statuses';
import { useState } from 'react';
+import { ElementStatus } from 'types/elements';
import { resetIns } from '../../lib/resetIns';
import validate from '../../lib/validation';
diff --git a/src/client/Components/Calculation/ELT/Content/Components/Controls/index.js b/src/client/Containers/Calculation/Components/ELT/Components/Controls/index.js
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/Components/Controls/index.js
rename to src/client/Containers/Calculation/Components/ELT/Components/Controls/index.js
diff --git a/src/client/Components/Calculation/ELT/Content/Components/InsTable.tsx b/src/client/Containers/Calculation/Components/ELT/Components/InsTable.tsx
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/Components/InsTable.tsx
rename to src/client/Containers/Calculation/Components/ELT/Components/InsTable.tsx
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/Kasko.stories.jsx b/src/client/Containers/Calculation/Components/ELT/Kasko/Kasko.stories.jsx
similarity index 95%
rename from src/client/Components/Calculation/ELT/Content/Kasko/Kasko.stories.jsx
rename to src/client/Containers/Calculation/Components/ELT/Kasko/Kasko.stories.jsx
index c4ebe16..35d2d0c 100644
--- a/src/client/Components/Calculation/ELT/Content/Kasko/Kasko.stories.jsx
+++ b/src/client/Containers/Calculation/Components/ELT/Kasko/Kasko.stories.jsx
@@ -1,5 +1,5 @@
-import InsTable from '../InsTable';
import tableConfig from '../lib/config/table';
+import InsTable from './index';
export default {
title: 'Components/Calculation/ELT/Kasko',
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/index.jsx b/src/client/Containers/Calculation/Components/ELT/Kasko/index.jsx
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/Kasko/index.jsx
rename to src/client/Containers/Calculation/Components/ELT/Kasko/index.jsx
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.test.js b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/composeRequest.test.js
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.test.js
rename to src/client/Containers/Calculation/Components/ELT/Kasko/lib/composeRequest.test.js
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.ts b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/composeRequest.ts
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.ts
rename to src/client/Containers/Calculation/Components/ELT/Kasko/lib/composeRequest.ts
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/config/columns.ts b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/config/columns.ts
similarity index 88%
rename from src/client/Components/Calculation/ELT/Content/Kasko/lib/config/columns.ts
rename to src/client/Containers/Calculation/Components/ELT/Kasko/lib/config/columns.ts
index 0450501..b9cb705 100644
--- a/src/client/Components/Calculation/ELT/Content/Kasko/lib/config/columns.ts
+++ b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/config/columns.ts
@@ -1,6 +1,6 @@
-import { InsTableColumn } from 'client/Components/Calculation/ELT/Content/lib/config/table';
import { Outlined } from 'client/Components/Spinner';
import { formatMoney } from 'core/tools/format';
+import { InsTableColumn } from '../../../lib/config/table';
const columns: InsTableColumn[] = [
{
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/config/index.ts b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/config/index.ts
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/Kasko/lib/config/index.ts
rename to src/client/Containers/Calculation/Components/ELT/Kasko/lib/config/index.ts
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/convertEltResult.js b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/convertEltResult.js
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/Kasko/lib/convertEltResult.js
rename to src/client/Containers/Calculation/Components/ELT/Kasko/lib/convertEltResult.js
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/convertEltResult.test.js b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/convertEltResult.test.js
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/Kasko/lib/convertEltResult.test.js
rename to src/client/Containers/Calculation/Components/ELT/Kasko/lib/convertEltResult.test.js
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/onSelectRow.ts b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/onSelectRow.ts
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/Kasko/lib/onSelectRow.ts
rename to src/client/Containers/Calculation/Components/ELT/Kasko/lib/onSelectRow.ts
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/validation.ts
similarity index 96%
rename from src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts
rename to src/client/Containers/Calculation/Components/ELT/Kasko/lib/validation.ts
index caeb7b1..4817af2 100644
--- a/src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts
+++ b/src/client/Containers/Calculation/Components/ELT/Kasko/lib/validation.ts
@@ -1,7 +1,4 @@
-import {
- ElementsNames,
- TElements,
-} from 'core/types/Calculation/Store/elements';
+import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { ValidationCondition } from 'core/validation/validate';
export const requiredFields: ElementsNames[] = [
@@ -19,7 +16,7 @@ export const requiredFields: ElementsNames[] = [
'radioInfuranceOPF',
];
-export const conditions: TElements = {
+export const conditions: Partial> = {
selectLeaseObjectType: calculationStore => {
const leaseObjectType = calculationStore.getOption('selectLeaseObjectType');
if (leaseObjectType?.evo_id && ['11'].includes(leaseObjectType?.evo_id)) {
diff --git a/src/client/Components/Calculation/ELT/Content/Osago/index.jsx b/src/client/Containers/Calculation/Components/ELT/Osago/index.jsx
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/Osago/index.jsx
rename to src/client/Containers/Calculation/Components/ELT/Osago/index.jsx
diff --git a/src/client/Components/Calculation/ELT/Content/Osago/lib/composeRequest.ts b/src/client/Containers/Calculation/Components/ELT/Osago/lib/composeRequest.ts
similarity index 98%
rename from src/client/Components/Calculation/ELT/Content/Osago/lib/composeRequest.ts
rename to src/client/Containers/Calculation/Components/ELT/Osago/lib/composeRequest.ts
index 597e2b2..852c5fa 100644
--- a/src/client/Components/Calculation/ELT/Content/Osago/lib/composeRequest.ts
+++ b/src/client/Containers/Calculation/Components/ELT/Osago/lib/composeRequest.ts
@@ -1,6 +1,6 @@
+import { IAccount } from 'core/services/CrmService/types/entities';
import { currentDate } from 'core/tools/date';
import { ICalculationStore } from 'core/types/Calculation/Store';
-import { IAccount } from 'core/types/Entities/crmEntities';
import { get, isNull } from 'lodash';
const mapCategory = {
diff --git a/src/client/Components/Calculation/ELT/Content/Osago/lib/config/columns.ts b/src/client/Containers/Calculation/Components/ELT/Osago/lib/config/columns.ts
similarity index 86%
rename from src/client/Components/Calculation/ELT/Content/Osago/lib/config/columns.ts
rename to src/client/Containers/Calculation/Components/ELT/Osago/lib/config/columns.ts
index d5a4db0..d03d694 100644
--- a/src/client/Components/Calculation/ELT/Content/Osago/lib/config/columns.ts
+++ b/src/client/Containers/Calculation/Components/ELT/Osago/lib/config/columns.ts
@@ -1,6 +1,6 @@
-import { InsTableColumn } from 'client/Components/Calculation/ELT/Content/lib/config/table';
import { Outlined } from 'client/Components/Spinner';
import { formatMoney } from 'core/tools/format';
+import { InsTableColumn } from '../../../lib/config/table';
const columns: InsTableColumn[] = [
{
diff --git a/src/client/Components/Calculation/ELT/Content/Osago/lib/config/index.ts b/src/client/Containers/Calculation/Components/ELT/Osago/lib/config/index.ts
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/Osago/lib/config/index.ts
rename to src/client/Containers/Calculation/Components/ELT/Osago/lib/config/index.ts
diff --git a/src/client/Components/Calculation/ELT/Content/Osago/lib/convertEltResult.js b/src/client/Containers/Calculation/Components/ELT/Osago/lib/convertEltResult.js
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/Osago/lib/convertEltResult.js
rename to src/client/Containers/Calculation/Components/ELT/Osago/lib/convertEltResult.js
diff --git a/src/client/Components/Calculation/ELT/Content/Osago/lib/onSelectRow.ts b/src/client/Containers/Calculation/Components/ELT/Osago/lib/onSelectRow.ts
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/Osago/lib/onSelectRow.ts
rename to src/client/Containers/Calculation/Components/ELT/Osago/lib/onSelectRow.ts
diff --git a/src/client/Components/Calculation/ELT/Content/Osago/lib/validation.ts b/src/client/Containers/Calculation/Components/ELT/Osago/lib/validation.ts
similarity index 89%
rename from src/client/Components/Calculation/ELT/Content/Osago/lib/validation.ts
rename to src/client/Containers/Calculation/Components/ELT/Osago/lib/validation.ts
index de1f572..a86565d 100644
--- a/src/client/Components/Calculation/ELT/Content/Osago/lib/validation.ts
+++ b/src/client/Containers/Calculation/Components/ELT/Osago/lib/validation.ts
@@ -1,7 +1,4 @@
-import {
- ElementsNames,
- TElements,
-} from 'core/types/Calculation/Store/elements';
+import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { ValidationCondition } from 'core/validation/validate';
import { omit } from 'lodash';
import { conditions as kaskoConditions } from '../../Kasko/lib/validation';
@@ -22,7 +19,7 @@ export const requiredFields: ElementsNames[] = [
'radioInfuranceOPF',
];
-const osagoConditions: TElements = {
+const osagoConditions: Partial> = {
selectTownRegistration: calculationStore => {
const objectRegistration = calculationStore.getValue('objectRegistration');
if (objectRegistration === 100000001) {
diff --git a/src/client/Components/Calculation/ELT/Content/build.jsx b/src/client/Containers/Calculation/Components/ELT/build.jsx
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/build.jsx
rename to src/client/Containers/Calculation/Components/ELT/build.jsx
diff --git a/src/client/Components/Calculation/ELT/Content/index.jsx b/src/client/Containers/Calculation/Components/ELT/index.jsx
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/index.jsx
rename to src/client/Containers/Calculation/Components/ELT/index.jsx
diff --git a/src/client/Components/Calculation/ELT/Content/lib/config/table.ts b/src/client/Containers/Calculation/Components/ELT/lib/config/table.ts
similarity index 100%
rename from src/client/Components/Calculation/ELT/Content/lib/config/table.ts
rename to src/client/Containers/Calculation/Components/ELT/lib/config/table.ts
diff --git a/src/client/Components/Calculation/ELT/Content/lib/requests.ts b/src/client/Containers/Calculation/Components/ELT/lib/requests.ts
similarity index 96%
rename from src/client/Components/Calculation/ELT/Content/lib/requests.ts
rename to src/client/Containers/Calculation/Components/ELT/lib/requests.ts
index 1ad6c04..9a8a4cd 100644
--- a/src/client/Components/Calculation/ELT/Content/lib/requests.ts
+++ b/src/client/Containers/Calculation/Components/ELT/lib/requests.ts
@@ -1,7 +1,7 @@
import axios from 'axios';
+import { IAccount } from 'core/services/CrmService/types/entities';
import ELTService from 'core/services/ELTService';
import { ICalculationStore } from 'core/types/Calculation/Store';
-import { IAccount } from 'core/types/Entities/crmEntities';
import { toJS } from 'mobx';
import { map_evo_id_elt_FieldName } from '../lib/resetIns';
diff --git a/src/client/Components/Calculation/ELT/Content/lib/resetIns.ts b/src/client/Containers/Calculation/Components/ELT/lib/resetIns.ts
similarity index 92%
rename from src/client/Components/Calculation/ELT/Content/lib/resetIns.ts
rename to src/client/Containers/Calculation/Components/ELT/lib/resetIns.ts
index 7602e1a..cc27111 100644
--- a/src/client/Components/Calculation/ELT/Content/lib/resetIns.ts
+++ b/src/client/Containers/Calculation/Components/ELT/lib/resetIns.ts
@@ -1,5 +1,5 @@
+import { CRMEntity } from 'core/services/CrmService/types/entities';
import { ICalculationStore } from 'core/types/Calculation/Store';
-import { TCRMEntity } from 'core/types/Entities/crmEntities';
import { pick } from 'lodash';
import { sources } from './requests';
@@ -40,7 +40,7 @@ export function initIns(this: ICalculationStore, insType) {
return;
}
const { ELTStore } = this.stores;
- const list: TCRMEntity[] = [];
+ const list: CRMEntity[] = [];
const evo_id_elt_fieldName = map_evo_id_elt_FieldName[insType](this);
insuranceCompanies.forEach(company => {
if (
@@ -60,7 +60,7 @@ export function resetIns(this: ICalculationStore, insType) {
const { ELTStore } = this.stores;
- const list: TCRMEntity[] = [];
+ const list: CRMEntity[] = [];
ELTStore[insType].list.forEach(x => {
const picked = pick(x, initFields, '');
list.push(picked);
diff --git a/src/client/Components/Calculation/ELT/Content/lib/validation.ts b/src/client/Containers/Calculation/Components/ELT/lib/validation.ts
similarity index 84%
rename from src/client/Components/Calculation/ELT/Content/lib/validation.ts
rename to src/client/Containers/Calculation/Components/ELT/lib/validation.ts
index 5a68ffe..1db38d2 100644
--- a/src/client/Components/Calculation/ELT/Content/lib/validation.ts
+++ b/src/client/Containers/Calculation/Components/ELT/lib/validation.ts
@@ -1,30 +1,27 @@
-import { getTitle } from 'client/Containers/Calculation/lib/elements/tools';
+import { getTitle } from 'client/Containers/Calculation/Elements/tools';
+import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { openNotification } from 'client/Elements/Notification';
import { pipe } from 'core/tools/func';
import { ICalculationStore } from 'core/types/Calculation/Store';
-import {
- ElementsNames,
- TElements,
-} from 'core/types/Calculation/Store/elements';
import CONDITIONS from 'core/validation/conditions';
import {
convertToValidationResult,
getValue,
showValidationMessages,
validate,
- ValidationCondition,
+ ValidationCondition
} from 'core/validation/validate';
type ELTValidation = {
requiredFields: ElementsNames[];
- conditions?: TElements;
+ conditions?: Partial>;
};
export default function (this: ICalculationStore, validation: ELTValidation) {
const { requiredFields, conditions: customConditions } = validation;
const requiredFieldsConditions = requiredFields.reduce(
- (ac: TElements, elementName) => {
+ (ac: Partial>, elementName) => {
ac[elementName] = pipe(
getValue,
CONDITIONS.IS_NULL,
diff --git a/src/client/Containers/Calculation/Info/index.jsx b/src/client/Containers/Calculation/Components/Info/index.jsx
similarity index 100%
rename from src/client/Containers/Calculation/Info/index.jsx
rename to src/client/Containers/Calculation/Components/Info/index.jsx
diff --git a/src/client/Containers/Calculation/Info/infoList.ts b/src/client/Containers/Calculation/Components/Info/infoList.ts
similarity index 91%
rename from src/client/Containers/Calculation/Info/infoList.ts
rename to src/client/Containers/Calculation/Components/Info/infoList.ts
index 1ec5bbe..ac5e61b 100644
--- a/src/client/Containers/Calculation/Info/infoList.ts
+++ b/src/client/Containers/Calculation/Components/Info/infoList.ts
@@ -1,4 +1,4 @@
-import { IGroup } from 'core/types/Calculation/components';
+import { IGroup } from '../../types/common';
export const controlsList: IGroup[] = [
{
diff --git a/src/client/Components/Calculation/InsuranceTag.jsx b/src/client/Containers/Calculation/Components/InsuranceTag.jsx
similarity index 100%
rename from src/client/Components/Calculation/InsuranceTag.jsx
rename to src/client/Containers/Calculation/Components/InsuranceTag.jsx
diff --git a/src/client/Containers/Calculation/Results/index.jsx b/src/client/Containers/Calculation/Components/Results/index.jsx
similarity index 100%
rename from src/client/Containers/Calculation/Results/index.jsx
rename to src/client/Containers/Calculation/Components/Results/index.jsx
diff --git a/src/client/Containers/Calculation/Results/resultsList.ts b/src/client/Containers/Calculation/Components/Results/resultsList.ts
similarity index 95%
rename from src/client/Containers/Calculation/Results/resultsList.ts
rename to src/client/Containers/Calculation/Components/Results/resultsList.ts
index 1f6a019..5dc8fa1 100644
--- a/src/client/Containers/Calculation/Results/resultsList.ts
+++ b/src/client/Containers/Calculation/Components/Results/resultsList.ts
@@ -1,4 +1,4 @@
-import { ISection } from 'core/types/Calculation/components';
+import { ISection } from '../../types/common';
export const calculationResults: ISection[] = [
{
diff --git a/src/client/Containers/Calculation/Sections/index.jsx b/src/client/Containers/Calculation/Components/Sections/index.jsx
similarity index 79%
rename from src/client/Containers/Calculation/Sections/index.jsx
rename to src/client/Containers/Calculation/Components/Sections/index.jsx
index 76d3d43..747aeed 100644
--- a/src/client/Containers/Calculation/Sections/index.jsx
+++ b/src/client/Containers/Calculation/Components/Sections/index.jsx
@@ -1,5 +1,5 @@
import Background from 'client/Elements/Background';
-import { renderSections } from '../lib/renderSections';
+import { renderSections } from '../../lib/renderSections';
import sectionsList from './sectionsList';
const Sections = props => (
diff --git a/src/client/Containers/Calculation/Sections/sectionsList.ts b/src/client/Containers/Calculation/Components/Sections/sectionsList.ts
similarity index 84%
rename from src/client/Containers/Calculation/Sections/sectionsList.ts
rename to src/client/Containers/Calculation/Components/Sections/sectionsList.ts
index b64cfcc..402f4ab 100644
--- a/src/client/Containers/Calculation/Sections/sectionsList.ts
+++ b/src/client/Containers/Calculation/Components/Sections/sectionsList.ts
@@ -1,60 +1,6 @@
-import { ISection } from 'core/types/Calculation/components';
+import { ISection } from '../../types/common';
const sections: ISection[] = [
- // {
- // title: 'Интерес/ЛС',
- // groups: [
- // {
- // title: 'Создание нового интереса в CRM',
- // style: { columnsNumber: 3 },
- // blocks: [
- // {
- // elements: [
- // 'selectChannel',
- // 'tbxNewClient',
- // 'selectAccount',
- // 'tbxINN',
- // 'tbxKPP',
- // ],
- // },
- // {
- // elements: [
- // 'selectContactClient',
- // 'tbxContact',
- // 'radioContactGender',
- // 'tbxPhoneNumber',
- // 'tbxEmailAddress',
- // ],
- // },
- // {
- // elements: [
- // 'selectSupplier',
- // 'selectFinDepartment',
- // 'selectBroker',
- // 'selectAgent',
- // 'selectDoubleAgent',
- // ],
- // },
- // ],
- // },
- // {
- // style: { columnsNumber: 1 },
- // blocks: [
- // {
- // elements: ['tbxCommentLead'],
- // },
- // ],
- // },
- // {
- // style: { columnsNumber: 1 },
- // blocks: [
- // {
- // elements: ['btnCreateLead'],
- // },
- // ],
- // },
- // ],
- // },
{
title: 'Лизинг',
groups: [
@@ -305,7 +251,6 @@ const sections: ISection[] = [
'selectGPSModel',
'tbxInsKaskoPriceLeasePeriod',
'cbxWithTrailer',
- // 'btnDriversApplication',
],
},
{
@@ -402,11 +347,6 @@ const sections: ISection[] = [
blocks: [
{
style: { columnsNumber: 2 },
- elementStyle: {
- head: {
- whiteSpace: 'normal',
- },
- },
elements: [
// 'cbxLastPaymentRedemption',
'cbxPriceWithDiscount',
@@ -445,15 +385,6 @@ const sections: ISection[] = [
// {
// title: 'Без ограничений',
// groups: [
- // // {
- // // blocks: [
- // // {
- // // elements: [
- // // 'selectUserSession'
- // // ],
- // // },
- // // ],
- // // },
// {
// blocks: [
// {
diff --git a/src/client/hocs/Calculation/withButton.jsx b/src/client/Containers/Calculation/Elements/builders/buildAction.jsx
similarity index 67%
rename from src/client/hocs/Calculation/withButton.jsx
rename to src/client/Containers/Calculation/Elements/builders/buildAction.jsx
index e232294..4c5bb76 100644
--- a/src/client/hocs/Calculation/withButton.jsx
+++ b/src/client/Containers/Calculation/Elements/builders/buildAction.jsx
@@ -1,11 +1,11 @@
-import { observer } from 'mobx-react-lite';
-import { useStatus } from 'client/hooks/Calculation/useStatus';
import { useAction } from 'client/hooks/Calculation/useAction';
+import { useStatus } from 'client/hooks/Calculation/useStatus';
+import { observer } from 'mobx-react-lite';
-export default Button => ({ name, actionName, ...props }) =>
+export default ({ name, valueName: actionName, Component, ...props }) =>
observer(() => {
const { status } = useStatus(name);
const { action } = useAction({ actionName });
- return ;
+ return ;
});
diff --git a/src/client/hocs/Calculation/withComputedValue.jsx b/src/client/Containers/Calculation/Elements/builders/buildComputed.jsx
similarity index 80%
rename from src/client/hocs/Calculation/withComputedValue.jsx
rename to src/client/Containers/Calculation/Elements/builders/buildComputed.jsx
index a618008..1a22159 100644
--- a/src/client/hocs/Calculation/withComputedValue.jsx
+++ b/src/client/Containers/Calculation/Elements/builders/buildComputed.jsx
@@ -1,13 +1,8 @@
-import { observer } from 'mobx-react-lite';
-import { useComputedValue } from 'client/hooks/Calculation/useValue';
import { useStatus } from 'client/hooks/Calculation/useStatus';
+import { useComputedValue } from 'client/hooks/Calculation/useValue';
+import { observer } from 'mobx-react-lite';
-export default Component => ({
- name,
- computedValueName,
- validation,
- ...props
-}) =>
+export default ({ name, valueName: computedValueName, Component, ...props }) =>
observer(() => {
const { value } = useComputedValue({
computedValueName,
diff --git a/src/client/hocs/Calculation/withLink.jsx b/src/client/Containers/Calculation/Elements/builders/buildLink.jsx
similarity index 67%
rename from src/client/hocs/Calculation/withLink.jsx
rename to src/client/Containers/Calculation/Elements/builders/buildLink.jsx
index 67cd187..9782b5b 100644
--- a/src/client/hocs/Calculation/withLink.jsx
+++ b/src/client/Containers/Calculation/Elements/builders/buildLink.jsx
@@ -2,10 +2,10 @@ import { useStatus } from 'client/hooks/Calculation/useStatus';
import { useUrl } from 'client/hooks/Calculation/useUrl';
import { observer } from 'mobx-react-lite';
-export default Button => ({ name, urlName, ...props }) =>
+export default ({ name, valueName: urlName, Component, ...props }) =>
observer(() => {
const { status } = useStatus(name);
const { url } = useUrl({ urlName });
- return ;
+ return ;
});
diff --git a/src/client/Containers/Calculation/Elements/builders/buildTable.jsx b/src/client/Containers/Calculation/Elements/builders/buildTable.jsx
new file mode 100644
index 0000000..b93619a
--- /dev/null
+++ b/src/client/Containers/Calculation/Elements/builders/buildTable.jsx
@@ -0,0 +1,59 @@
+import { useTableOptions } from 'client/hooks/Calculation/useOptions';
+import { useTableStatus } from 'client/hooks/Calculation/useStatus';
+import { useTableValidation } from 'client/hooks/Calculation/useValidation';
+import { useTableValue } from 'client/hooks/Calculation/useValue';
+import { useStores } from 'client/hooks/useStores';
+import { observer } from 'mobx-react-lite';
+
+export default ({ Component: Table, ...props }) => {
+ const { name: tableName, callbacks } = props;
+ const ObservedTable = observer(Table);
+ const { calculationStore } = useStores();
+ const tableData = calculationStore.tables[tableName];
+ return () => (
+
+ );
+};
+
+const withTableValue =
+ callbacks =>
+ Component =>
+ ({ tableName, rowIndex, propName, validation, ...props }) =>
+ observer(() => {
+ const { value, setCurrentValue } = useTableValue({
+ tableName,
+ rowIndex,
+ propName,
+ columnCallback: callbacks?.[propName],
+ });
+ const { status } = useTableStatus({ tableName, rowIndex, propName });
+ const { validateStatus, message } = useTableValidation({
+ tableName,
+ rowIndex,
+ propName,
+ validation,
+ });
+
+ const { options, filter } = useTableOptions({
+ tableName,
+ rowIndex,
+ propName,
+ });
+
+ return (
+
+ );
+ });
diff --git a/src/client/hocs/Calculation/withValue.jsx b/src/client/Containers/Calculation/Elements/builders/buildValue.jsx
similarity index 90%
rename from src/client/hocs/Calculation/withValue.jsx
rename to src/client/Containers/Calculation/Elements/builders/buildValue.jsx
index 62d9031..8cce1a7 100644
--- a/src/client/hocs/Calculation/withValue.jsx
+++ b/src/client/Containers/Calculation/Elements/builders/buildValue.jsx
@@ -1,10 +1,10 @@
-import { observer } from 'mobx-react-lite';
-import { useStoreValue } from 'client/hooks/Calculation/useValue';
+import { useOptions } from 'client/hooks/Calculation/useOptions';
import { useStatus } from 'client/hooks/Calculation/useStatus';
import { useValidation } from 'client/hooks/Calculation/useValidation';
-import { useOptions } from 'client/hooks/Calculation/useOptions';
+import { useStoreValue } from 'client/hooks/Calculation/useValue';
+import { observer } from 'mobx-react-lite';
-export default Component => ({ name, valueName, validation, ...props }) =>
+export default ({ name, valueName, Component, ...props }) =>
observer(() => {
const { value, setCurrentValue } = useStoreValue({
valueName,
@@ -13,7 +13,6 @@ export default Component => ({ name, valueName, validation, ...props }) =>
const { validateStatus, message } = useValidation({
elementName: name,
value,
- validation,
});
const { options } = useOptions(name);
diff --git a/src/client/Containers/Calculation/Elements/builders/index.ts b/src/client/Containers/Calculation/Elements/builders/index.ts
new file mode 100644
index 0000000..2a200ed
--- /dev/null
+++ b/src/client/Containers/Calculation/Elements/builders/index.ts
@@ -0,0 +1,40 @@
+import ELT from '../../Components/ELT';
+import { CustomComponents, NonValueElementsNames } from '../../types/elements';
+import { TableNames } from '../../types/tables';
+import components from '../components';
+import tables from '../tables';
+import buildAction from './buildAction';
+import buildComputed from './buildComputed';
+import buildLink from './buildLink';
+import buildTable from './buildTable';
+import buildValue from './buildValue';
+
+const valueElementsBuilders = Object.keys(components).reduce(
+ (acc, elementName) => {
+ acc[elementName] = buildValue;
+ return acc;
+ },
+ {},
+);
+
+const overrideBuilders: Record<
+ NonValueElementsNames | TableNames | CustomComponents,
+ any
+> = {
+ labelLeaseObjectRisk: buildComputed,
+ tbxInsKaskoPriceLeasePeriod: buildComputed,
+ labelIrrInfo: buildComputed,
+ labelRegistrationDescription: buildComputed,
+ btnCreateKP: buildAction,
+ btnCalculate: buildAction,
+ linkDownloadKp: buildLink,
+ componentElt: () => ELT,
+ tablePayments: ({ name, Component }) =>
+ buildTable({ name, Component, ...tables[name] }),
+ tableInsurance: ({ name, Component }) =>
+ buildTable({ name, Component, ...tables[name] }),
+ tableResults: ({ name, Component }) =>
+ buildTable({ name, Component, ...tables[name] }),
+};
+
+export default Object.assign(valueElementsBuilders, overrideBuilders);
diff --git a/src/client/Containers/Calculation/lib/elements/components.ts b/src/client/Containers/Calculation/Elements/components.ts
similarity index 82%
rename from src/client/Containers/Calculation/lib/elements/components.ts
rename to src/client/Containers/Calculation/Elements/components.ts
index 8802673..d5fb139 100644
--- a/src/client/Containers/Calculation/lib/elements/components.ts
+++ b/src/client/Containers/Calculation/Elements/components.ts
@@ -1,4 +1,3 @@
-import ELT from 'client/Components/Calculation/ELT';
import Button from 'client/Elements/Button';
import Checkbox from 'client/Elements/Checkbox';
import Input from 'client/Elements/Input';
@@ -9,29 +8,11 @@ import Radio from 'client/Elements/Radio';
import Select from 'client/Elements/Select';
import Switch from 'client/Elements/Switch';
import Table from 'client/Elements/Table';
-import TextArea from 'client/Elements/TextArea';
-import { Component } from 'core/types/Calculation/components';
-import { TElements } from 'core/types/Calculation/Store/elements';
-import { StoreTables } from 'core/types/Calculation/Store/tables';
+import { FC } from 'react';
+import { AllElementsNames } from '../types/elements';
+import { TableNames } from './../types/tables';
-const elementsComponents: TElements = {
- selectChannel: Select,
- tbxNewClient: Input,
- selectAccount: Select,
- tbxINN: Input,
- tbxKPP: Input,
- selectContactClient: Select,
- tbxContact: Input,
- radioContactGender: Radio,
- tbxPhoneNumber: Input,
- tbxEmailAddress: Input,
- selectSupplier: Select,
- selectFinDepartment: Select,
- selectBroker: Select,
- selectAgent: Select,
- selectDoubleAgent: Select,
- tbxCommentLead: TextArea,
- btnCreateLead: Button,
+export default {
selectProduct: Select,
selectClientRisk: Select,
selectClientType: Select,
@@ -58,7 +39,6 @@ const elementsComponents: TElements = {
selectBrand: Select,
selectModel: Select,
selectConfiguration: Select,
- labelLeaseObjectRisk: Label,
labelDepreciationGroup: Label,
cbxLeaseObjectUsed: Checkbox,
radioDeliveryTime: Radio,
@@ -95,19 +75,15 @@ const elementsComponents: TElements = {
cbxInsDecentral: Switch,
radioInsKaskoType: Radio,
tbxInsFranchise: InputNumber,
- selectInsPeriod: Select,
- btnFranschise: Button,
cbxInsUnlimitDrivers: Switch,
tbxInsAgeDrivers: InputNumber,
tbxInsExpDrivers: InputNumber,
tbxINNForCalc: InputNumber,
- btnDriversApplication: Button,
selectGPSBrand: Select,
selectGPSModel: Select,
selectRegionRegistration: Select,
selectTownRegistration: Select,
radioInfuranceOPF: Radio,
- tbxInsKaskoPriceLeasePeriod: InputNumber,
selectRegistration: Select,
selectInsNSIB: Select,
radioRequirementTelematic: Radio,
@@ -125,8 +101,6 @@ const elementsComponents: TElements = {
cbxQuoteRedemptionGraph: Switch,
tbxQuoteName: Input,
radioQuoteContactGender: Radio,
- btnCreateKP: Button,
- selectUserSession: Select,
cbxDisableChecks: Switch,
selectTarif: Select,
tbxCreditRate: InputNumber,
@@ -138,9 +112,31 @@ const elementsComponents: TElements = {
selectOpportunity: Select,
selectQuote: Select,
cbxRecalcWithRevision: Checkbox,
- btnCalculate: Button,
tbxIRR_Perc: InputNumber,
+ tbxMileage: InputNumber,
+ radioCalcType: Radio,
+ tbxTotalPayments: InputNumber,
+ radioObjectRegistration: Radio,
+ selectObjectRegionRegistration: Select,
+ tbxVehicleTaxInYear: InputNumber,
+ tbxVehicleTaxInLeasingPeriod: InputNumber,
+ selectObjectCategoryTax: Select,
+ selectObjectTypeTax: Select,
+ radioTypePTS: Radio,
+ selectLegalClientRegion: Select,
+ selectLegalClientTown: Select,
+ selectSubsidy: Select,
+ selectFuelCard: Select,
+ labelSubsidySum: Label,
+ tbxMinPriceChange: InputNumber,
+
+ /** Computed Elements */
+ labelLeaseObjectRisk: Label,
+ tbxInsKaskoPriceLeasePeriod: InputNumber,
labelIrrInfo: Label,
+ labelRegistrationDescription: Label,
+
+ /** Result Elements */
labelResultTotalGraphwithNDS: Label,
labelResultPlPrice: Label,
labelResultPriceUpPr: Label,
@@ -157,31 +153,16 @@ const elementsComponents: TElements = {
labelResultBonusMPL: Label,
labelResultDopMPLLeasing: Label,
labelResultBonusDopProd: Label,
+
+ /** Button Elements */
+ btnCreateKP: Button,
+ btnCalculate: Button,
+
+ /** Link Elements */
linkDownloadKp: Link,
- tbxMileage: InputNumber,
- radioCalcType: Radio,
- tbxTotalPayments: InputNumber,
- componentElt: ELT,
- radioObjectRegistration: Radio,
- selectObjectRegionRegistration: Select,
- tbxVehicleTaxInYear: InputNumber,
- tbxVehicleTaxInLeasingPeriod: InputNumber,
- selectObjectCategoryTax: Select,
- selectObjectTypeTax: Select,
- radioTypePTS: Radio,
- labelRegistrationDescription: Label,
- selectLegalClientRegion: Select,
- selectLegalClientTown: Select,
- selectSubsidy: Select,
- selectFuelCard: Select,
- labelSubsidySum: Label,
- tbxMinPriceChange: InputNumber,
-};
-const tablesComponents: StoreTables = {
- tableInsurance: Table,
+ /** Table Elements */
tablePayments: Table,
+ tableInsurance: Table,
tableResults: Table,
-};
-
-export default Object.assign(elementsComponents, tablesComponents);
+} as Record>;
diff --git a/src/client/Containers/Calculation/lib/elements/elementsProps.ts b/src/client/Containers/Calculation/Elements/props/common.ts
similarity index 63%
rename from src/client/Containers/Calculation/lib/elements/elementsProps.ts
rename to src/client/Containers/Calculation/Elements/props/common.ts
index 8563bf8..ad4e565 100644
--- a/src/client/Containers/Calculation/lib/elements/elementsProps.ts
+++ b/src/client/Containers/Calculation/Elements/props/common.ts
@@ -1,82 +1,13 @@
import DownloadOutlined from '@ant-design/icons/lib/icons/DownloadOutlined';
-import InsuranceTag from 'client/Components/Calculation/InsuranceTag';
-import Link from 'client/Elements/Link';
-import buildTooltip from 'client/Elements/Tooltip';
-import { withLink } from 'client/hocs/Calculation';
import { MAX_FRANCHISE } from 'core/constants/stores/Calculation/limits';
import { currentYear } from 'core/tools/date';
import { formatMoney, formatNumber } from 'core/tools/format';
import { pipe } from 'core/tools/func';
import { round } from 'core/tools/num';
-import {
- validateEmail,
- validateInn,
- validateKpp,
- validatePhone,
-} from 'core/tools/validate';
-import { ElementProps } from 'core/types/Calculation/components';
-import { TElements } from 'core/types/Calculation/Store/elements';
+import { ElementProps } from 'types/elements';
+import { AllElementsNames, ElementsNames } from '../../types/elements';
-const elementsProps: TElements = {
- selectChannel: {
- showSearch: true,
- },
- selectAccount: {
- showSearch: true,
- },
- tbxINN: {
- validation: {
- errorMessage: 'Некорректный ИНН',
- validator: validateInn,
- },
- },
- tbxKPP: {
- validation: {
- errorMessage: 'Некорректный КПП',
- validator: validateKpp,
- },
- },
- selectContactClient: {
- showSearch: true,
- },
- radioContactGender: {
- style: 'button',
- },
- tbxPhoneNumber: {
- type: 'tel',
- validation: {
- errorMessage: 'Некорректный номер телефона',
- validator: validatePhone,
- },
- //TODO: mask + 7(999) 999 99 99
- },
- tbxEmailAddress: {
- type: 'email',
- //TODO email mask
- validation: {
- errorMessage: 'Некорректный E-mail',
- validator: validateEmail,
- },
- },
- selectSupplier: {
- showSearch: true,
- },
- selectFinDepartment: {
- showSearch: false,
- },
- selectBroker: {
- showSearch: false,
- },
- selectAgent: {
- showSearch: true,
- },
- selectDoubleAgent: {
- showSearch: true,
- },
- btnCreateLead: {
- type: 'primary',
- text: 'Создать интерес',
- },
+const elementsProps: Partial> = {
tbxLeaseObjectPrice: {
min: '1000.00',
max: '1000000000.00',
@@ -152,7 +83,6 @@ const elementsProps: TElements = {
min: '50',
max: '99',
},
- selectSeasonType: {},
tbxComissionPerc: {
min: '0',
max: '100',
@@ -278,10 +208,6 @@ const elementsProps: TElements = {
precision: 2,
formatter: formatNumber,
},
- btnFranschise: {
- type: 'ghost',
- text: 'Заявление на франшизу',
- },
tbxInsAgeDrivers: {
min: '18',
max: '99',
@@ -290,19 +216,12 @@ const elementsProps: TElements = {
min: '0',
max: '99',
},
- btnDriversApplication: {
- type: 'ghost',
- text: 'Заявление на ограничения по водителям',
- },
selectRegionRegistration: {
showSearch: true,
},
selectTownRegistration: {
showSearch: true,
},
- radioRequirementTelematic: {
- // style: 'button',
- },
radioQuoteContactGender: {
style: 'button',
},
@@ -334,36 +253,12 @@ const elementsProps: TElements = {
},
selectLead: {
showSearch: true,
- sub: {
- Component: withLink(Link)({
- name: 'leadUrl',
- text: 'Открыть в CRM',
- urlName: 'leadUrl',
- type: 'link',
- }),
- },
},
selectOpportunity: {
showSearch: true,
- sub: {
- Component: withLink(Link)({
- name: 'leadUrl',
- text: 'Открыть в CRM',
- urlName: 'opportunityUrl',
- type: 'link',
- }),
- },
},
selectQuote: {
showSearch: true,
- sub: {
- Component: withLink(Link)({
- name: 'leadUrl',
- text: 'Открыть в CRM',
- urlName: 'quoteUrl',
- type: 'link',
- }),
- },
},
btnCalculate: {
text: 'Рассчитать график',
@@ -402,9 +297,6 @@ const elementsProps: TElements = {
precision: 2,
formatter: formatNumber,
},
- componentElt: {
- title: 'Расчет страховки в ЭЛТ',
- },
radioObjectRegistration: {
style: 'button',
},
@@ -416,12 +308,6 @@ const elementsProps: TElements = {
step: '100',
max: '9999999',
precision: 2,
- tooltip: {
- Component: buildTooltip({
- title: 'Без учета налога на роскошь',
- placement: 'topLeft',
- }),
- },
},
tbxVehicleTaxInLeasingPeriod: {
min: '0',
@@ -432,21 +318,12 @@ const elementsProps: TElements = {
selectObjectRegionRegistration: {
showSearch: true,
},
- tbxINNForCalc: {
- // validation: {
- // errorMessage: 'Некорректный ИНН',
- // validator: validateInn,
- // },
- },
- tableInsurance: {
- sub: {
- Component: InsuranceTag,
- },
- },
tbxInsKaskoPriceLeasePeriod: {
min: 0,
precision: 2,
formatter: formatNumber,
+ readOnly: true,
+ controls: false,
},
selectLegalClientRegion: {
showSearch: true,
@@ -457,31 +334,21 @@ const elementsProps: TElements = {
radioInfuranceOPF: {
style: 'button',
},
- selectHighSeasonStart: {
- tooltip: {
- Component: buildTooltip({
- title: 'С какого платежа начинается полный высокий сезон',
- placement: 'topLeft',
- }),
- },
- },
};
-export const numberElementsProps: TElements = Object.keys(
- elementsProps,
-).reduce((acc, a) => {
- const min = elementsProps[a]?.min,
- max = elementsProps[a]?.max;
- if (min || max)
- return {
- ...acc,
- [a]: { min, max },
- };
- return acc;
-}, {});
+export const numberElementsProps: Partial> =
+ Object.keys(elementsProps).reduce((acc, a) => {
+ const min = elementsProps[a]?.min,
+ max = elementsProps[a]?.max;
+ if (min || max)
+ return {
+ ...acc,
+ [a]: { min, max },
+ };
+ return acc;
+ }, {});
-const labelElementsProps: TElements = Object.assign(
- {},
+const moneyResultElementsProps = (
[
'labelResultTotalGraphwithNDS',
'labelResultPlPrice',
@@ -496,25 +363,33 @@ const labelElementsProps: TElements = Object.assign(
'labelResultDopMPLLeasing',
'labelResultBonusDopProd',
'labelSubsidySum',
- ].reduce(
- (ac, a) => ({
- ...ac,
- //@ts-ignore
- [a]: { middleware: value => pipe(round, formatMoney)(value) },
- }),
- {},
- ),
+ ] as ElementsNames[]
+).reduce(
+ (ac, a) => ({
+ ...ac,
+ //@ts-ignore
+ [a]: { middleware: value => pipe(round, formatMoney)(value) },
+ }),
+ {},
+);
+
+const numberResultElementsProps = (
[
'labelResultPriceUpPr',
'labelResultIRRGraphPerc',
'labelResultIRRNominalPerc',
'labelResultTerm',
- ].reduce(
- (ac, a) => ({
- ...ac,
- [a]: { middleware: value => round(value) },
- }),
- {},
- ),
+ ] as ElementsNames[]
+).reduce(
+ (ac, a) => ({
+ ...ac,
+ [a]: { middleware: value => round(value) },
+ }),
+ {},
+);
+
+export default Object.assign(
+ elementsProps,
+ moneyResultElementsProps,
+ numberResultElementsProps,
);
-export default Object.assign(elementsProps, labelElementsProps);
diff --git a/src/client/Containers/Calculation/Elements/props/render.tsx b/src/client/Containers/Calculation/Elements/props/render.tsx
new file mode 100644
index 0000000..29c5f51
--- /dev/null
+++ b/src/client/Containers/Calculation/Elements/props/render.tsx
@@ -0,0 +1,135 @@
+
+import Link from 'client/Elements/Link';
+import buildTooltip from 'client/Elements/Tooltip';
+import { Flex } from 'client/UIKit/grid';
+import { ElementProps } from 'types/elements';
+import InsuranceTag from '../../Components/InsuranceTag';
+import { AllElementsNames } from '../../types/elements';
+import { TableNames } from '../../types/tables';
+import buildLink from '../builders/buildLink';
+
+const Head = props => (
+
+ {props.children}
+
+);
+
+export default {
+ selectLead: {
+ render: (Title, Element) => {
+ const SubComponent = buildLink({
+ name: 'leadUrl',
+ text: 'Открыть в CRM',
+ valueName: 'leadUrl',
+ type: 'link',
+ Component: Link,
+ });
+ return (
+
+
+
+
+
+
+
+ );
+ },
+ },
+
+ selectOpportunity: {
+ render: (Title, Element) => {
+ const SubComponent = buildLink({
+ name: 'leadUrl',
+ text: 'Открыть в CRM',
+ valueName: 'opportunityUrl',
+ type: 'link',
+ Component: Link,
+ });
+ return (
+
+
+
+
+
+
+
+ );
+ },
+ },
+
+ selectQuote: {
+ render: (Title, Element) => {
+ const SubComponent = buildLink({
+ name: 'leadUrl',
+ text: 'Открыть в CRM',
+ valueName: 'quoteUrl',
+ type: 'link',
+ Component: Link,
+ });
+ return (
+
+
+
+
+
+
+
+ );
+ },
+ },
+
+ tableInsurance: {
+ sub: {
+ Component: InsuranceTag,
+ },
+ render: (Title, Element) => {
+ return (
+
+
+
+
+
+
+
+ );
+ },
+ },
+
+ tbxVehicleTaxInYear: {
+ render: (Title, Component) => {
+ const Tooltip = buildTooltip({
+ title: 'Без учета налога на роскошь',
+ placement: 'topLeft',
+ });
+ return (
+
+
+
+
+
+
+ );
+ },
+ },
+
+ selectHighSeasonStart: {
+ render: (Title, Component) => {
+ const Tooltip = buildTooltip({
+ title: 'С какого платежа начинается полный высокий сезон',
+ placement: 'topLeft',
+ });
+ return (
+
+
+
+
+
+
+ );
+ },
+ },
+} as Partial>;
diff --git a/src/client/Containers/Calculation/lib/elements/tables/index.js b/src/client/Containers/Calculation/Elements/tables/index.js
similarity index 100%
rename from src/client/Containers/Calculation/lib/elements/tables/index.js
rename to src/client/Containers/Calculation/Elements/tables/index.js
diff --git a/src/client/Containers/Calculation/lib/elements/tables/insurance.ts b/src/client/Containers/Calculation/Elements/tables/insurance.ts
similarity index 95%
rename from src/client/Containers/Calculation/lib/elements/tables/insurance.ts
rename to src/client/Containers/Calculation/Elements/tables/insurance.ts
index e911ac6..402a135 100644
--- a/src/client/Containers/Calculation/lib/elements/tables/insurance.ts
+++ b/src/client/Containers/Calculation/Elements/tables/insurance.ts
@@ -8,16 +8,10 @@ import {
} from 'core/constants/stores/Calculation/filters';
import { MAX_INSURANCE } from 'core/constants/stores/Calculation/limits';
import { formatNumber } from 'core/tools/format';
-import {
- ITable,
- TableColumn,
- TableColumnCallbacks,
- TableColumnOptions,
- TableRow,
-} from 'core/types/Calculation/Store/tables';
-import { ElementStatus } from 'core/types/statuses';
+import { ElementStatus } from 'types/elements';
+import { Column, Table } from '../../types/tables';
-const columns: TableColumn[] = [
+const columns: Column[] = [
{
name: 'policyType',
title: 'Тип полиса',
@@ -61,7 +55,7 @@ const columns: TableColumn[] = [
},
];
-const rows: TableRow[] = [
+const rows: Table['rows'] = [
{
policyType: {
value: 'ОСАГО',
@@ -144,7 +138,7 @@ const rows: TableRow[] = [
},
];
-const callbacks: TableColumnCallbacks = {
+const callbacks: Table['callbacks'] = {
insCost: ({ calculationStore, tableName, rowIndex }) => {
if (
calculationStore.tables[tableName]?.rows[rowIndex]['insCost']?.value &&
@@ -336,7 +330,7 @@ const callbacks: TableColumnCallbacks = {
},
};
-const options: TableColumnOptions = {
+const options: Table['options'] = {
insured: [
{
name: 'ЛП',
@@ -365,4 +359,4 @@ export default {
options,
callbacks,
params: {},
-} as ITable;
+} as Table;
diff --git a/src/client/Containers/Calculation/lib/elements/tables/payments.ts b/src/client/Containers/Calculation/Elements/tables/payments.ts
similarity index 88%
rename from src/client/Containers/Calculation/lib/elements/tables/payments.ts
rename to src/client/Containers/Calculation/Elements/tables/payments.ts
index c2c33c4..5b1c49d 100644
--- a/src/client/Containers/Calculation/lib/elements/tables/payments.ts
+++ b/src/client/Containers/Calculation/Elements/tables/payments.ts
@@ -2,16 +2,12 @@ import InputNumber from 'client/Elements/InputNumber';
import valuesConstants from 'core/constants/values';
import { rotateArrays } from 'core/tools/array';
import { formatNumber } from 'core/tools/format';
-import {
- ITable,
- TableColumn,
- TableColumnCallbacks,
- TableColumnFeatures,
-} from 'core/types/Calculation/Store/tables';
import { inRange } from 'lodash';
+import { Table } from '../../types/tables';
+
const { PERIODS_NUMBER } = valuesConstants;
-const columns: TableColumn[] = [
+const columns: Table['columns'] = [
{
name: 'paymentRelation',
title: '% платежа',
@@ -26,7 +22,7 @@ const columns: TableColumn[] = [
},
];
-const callbacks: TableColumnCallbacks = {
+const callbacks: Table['callbacks'] = {
paymentRelation: ({ calculationStore, tableName, rowIndex, value }) => {
const rowLength = calculationStore.tables[tableName].rows.length;
const { graphType, seasonType } = calculationStore.values;
@@ -65,9 +61,8 @@ const callbacks: TableColumnCallbacks = {
),
shiftNumber = highSeasonStartValue - 2;
- const seasonTypeOptions = calculationStore.getOption(
- 'selectSeasonType',
- );
+ const seasonTypeOptions =
+ calculationStore.getOption('selectSeasonType');
const startPositions =
seasonTypeOptions && seasonTypeOptions.startPositions,
endPositions =
@@ -123,19 +118,19 @@ const callbacks: TableColumnCallbacks = {
},
};
-const features: TableColumnFeatures = {
- numerize: true,
- split: {
- rowsNumber: 12,
- columnsNumber: 3,
+const params: Table['params'] = {
+ features: {
+ numerize: true,
+ split: {
+ rowsNumber: 12,
+ columnsNumber: 3,
+ },
},
};
-const params = { features };
-
export default {
columns,
rows: [],
params,
callbacks,
-} as ITable;
+} as Table;
diff --git a/src/client/Containers/Calculation/lib/elements/tables/results.ts b/src/client/Containers/Calculation/Elements/tables/results.ts
similarity index 77%
rename from src/client/Containers/Calculation/lib/elements/tables/results.ts
rename to src/client/Containers/Calculation/Elements/tables/results.ts
index 0a05714..13645d8 100644
--- a/src/client/Containers/Calculation/lib/elements/tables/results.ts
+++ b/src/client/Containers/Calculation/Elements/tables/results.ts
@@ -3,13 +3,9 @@ import Label from 'client/Elements/Label';
import { formatMoney } from 'core/tools/format';
import { pipe } from 'core/tools/func';
import { round } from 'core/tools/num';
-import {
- ITable,
- TableColumn,
- TableColumnFeatures,
-} from 'core/types/Calculation/Store/tables';
+import { Column, Table } from '../../types/tables';
-const columns: TableColumn[] = [
+const columns: Column[] = [
{
name: 'paymentSum',
title: 'Сумма платежа',
@@ -36,14 +32,14 @@ const columns: TableColumn[] = [
},
];
-const features: TableColumnFeatures = {
- numerize: true,
+const params: Table['params'] = {
+ features: {
+ numerize: true,
+ },
};
-const params = { features };
-
export default {
columns,
rows: [],
params,
-} as ITable;
+} as Table;
diff --git a/src/client/Containers/Calculation/lib/elements/titles.ts b/src/client/Containers/Calculation/Elements/titles.ts
similarity index 86%
rename from src/client/Containers/Calculation/lib/elements/titles.ts
rename to src/client/Containers/Calculation/Elements/titles.ts
index 3a6fb4c..3b559b7 100644
--- a/src/client/Containers/Calculation/lib/elements/titles.ts
+++ b/src/client/Containers/Calculation/Elements/titles.ts
@@ -1,27 +1,10 @@
-import { TElements } from 'core/types/Calculation/Store/elements';
-import { StoreTables } from 'core/types/Calculation/Store/tables';
+import { AllElementsNames } from '../types/elements';
+import { TableNames } from '../types/tables';
-export const elementsTitles: TElements = {
+export const elementsTitles: Partial> = {
selectLead: 'Интерес',
selectOpportunity: 'Лизинговая сделка',
selectQuote: 'Предложение',
- selectTemplate: 'Выбор шаблона',
- selectChannel: 'Канал привлечения',
- tbxNewClient: 'Новый контрагент',
- selectAccount: 'Существующий контрагент',
- tbxINN: 'ИНН',
- tbxKPP: 'КПП',
- selectContactClient: 'Контактное лицо контрагента',
- tbxContact: 'Контактное лицо',
- radioContactGender: 'Пол контактного лица',
- tbxPhoneNumber: 'Телефон',
- tbxEmailAddress: 'E-mail',
- selectSupplier: 'Поставщик',
- selectFinDepartment: 'Финотдел',
- selectAgent: 'Агент',
- selectDoubleAgent: 'Двойной агент',
- selectBroker: 'Брокер',
- tbxCommentLead: 'Комментарий к интересу',
selectProduct: 'Продукт',
selectClientRisk: 'Риск клиента',
selectClientType: 'Тип клиента',
@@ -113,15 +96,12 @@ export const elementsTitles: TElements = {
tbxImporterRewardPerc: 'АВ импортера, %',
tbxImporterRewardRub: 'АВ импортера, руб.',
cbxDisableChecks: 'Отключить все проверки',
- tbxSystemUser: 'Пользователь',
- tbxBusinessUnit: 'Подразделение',
selectRegistration: 'Регистрация',
selectInsNSIB: 'НСИБ',
selectTechnicalCard: 'Карта техпомощи',
radioRequirementTelematic: 'Программа средства контроля',
selectTelematic: 'Телематика ',
selectTracker: 'Маяк',
- selectUserSession: 'Загрузить сессию пользователя',
labelIrrInfo: 'Диапазон IRR (Номинал)',
tbxMileage: 'Пробег, км',
radioCalcType: 'Расчет от',
@@ -141,9 +121,8 @@ export const elementsTitles: TElements = {
labelSubsidySum: 'Сумма субсидии с НДС',
selectFuelCard: 'Топливная карта',
tbxMinPriceChange: 'Мин. возможное изменение стоимости ПЛ',
-};
-const resultsTitles: TElements = {
+ /** Result Elements */
labelResultTotalGraphwithNDS: 'Итого по графику, с НДС',
labelResultPlPrice: 'Стоимость ПЛ с НДС',
labelResultPriceUpPr: 'Удорожание, год',
@@ -162,10 +141,10 @@ const resultsTitles: TElements = {
labelResultBonusDopProd: 'Бонус МПЛ за доп.продукты, без НДФЛ',
};
-export const tablesTitles: StoreTables = {
+export const tablesTitles: Record = {
tableInsurance: 'Таблица страхования',
tablePayments: 'Таблица платежей',
tableResults: '',
};
-export default Object.assign(elementsTitles, resultsTitles, tablesTitles);
+export default Object.assign(elementsTitles, tablesTitles);
diff --git a/src/client/Containers/Calculation/lib/elements/tools.ts b/src/client/Containers/Calculation/Elements/tools.ts
similarity index 60%
rename from src/client/Containers/Calculation/lib/elements/tools.ts
rename to src/client/Containers/Calculation/Elements/tools.ts
index f119469..25347f1 100644
--- a/src/client/Containers/Calculation/lib/elements/tools.ts
+++ b/src/client/Containers/Calculation/Elements/tools.ts
@@ -1,17 +1,15 @@
//@ts-nocheck
-import { ElementsNames } from 'core/types/Calculation/Store/elements';
import { ValuesNames } from 'core/types/Calculation/Store/values';
+import { ElementsNames } from '../types/elements';
import { elementsTitles } from './titles';
-import { elementsValues } from './values';
+import values from './values';
export function getValueName(elementName: ElementsNames): ValuesNames {
- return elementsValues[elementName];
+ return values[elementName];
}
export function getFieldName(valueName: ValuesNames): ElementsNames {
- return Object.keys(elementsValues).find(
- key => elementsValues[key] === valueName,
- );
+ return Object.keys(values).find(key => values[key] === valueName);
}
export function getTitle(elementName: ElementsNames): string {
diff --git a/src/client/Containers/Calculation/lib/elements/values.ts b/src/client/Containers/Calculation/Elements/values.ts
similarity index 84%
rename from src/client/Containers/Calculation/lib/elements/values.ts
rename to src/client/Containers/Calculation/Elements/values.ts
index c8077fc..ac868ed 100644
--- a/src/client/Containers/Calculation/lib/elements/values.ts
+++ b/src/client/Containers/Calculation/Elements/values.ts
@@ -1,31 +1,21 @@
-import { TElements } from 'core/types/Calculation/Store/elements';
+import { ActionsNames } from 'core/types/Calculation/Store/effect';
+import { LinksNames } from 'core/types/Calculation/Store/links';
import {
- ResultValuesNames,
+ ComputedValuesNames,
ValuesNames,
} from 'core/types/Calculation/Store/values';
+import {
+ ButtonElementsNames,
+ ComputedElementsNames,
+ ElementsNames,
+ LinkElementsNames,
+} from '../types/elements';
-export const elementsValues: TElements = {
+const elementsValues: Record = {
selectLead: 'lead',
selectOpportunity: 'opportunity',
selectQuote: 'quote',
cbxRecalcWithRevision: 'recalcWithRevision',
- selectTemplate: 'template',
- selectChannel: 'channel',
- tbxNewClient: 'newClient',
- selectAccount: 'account',
- tbxINN: 'INN',
- tbxKPP: 'KPP',
- selectContactClient: 'contactClient',
- tbxContact: 'contact',
- radioContactGender: 'contactGender',
- tbxPhoneNumber: 'phoneNumber',
- tbxEmailAddress: 'emailAddress',
- selectSupplier: 'supplier',
- selectFinDepartment: 'finDepartment',
- selectAgent: 'agent',
- selectDoubleAgent: 'doubleAgent',
- selectBroker: 'broker',
- tbxCommentLead: 'commentLead',
selectProduct: 'product',
selectClientRisk: 'clientRisk',
selectClientType: 'clientType',
@@ -93,7 +83,6 @@ export const elementsValues: TElements = {
radioInfuranceOPF: 'infuranceOPF',
radioInsKaskoType: 'insKaskoType',
cbxInsDecentral: 'insDecentral',
- selectInsPeriod: 'insPeriod',
tbxInsFranchise: 'insFranchise',
cbxInsUnlimitDrivers: 'insUnlimitDrivers',
tbxInsAgeDrivers: 'insAgeDrivers',
@@ -113,7 +102,6 @@ export const elementsValues: TElements = {
selectTarif: 'tarif',
tbxCreditRate: 'creditRate',
selectRate: 'rate',
- selectUserSession: 'userSession',
tbxMaxPriceChange: 'maxPriceChange',
tbxImporterRewardPerc: 'importerRewardPerc',
tbxImporterRewardRub: 'importerRewardRub',
@@ -140,9 +128,8 @@ export const elementsValues: TElements = {
labelSubsidySum: 'subsidySum',
selectFuelCard: 'fuelCard',
tbxMinPriceChange: 'minPriceChange',
-};
-const resultElementsValues: TElements = {
+ /** Result Elements */
labelResultTotalGraphwithNDS: 'resultTotalGraphwithNDS',
labelResultPlPrice: 'resultPlPrice',
labelResultPriceUpPr: 'resultPriceUpPr',
@@ -161,4 +148,28 @@ const resultElementsValues: TElements = {
labelResultBonusDopProd: 'resultBonusDopProd',
};
-export default Object.assign(elementsValues, resultElementsValues);
+const elementsComputedValues: Record<
+ ComputedElementsNames,
+ ComputedValuesNames
+> = {
+ labelLeaseObjectRisk: 'leaseObjectRiskName',
+ tbxInsKaskoPriceLeasePeriod: 'insKaskoPriceLeasePeriod',
+ labelIrrInfo: 'irrInfo',
+ labelRegistrationDescription: 'registrationDescription',
+};
+
+const elementsActions: Record = {
+ btnCalculate: 'calculate',
+ btnCreateKP: 'createKP',
+};
+
+const elementsLinks: Record = {
+ linkDownloadKp: 'kpUrl',
+};
+
+export default Object.assign(
+ elementsValues,
+ elementsComputedValues,
+ elementsActions,
+ elementsLinks,
+);
diff --git a/src/client/Containers/Calculation/index.jsx b/src/client/Containers/Calculation/index.jsx
index 3fc9875..67be2b4 100644
--- a/src/client/Containers/Calculation/index.jsx
+++ b/src/client/Containers/Calculation/index.jsx
@@ -2,9 +2,9 @@ import withStores from 'client/hocs/withStores';
import { Box } from 'client/UIKit/grid';
import mq from 'client/UIKit/mq';
import styled from 'styled-components';
-import Info from './Info';
-import Results from './Results';
-import Sections from './Sections';
+import Info from './Components/Info';
+import Results from './Components/Results';
+import Sections from './Components/Sections';
const Grid = styled(Box)`
grid-gap: 10px;
diff --git a/src/client/Containers/Calculation/lib/buildElement.js b/src/client/Containers/Calculation/lib/buildElement.js
index 205b3d8..efd7f6c 100644
--- a/src/client/Containers/Calculation/lib/buildElement.js
+++ b/src/client/Containers/Calculation/lib/buildElement.js
@@ -1,61 +1,20 @@
-import {
- withButton,
- withComputedValue,
- withLink,
- withTable,
- withValue,
-} from 'client/hocs/Calculation';
-import { ElementType } from 'core/types/Calculation/Store/elements';
-import { pick } from 'lodash';
-import elementsActions from './elements/actions';
-import elementsComponents from './elements/components';
-import elementsComputedValues from './elements/computedValues';
-import tables from './elements/tables';
-import { getValueName } from './elements/tools';
-import elementsTypes from './elements/types';
-import elementsUrls from './elements/urls';
+import builders from '../Elements/builders';
+import components from '../Elements/components';
+import props from '../Elements/props/common';
+import { getValueName } from '../Elements/tools';
-export function buildElement(elementName, elementProps = {}) {
- const elementType = elementsTypes[elementName];
- const Component = elementsComponents[elementName];
+export function buildElement(name) {
+ const valueName = getValueName(name);
+ const Component = components[name];
+ const elementProps = props[name];
- switch (elementType) {
- case ElementType.Table: {
- return withTable(Component)({
- name: elementName,
- ...pick(tables[elementName], ['options', 'callbacks', 'params']),
- });
- }
- case ElementType.Action: {
- return withButton(Component)({
- name: elementName,
- actionName: elementsActions[elementName],
- ...elementProps,
- });
- }
- case ElementType.Computed: {
- return withComputedValue(Component)({
- name: elementName,
- computedValueName: elementsComputedValues[elementName],
- ...elementProps,
- });
- }
- case ElementType.Link: {
- return withLink(Component)({
- name: elementName,
- urlName: elementsUrls[elementName],
- ...elementProps,
- });
- }
- case ElementType.Custom: {
- return () => ;
- }
- default: {
- return withValue(Component)({
- name: elementName,
- valueName: getValueName(elementName),
- ...elementProps,
- });
- }
- }
+ const builder = builders[name];
+ const Element = builder({
+ name,
+ valueName,
+ Component,
+ ...elementProps,
+ });
+
+ return Element;
}
diff --git a/src/client/Containers/Calculation/lib/elements/actions.ts b/src/client/Containers/Calculation/lib/elements/actions.ts
deleted file mode 100644
index 78fd32b..0000000
--- a/src/client/Containers/Calculation/lib/elements/actions.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { TElements } from 'core/types/Calculation/Store/elements';
-import { ActionsNames } from 'core/types/Calculation/Store/effect';
-
-const elementsActions: TElements = {
- btnCalculate: 'calculate',
- btnCreateLead: 'createLead',
- btnCreateKP: 'createKP',
-};
-
-export default elementsActions;
diff --git a/src/client/Containers/Calculation/lib/elements/computedValues.ts b/src/client/Containers/Calculation/lib/elements/computedValues.ts
deleted file mode 100644
index e6bd180..0000000
--- a/src/client/Containers/Calculation/lib/elements/computedValues.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { TElements } from 'core/types/Calculation/Store/elements';
-import { ComputedValuesNames } from 'core/types/Calculation/Store/values';
-
-const elementsComputedValues: TElements = {
- labelLeaseObjectRisk: 'leaseObjectRiskName',
- tbxInsKaskoPriceLeasePeriod: 'insKaskoPriceLeasePeriod',
- labelIrrInfo: 'irrInfo',
- labelRegistrationDescription: 'registrationDescription',
-};
-
-export default elementsComputedValues;
diff --git a/src/client/Containers/Calculation/lib/elements/types.ts b/src/client/Containers/Calculation/lib/elements/types.ts
deleted file mode 100644
index 6682813..0000000
--- a/src/client/Containers/Calculation/lib/elements/types.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { ElementType, TElements } from 'core/types/Calculation/Store/elements';
-import { StoreTables } from 'core/types/Calculation/Store/tables';
-
-const elementsTypes: TElements = {
- labelLeaseObjectRisk: ElementType.Computed,
- btnFranschise: ElementType.Action,
- btnDriversApplication: ElementType.Action,
- tbxInsKaskoPriceLeasePeriod: ElementType.Computed,
- btnCreateKP: ElementType.Action,
- btnCalculate: ElementType.Action,
- labelIrrInfo: ElementType.Computed,
- linkDownloadKp: ElementType.Link,
- componentElt: ElementType.Custom,
- labelRegistrationDescription: ElementType.Computed,
-};
-
-const tablesTypes: StoreTables = {
- tablePayments: ElementType.Table,
- tableInsurance: ElementType.Table,
- tableResults: ElementType.Table,
-};
-
-export default Object.assign(elementsTypes, tablesTypes);
diff --git a/src/client/Containers/Calculation/lib/elements/urls.ts b/src/client/Containers/Calculation/lib/elements/urls.ts
deleted file mode 100644
index 517d474..0000000
--- a/src/client/Containers/Calculation/lib/elements/urls.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { LinksNames } from 'core/types/Calculation/Store/links';
-import { TElements } from 'core/types/Calculation/Store/elements';
-
-const elementsUrls: TElements = {
- linkDownloadKp: 'kpUrl',
-};
-
-export default elementsUrls;
diff --git a/src/client/Containers/Calculation/lib/renderSections.js b/src/client/Containers/Calculation/lib/renderSections.js
index b6c8834..6f8125a 100644
--- a/src/client/Containers/Calculation/lib/renderSections.js
+++ b/src/client/Containers/Calculation/lib/renderSections.js
@@ -5,9 +5,9 @@ import colors from 'client/UIKit/colors';
import { Box, Flex } from 'client/UIKit/grid';
import mq from 'client/UIKit/mq';
import styled from 'styled-components';
+import elementsRenderProps from '../Elements/props/render';
+import elementsTitles from '../Elements/titles';
import { buildElement } from '../lib/buildElement';
-import elementsProps from './elements/elementsProps';
-import elementsTitles from './elements/titles';
const ElementTitle = styled.h5`
color: rgba(0, 0, 0, 0.75);
@@ -17,47 +17,26 @@ const ElementTitle = styled.h5`
margin: 0 8px 3px 0;
text-overflow: ellipsis;
overflow: hidden;
- white-space: ${props => props.whiteSpace || 'nowrap'};
+ white-space: nowrap;
`;
-const Head = ({ sub, elementTitle, style }) => {
- if (sub?.Component) {
- return (
-
- {elementTitle}
-
-
- );
- }
- return {elementTitle};
-};
+const renderElements = ({ elements }) => {
+ return elements.map(elementName => {
+ const elementTitleText = elementsTitles[elementName];
+ const Title = () => {elementTitleText};
+ const Element = buildElement(elementName);
-const renderElements = ({ elements, elementStyle }) => {
- return elements.map((elementName, ie) => {
- const elementTitle = elementsTitles[elementName];
- const { tooltip, sub, ...elementProps } = elementsProps[elementName] || {};
-
- const Component = buildElement(elementName, elementProps);
- const Tooltip = tooltip?.Component;
-
- const element = (
-
-
-
-
- );
- if (tooltip) {
- return {element};
+ if (elementsRenderProps[elementName]) {
+ const { render } = elementsRenderProps[elementName];
+ return render(Title, Element);
}
- return element;
+
+ return (
+
+
+
+
+ );
});
};
@@ -73,16 +52,13 @@ const ElementsGrid = styled(Box)`
`;
const renderBlocks = ({ blocks }) => {
- if (!blocks || blocks.length === 0) {
- return null;
- }
- return blocks.map((block, ib) => {
- const { elements, title, style, elementStyle } = block;
+ return blocks?.map((block, ib) => {
+ const { elements, title, style } = block;
return (
{title && {title}}
- {renderElements({ elements, elementStyle })}
+ {renderElements({ elements })}
);
@@ -96,10 +72,7 @@ const BlocksTitle = styled(Divider)`
`;
export const renderGroups = ({ groups }) => {
- if (!groups || groups.length === 0) {
- return null;
- }
- return groups.map((group, ig) => {
+ return groups?.map((group, ig) => {
const { title, blocks, style } = group;
return (
diff --git a/src/client/Containers/Calculation/types/common.ts b/src/client/Containers/Calculation/types/common.ts
new file mode 100644
index 0000000..76ad448
--- /dev/null
+++ b/src/client/Containers/Calculation/types/common.ts
@@ -0,0 +1,19 @@
+import { AllElementsNames, CustomComponents } from './elements';
+import { TableNames } from './tables';
+
+interface IBlock {
+ title?: string;
+ elements: (AllElementsNames | TableNames | CustomComponents)[];
+ [key: string]: any;
+}
+
+export interface IGroup {
+ title?: string;
+ blocks?: IBlock[];
+ style?: { [key: string]: any };
+}
+
+export interface ISection {
+ title?: string;
+ groups?: IGroup[];
+}
diff --git a/src/core/types/Calculation/Store/elements.ts b/src/client/Containers/Calculation/types/elements.ts
similarity index 77%
rename from src/core/types/Calculation/Store/elements.ts
rename to src/client/Containers/Calculation/types/elements.ts
index b33d84c..9143c85 100644
--- a/src/core/types/Calculation/Store/elements.ts
+++ b/src/client/Containers/Calculation/types/elements.ts
@@ -1,28 +1,8 @@
-import { TableNames } from 'core/types/Calculation/Store/tables';
-
export type ElementsNames =
| 'selectLead'
| 'selectOpportunity'
| 'selectQuote'
| 'cbxRecalcWithRevision'
- | 'selectTemplate'
- | 'selectChannel'
- | 'tbxNewClient'
- | 'selectAccount'
- | 'tbxINN'
- | 'tbxKPP'
- | 'selectContactClient'
- | 'tbxContact'
- | 'radioContactGender'
- | 'tbxPhoneNumber'
- | 'tbxEmailAddress'
- | 'selectSupplier'
- | 'selectFinDepartment'
- | 'selectAgent'
- | 'selectDoubleAgent'
- | 'selectBroker'
- | 'tbxCommentLead'
- | 'btnCreateLead'
| 'selectProduct'
| 'selectClientRisk'
| 'selectClientType'
@@ -48,7 +28,6 @@ export type ElementsNames =
| 'tbxIRR_Perc'
| 'selectLeaseObjectType'
| 'radioDeliveryTime'
- | 'labelLeaseObjectRisk'
| 'labelDepreciationGroup'
| 'tbxLeaseObjectCount'
| 'cbxWithTrailer'
@@ -90,9 +69,7 @@ export type ElementsNames =
| 'selectTownRegistration'
| 'radioInfuranceOPF'
| 'radioInsKaskoType'
- | 'tbxInsKaskoPriceLeasePeriod'
| 'cbxInsDecentral'
- | 'selectInsPeriod'
| 'tbxInsFranchise'
| 'cbxInsUnlimitDrivers'
| 'tbxInsAgeDrivers'
@@ -108,32 +85,20 @@ export type ElementsNames =
| 'cbxNSIB'
| 'tbxQuoteName'
| 'radioQuoteContactGender'
- | 'btnCreateKP'
| 'cbxQuoteRedemptionGraph'
| 'selectTarif'
| 'tbxCreditRate'
| 'selectRate'
- | 'selectUserSession'
| 'radioRequirementTelematic'
| 'tbxMaxPriceChange'
| 'tbxImporterRewardPerc'
| 'tbxImporterRewardRub'
| 'cbxDisableChecks'
- | 'btnFranschise'
- | 'btnDriversApplication'
- | 'tbxSystemUser'
- | 'tbxBusinessUnit'
- | 'tbxLeadNumber'
- | 'tbxOpportunityNumber'
- | 'lblLead'
- | 'lblOpportunity'
- | 'btnCalculate'
| 'selectRegistration'
| 'selectInsNSIB'
| 'selectTechnicalCard'
| 'selectTelematic'
| 'selectTracker'
- | 'labelIrrInfo'
| 'tbxMileage'
| 'radioCalcType'
| 'tbxTotalPayments'
@@ -144,17 +109,13 @@ export type ElementsNames =
| 'selectObjectCategoryTax'
| 'selectObjectTypeTax'
| 'radioTypePTS'
- | 'labelRegistrationDescription'
| 'selectLegalClientRegion'
| 'selectLegalClientTown'
| 'selectSubsidy'
| 'labelSubsidySum'
| 'selectFuelCard'
- | 'tbxMinPriceChange';
-
-export type LinkElementsNames = 'linkDownloadKp';
-
-export type ResultElementsNames =
+ | 'tbxMinPriceChange'
+ /** Result Elements */
| 'labelResultTotalGraphwithNDS'
| 'labelResultPlPrice'
| 'labelResultPriceUpPr'
@@ -171,25 +132,29 @@ export type ResultElementsNames =
| 'labelResultBonusMPL'
| 'labelResultDopMPLLeasing'
| 'labelResultBonusDopProd';
+export type ButtonElementsNames = 'btnCreateKP' | 'btnCalculate';
+export type LinkElementsNames = 'linkDownloadKp';
+export type ComputedElementsNames =
+ | 'labelLeaseObjectRisk'
+ | 'tbxInsKaskoPriceLeasePeriod'
+ | 'labelIrrInfo'
+ | 'labelRegistrationDescription';
export type CustomComponents = 'componentElt';
-export type AllElements =
+/** GROUPS */
+export type InteractionElementsNames =
| ElementsNames
- | ResultElementsNames
+ | ButtonElementsNames
+ | LinkElementsNames;
+
+export type NonValueElementsNames =
+ | ButtonElementsNames
| LinkElementsNames
- | CustomComponents
- | TableNames;
+ | ComputedElementsNames;
-export enum ElementType {
- Default,
- Computed,
- Table,
- Action,
- Link,
- Custom,
-}
-
-export type TElements = {
- [elementName in AllElements]?: T;
-};
+export type AllElementsNames =
+ | ElementsNames
+ | ComputedElementsNames
+ | ButtonElementsNames
+ | LinkElementsNames;
diff --git a/src/client/Containers/Calculation/types/tables.ts b/src/client/Containers/Calculation/types/tables.ts
new file mode 100644
index 0000000..25d0031
--- /dev/null
+++ b/src/client/Containers/Calculation/types/tables.ts
@@ -0,0 +1,49 @@
+import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess';
+import { TOptionizedEntity } from 'core/services/CrmService/types/common';
+import { ICalculationStore } from 'core/types/Calculation/Store';
+import { TElementFilter } from 'core/types/Calculation/Store/filters';
+import { FC } from 'react';
+import { ElementProps, ElementStatus } from 'types/elements';
+
+export type TableNames = 'tableInsurance' | 'tablePayments' | 'tableResults';
+export type TableValuesNames =
+ | 'policyType'
+ | 'insuranceCompany'
+ | 'insured'
+ | 'insCost'
+ | 'insTerm'
+ | 'paymentNumber'
+ | 'paymentRelation'
+ | 'paymentSum'
+ | 'ndsCompensation'
+ | 'redemptionAmount';
+
+type CellCallback = (props: {
+ calculationStore: ICalculationStore;
+ calculationProcess: TCalculationProcess;
+ tableName: TableNames;
+ rowIndex: number;
+ value: any;
+}) => void;
+
+export type Cell = {
+ value?: any;
+ status?: ElementStatus;
+ validation?: boolean;
+ filter?: TElementFilter;
+};
+
+export type Column = {
+ name: TableValuesNames;
+ title: string;
+ Component: FC;
+ props?: ElementProps;
+};
+
+export type Table = {
+ columns: Column[];
+ rows: Partial>[];
+ options?: Partial>;
+ params?: { features?: Record };
+ callbacks?: Partial>;
+};
diff --git a/src/client/Elements/Button.jsx b/src/client/Elements/Button.jsx
index eb2c2c1..4881357 100644
--- a/src/client/Elements/Button.jsx
+++ b/src/client/Elements/Button.jsx
@@ -1,7 +1,7 @@
import { Button as AntButton } from 'antd';
import { ACTION_DELAY } from 'core/constants/debounce';
-import { ElementStatus } from 'core/types/statuses';
import { throttle } from 'lodash';
+import { ElementStatus } from 'types/elements';
const Button = ({ status, action, text, ...props }) => {
const throttledAction = action
diff --git a/src/client/Elements/Checkbox.jsx b/src/client/Elements/Checkbox.jsx
index 6e87c98..d6ab6a9 100644
--- a/src/client/Elements/Checkbox.jsx
+++ b/src/client/Elements/Checkbox.jsx
@@ -1,5 +1,5 @@
import { Checkbox as AntCheckbox, Form } from 'antd';
-import { ElementStatus } from 'core/types/statuses';
+import { ElementStatus } from 'types/elements';
const Checkbox = ({
value,
diff --git a/src/client/Elements/Input.jsx b/src/client/Elements/Input.jsx
index 9c50182..3abb5fd 100644
--- a/src/client/Elements/Input.jsx
+++ b/src/client/Elements/Input.jsx
@@ -1,5 +1,5 @@
import { Form, Input as AntInput } from 'antd';
-import { ElementStatus } from 'core/types/statuses';
+import { ElementStatus } from 'types/elements';
const Input = ({
value,
diff --git a/src/client/Elements/InputNumber.jsx b/src/client/Elements/InputNumber.jsx
index cf60b4c..12014ac 100644
--- a/src/client/Elements/InputNumber.jsx
+++ b/src/client/Elements/InputNumber.jsx
@@ -1,7 +1,7 @@
import { Form, InputNumber as AntInputNumber } from 'antd';
import { Outlined } from 'client/Components/Spinner';
-import { ElementStatus } from 'core/types/statuses';
import styled from 'styled-components';
+import { ElementStatus } from 'types/elements';
const { Disabled, Loading } = ElementStatus;
diff --git a/src/client/Elements/Link.jsx b/src/client/Elements/Link.jsx
index a3a17db..0920054 100644
--- a/src/client/Elements/Link.jsx
+++ b/src/client/Elements/Link.jsx
@@ -1,5 +1,5 @@
import { Button as AntButton } from 'antd';
-import { ElementStatus } from 'core/types/statuses';
+import { ElementStatus } from 'types/elements';
const Link = ({ status, url, text, icon: Icon, ...props }) => {
return (
diff --git a/src/client/Elements/Radio.jsx b/src/client/Elements/Radio.jsx
index 23d386d..9547ba9 100644
--- a/src/client/Elements/Radio.jsx
+++ b/src/client/Elements/Radio.jsx
@@ -1,5 +1,5 @@
import { Form, Radio as AntRadio } from 'antd';
-import { ElementStatus } from 'core/types/statuses';
+import { ElementStatus } from 'types/elements';
const Radio = ({
value,
diff --git a/src/client/Elements/Select.jsx b/src/client/Elements/Select.jsx
index a83d3c7..9d94ec4 100644
--- a/src/client/Elements/Select.jsx
+++ b/src/client/Elements/Select.jsx
@@ -1,5 +1,5 @@
import { Form, Select as AntSelect } from 'antd';
-import { ElementStatus } from 'core/types/statuses';
+import { ElementStatus } from 'types/elements';
const Select = ({
value = null,
diff --git a/src/client/Elements/Switch.jsx b/src/client/Elements/Switch.jsx
index 854721a..f0473d1 100644
--- a/src/client/Elements/Switch.jsx
+++ b/src/client/Elements/Switch.jsx
@@ -1,5 +1,5 @@
import { Form, Switch as AntSwitch } from 'antd';
-import { ElementStatus } from 'core/types/statuses';
+import { ElementStatus } from 'types/elements';
const Switch = ({
value,
diff --git a/src/client/Elements/TextArea.jsx b/src/client/Elements/TextArea.jsx
index 863a593..dab853f 100644
--- a/src/client/Elements/TextArea.jsx
+++ b/src/client/Elements/TextArea.jsx
@@ -1,5 +1,5 @@
import { Form, Input as AntInput } from 'antd';
-import { ElementStatus } from 'core/types/statuses';
+import { ElementStatus } from 'types/elements';
const TextArea = ({
value,
diff --git a/src/client/hocs/Calculation/index.js b/src/client/hocs/Calculation/index.js
deleted file mode 100644
index 52b0585..0000000
--- a/src/client/hocs/Calculation/index.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import withButton from './withButton';
-import withComputedValue from './withComputedValue';
-import withLink from './withLink';
-import withTable from './withTable';
-import withValue from './withValue';
-
-export { withButton, withLink, withValue, withComputedValue, withTable };
diff --git a/src/client/hocs/Calculation/withTable.jsx b/src/client/hocs/Calculation/withTable.jsx
deleted file mode 100644
index 43298fc..0000000
--- a/src/client/hocs/Calculation/withTable.jsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { useTableOptions } from 'client/hooks/Calculation/useOptions';
-import { useTableStatus } from 'client/hooks/Calculation/useStatus';
-import { useTableValidation } from 'client/hooks/Calculation/useValidation';
-import { useTableValue } from 'client/hooks/Calculation/useValue';
-import { useStores } from 'client/hooks/useStores';
-import { observer } from 'mobx-react-lite';
-
-export default Table => props => {
- const { name: tableName, callbacks } = props;
- const ObservedTable = observer(Table);
- const { calculationStore } = useStores();
- const tableData = calculationStore.tables[tableName];
- return () => (
-
- );
-};
-
-const withTableValue = callbacks => Component => ({
- tableName,
- rowIndex,
- propName,
- validation,
- ...props
-}) =>
- observer(() => {
- const { value, setCurrentValue } = useTableValue({
- tableName,
- rowIndex,
- propName,
- columnCallback: callbacks?.[propName],
- });
- const { status } = useTableStatus({ tableName, rowIndex, propName });
- const { validateStatus, message } = useTableValidation({
- tableName,
- rowIndex,
- propName,
- validation,
- });
-
- const { options, filter } = useTableOptions({
- tableName,
- rowIndex,
- propName,
- });
-
- return (
-
- );
- });
diff --git a/src/client/hooks/Calculation/useValidation.js b/src/client/hooks/Calculation/useValidation.js
new file mode 100644
index 0000000..b913a49
--- /dev/null
+++ b/src/client/hooks/Calculation/useValidation.js
@@ -0,0 +1,62 @@
+import { INVALID_INPUT as INVALID_INPUT_MESSAGE } from 'core/constants/errorMessages';
+import { useEffect, useState } from 'react';
+import { useStores } from '../useStores';
+
+export const useValidation = ({ elementName, value }) => {
+ const [isValid, setValidation] = useState(undefined);
+ const { calculationStore } = useStores();
+
+ // get value from store
+ const validationStatus = calculationStore.validations[elementName];
+ useEffect(() => {
+ setValidation(validationStatus);
+ }, [validationStatus]);
+
+ useEffect(() => {
+ if (value === undefined || value === '') {
+ calculationStore.setValidation(elementName, undefined);
+ }
+ }, [value]);
+
+ return {
+ validateStatus: isValid === false ? 'error' : undefined,
+ message: isValid === false ? INVALID_INPUT_MESSAGE : undefined,
+ };
+};
+
+export const useTableValidation = ({
+ tableName,
+ rowIndex,
+ propName,
+ value,
+}) => {
+ const [isValid, setValidation] = useState(undefined);
+ const { calculationStore } = useStores();
+
+ const validationStatus =
+ calculationStore?.tables?.[tableName]?.rows?.[rowIndex]?.[propName]
+ ?.validation;
+ useEffect(() => {
+ setValidation(validationStatus);
+ }, [validationStatus]);
+
+ useEffect(() => {
+ if (value === undefined || value === '') {
+ calculationStore.setTableRows(
+ tableName,
+ rowIndex,
+ )([
+ {
+ [propName]: {
+ validation: undefined,
+ },
+ },
+ ]);
+ }
+ }, [value]);
+
+ return {
+ validateStatus: isValid === false ? 'error' : undefined,
+ message: isValid === false ? INVALID_INPUT_MESSAGE : undefined,
+ };
+};
diff --git a/src/client/hooks/Calculation/useValidation.ts b/src/client/hooks/Calculation/useValidation.ts
deleted file mode 100644
index 18bd7cc..0000000
--- a/src/client/hooks/Calculation/useValidation.ts
+++ /dev/null
@@ -1,147 +0,0 @@
-import { ValidateStatus } from 'antd/lib/form/FormItem';
-import { INVALID_INPUT as INVALID_INPUT_MESSAGE } from 'core/constants/errorMessages';
-import { ElementsNames } from 'core/types/Calculation/Store/elements';
-import {
- TableNames,
- TableValuesNames,
-} from 'core/types/Calculation/Store/tables';
-import { useEffect, useState } from 'react';
-import { useStores } from '../useStores';
-
-type TValidation = {
- errorMessage: string;
- validator: ((_: any) => boolean) | undefined;
-};
-interface IUseValidationArgs {
- elementName: ElementsNames;
- value: any;
- validation: TValidation;
-}
-
-interface IUseTableValidationArgs {
- tableName: TableNames;
- rowIndex: number;
- propName: TableValuesNames;
- value: any;
- validation: TValidation;
-}
-
-export const useValidation = ({
- elementName,
- value,
- validation,
-}: IUseValidationArgs) => {
- const { validator, errorMessage } = validation || {
- validator: undefined,
- errorMessage: undefined,
- };
- const [isValid, setValidation] = useState(undefined);
- const { calculationStore } = useStores();
-
- // inject value from store
- const validationStatus = calculationStore.validations[elementName];
- useEffect(() => {
- setValidation(validationStatus);
- }, [validationStatus]);
-
- // inner validation && set validation status to store
- useEffect(() => {
- if (value === undefined || value === '') {
- calculationStore.setValidation(elementName, undefined);
- } else {
- if (validator) {
- const validationResult = validator(value);
- calculationStore.setValidation(elementName, validationResult);
- }
- }
- }, [value]);
-
- const getValidateStatus = (): ValidateStatus | undefined => {
- if (isValid === undefined) {
- return undefined;
- }
- return isValid === false ? 'error' : 'success';
- };
-
- const getMessage = (): string | undefined => {
- if (isValid === false) {
- return errorMessage || INVALID_INPUT_MESSAGE;
- }
- };
-
- return {
- isValid,
- validateStatus: getValidateStatus(),
- message: getMessage(),
- };
-};
-
-export const useTableValidation = ({
- tableName,
- rowIndex,
- propName,
- value,
- validation,
-}: IUseTableValidationArgs) => {
- const { validator, errorMessage } = validation || {
- validator: undefined,
- errorMessage: undefined,
- };
- const [isValid, setValidation] = useState(undefined);
- const { calculationStore } = useStores();
-
- const validationStatus =
- calculationStore?.tables?.[tableName]?.rows?.[rowIndex]?.[propName]
- ?.validation;
- useEffect(() => {
- setValidation(validationStatus);
- }, [validationStatus]);
-
- useEffect(() => {
- if (value === undefined || value === '') {
- calculationStore.setTableRows(
- tableName,
- rowIndex,
- )([
- {
- [propName]: {
- validation: undefined,
- },
- },
- ]);
- } else {
- if (validator) {
- const validationResult = validator(value);
- calculationStore.setTableRows(
- tableName,
- rowIndex,
- )([
- {
- [propName]: {
- validation: validationResult,
- },
- },
- ]);
- }
- }
- }, [value]);
-
- const getValidateStatus = (): ValidateStatus | undefined => {
- if (isValid === undefined) {
- return undefined;
- }
- return isValid === false ? 'error' : 'success';
- };
-
- const getMessage = (): string | undefined => {
- if (isValid === false) {
- return errorMessage || INVALID_INPUT_MESSAGE;
- }
- };
-
- return {
- isValid,
- validateStatus: getValidateStatus(),
- message: getMessage(),
- };
-};
diff --git a/src/client/stores/CalculationStore/Data/values.js b/src/client/stores/CalculationStore/Data/values.js
index ba26846..6d4cd52 100644
--- a/src/client/stores/CalculationStore/Data/values.js
+++ b/src/client/stores/CalculationStore/Data/values.js
@@ -1,4 +1,4 @@
-import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
+import { getValueName } from 'client/Containers/Calculation/Elements/tools';
import initialFilters, {
noResetValueElements
} from 'client/stores/CalculationStore/config/initialFilters';
diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/checkValidation.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/checkValidation.ts
index 69d21f5..39fef04 100644
--- a/src/client/stores/CalculationStore/Effects/actions/calculate/checkValidation.ts
+++ b/src/client/stores/CalculationStore/Effects/actions/calculate/checkValidation.ts
@@ -1,8 +1,8 @@
import elementsTitles, {
- tablesTitles,
-} from 'client/Containers/Calculation/lib/elements/titles';
+ tablesTitles
+} from 'client/Containers/Calculation/Elements/titles';
+import { TableNames } from 'client/Containers/Calculation/types/tables';
import { ICalculationStore } from 'core/types/Calculation/Store';
-import { TableNames } from 'core/types/Calculation/Store/tables';
import { omit } from 'lodash';
import { toJS } from 'mobx';
diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/index.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/index.ts
index 731aa37..6f5930f 100644
--- a/src/client/stores/CalculationStore/Effects/actions/calculate/index.ts
+++ b/src/client/stores/CalculationStore/Effects/actions/calculate/index.ts
@@ -2,8 +2,8 @@ import { message } from 'antd';
import { openNotification } from 'client/Elements/Notification';
import CalculationService from 'core/services/CalculationService';
import { ICalculationStore } from 'core/types/Calculation/Store';
-import { resultsValues } from 'core/types/Calculation/Store/values';
-import { ElementStatus } from 'core/types/statuses';
+import { ValuesNames } from 'core/types/Calculation/Store/values';
+import { ElementStatus } from 'types/elements';
import checkValidation from './checkValidation';
import prepareCalculationData from './prepareData';
import results from './results';
@@ -11,11 +11,33 @@ import validate from './validate';
const BUTTONS_TIMEOUT = 500;
+export const RESULT_VALUES: ValuesNames[] = [
+ 'resultTotalGraphwithNDS',
+ 'resultPlPrice',
+ 'resultPriceUpPr',
+ 'resultIRRGraphPerc',
+ 'resultIRRNominalPerc',
+ 'resultInsKasko',
+ 'resultInsOsago',
+ 'resultDopProdSum',
+ 'resultFirstPayment',
+ 'resultLastPayment',
+ 'resultTerm',
+ 'resultAB_FL',
+ 'resultAB_UL',
+ 'resultBonusMPL',
+ 'resultDopMPLLeasing',
+ 'resultBonusDopProd',
+];
+
export default function (this: ICalculationStore) {
const cleanResults = () => {
- for (let resultValue of resultsValues) {
- this.setValue(resultValue, '');
- }
+ this.setValues(
+ RESULT_VALUES.reduce((acc, v) => {
+ acc[v] = '';
+ return acc;
+ }, {}),
+ );
};
const blockButtons = () => {
diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts
index c0e37c8..816de37 100644
--- a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts
+++ b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts
@@ -1,12 +1,15 @@
import valuesConstants from 'core/constants/values';
+import {
+ PaymentRow,
+ PreparedValues,
+} from 'core/services/CalculationService/types/prepared';
+import { PreparedData } from 'core/services/CalculationService/types/request';
import { currentDate } from 'core/tools/date';
import { NIL } from 'core/tools/uuid';
-import { PaymentRow, PreparedValues } from 'core/types/Calculation/Prepare';
-import { IPreparedData } from 'core/types/Calculation/Requests';
import { ICalculationStore } from 'core/types/Calculation/Store';
import { convertPrice } from '../../lib/tools';
-export default function (this: ICalculationStore): IPreparedData {
+export default function (this: ICalculationStore): PreparedData {
const { values, options, tables } = this;
const preparedPaymentsRows: PaymentRow[] = Array.from(
@@ -97,9 +100,8 @@ export default function (this: ICalculationStore): IPreparedData {
(0.0234 / ((1 - 1 / 1.0234) ^ ((preparedValues.nmper as number) - 2)))
: 1;
preparedValues.loanRate = parseFloat(values.creditRate) / 100;
- preparedValues.loanRatePeriod = this.getOption(
- 'selectRate',
- )?.evo_credit_period;
+ preparedValues.loanRatePeriod =
+ this.getOption('selectRate')?.evo_credit_period;
preparedValues.balanceHolder = values.balanceHolder;
preparedValues.dogDate = preparedValues.calcDate;
preparedValues.paymentDateNew = undefined;
@@ -112,12 +114,10 @@ export default function (this: ICalculationStore): IPreparedData {
(values.lastPaymentRub as number) / (1 + valuesConstants.VAT);
preparedValues.subsidySum =
parseInt(values.subsidySum) / (1 + valuesConstants.VAT);
- preparedValues.subsidyPaymentNumber = this.getOption(
- 'selectSubsidy',
- )?.evo_get_subsidy_payment;
- preparedValues.fuelCardSum = this.getOption(
- 'selectFuelCard',
- )?.evo_graph_price_withoutnds;
+ preparedValues.subsidyPaymentNumber =
+ this.getOption('selectSubsidy')?.evo_get_subsidy_payment;
+ preparedValues.fuelCardSum =
+ this.getOption('selectFuelCard')?.evo_graph_price_withoutnds;
preparedValues.scheduleOfPayments = values.graphType;
preparedValues.comissionRub =
(values.comissionRub as number) / (1 + valuesConstants.VAT);
diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts
index a70f485..99a48f4 100644
--- a/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts
+++ b/src/client/stores/CalculationStore/Effects/actions/calculate/results.ts
@@ -1,18 +1,20 @@
+import { Table } from 'client/Containers/Calculation/types/tables';
import valuesConstants from 'core/constants/values';
-import { IPreparedData } from 'core/types/Calculation/Requests';
-import { IGetCalculationResponse } from 'core/types/Calculation/Responses';
+import {
+ GetCalculationResponse,
+ PreparedData,
+} from 'core/services/CalculationService/types/request';
import { ICalculationStore } from 'core/types/Calculation/Store';
-import { ITableCell, TableProps } from 'core/types/Calculation/Store/tables';
export default {
showResultsTable: function (
this: ICalculationStore,
- preparedData: IPreparedData,
- res: IGetCalculationResponse,
+ preparedData: PreparedData,
+ res: GetCalculationResponse,
) {
if (preparedData.preparedValues.nmper) {
const { sumWithVatColumn, vatColumn, sumRepaymentColumn } = res.columns;
- const results: TableProps[] = [];
+ const results: Table['rows'] = [];
for (let i = 0; i < preparedData.preparedValues.nmper; i++) {
const balanceHolder = this.getValue('balanceHolder');
@@ -44,8 +46,8 @@ export default {
},
showResults: function (
this: ICalculationStore,
- preparedData: IPreparedData,
- res: IGetCalculationResponse,
+ preparedData: PreparedData,
+ res: GetCalculationResponse,
) {
const { sumWithVatColumn } = res.columns;
this.setValue(
@@ -144,7 +146,7 @@ export default {
},
setResValues: function (
this: ICalculationStore,
- res: IGetCalculationResponse,
+ res: GetCalculationResponse,
) {
this.setValue(
'IRR_Perc',
diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts
index f2affab..4bfff21 100644
--- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts
+++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts
@@ -1,21 +1,18 @@
-import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
+import { getValueName } from 'client/Containers/Calculation/Elements/tools';
+import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { pipe } from 'core/tools/func';
import { ICalculationStore } from 'core/types/Calculation/Store';
-import {
- ElementsNames,
- TElements,
-} from 'core/types/Calculation/Store/elements';
import CONDITIONS from 'core/validation/conditions';
import {
convertToValidationResult,
getValue,
showValidationMessages,
validate,
- ValidationCondition,
+ ValidationCondition
} from 'core/validation/validate';
import { isNil } from 'lodash';
-const customConditions: TElements = {
+const customConditions: Partial> = {
selectLeaseObjectCategory: calculationStore => {
const leaseObjectType = calculationStore.getOption('selectLeaseObjectType');
const leaseObjectCategory = calculationStore.getValue(
@@ -82,11 +79,8 @@ const customConditions: TElements = {
return { isValid: true };
},
radioRequirementTelematic: calculationStore => {
- const {
- telematic,
- tracker,
- requirementTelematic,
- } = calculationStore.getValues([
+ const { telematic, tracker, requirementTelematic } =
+ calculationStore.getValues([
'telematic',
'tracker',
'requirementTelematic',
@@ -107,10 +101,9 @@ const customConditions: TElements = {
return { isValid: true };
},
selectTownRegistration: calculationStore => {
- const {
- townRegistration,
- objectRegistration,
- } = calculationStore.getValues(['townRegistration', 'objectRegistration']);
+ const { townRegistration, objectRegistration } = calculationStore.getValues(
+ ['townRegistration', 'objectRegistration'],
+ );
if (objectRegistration === 100000000 && !townRegistration) {
return {
isValid: false,
@@ -141,7 +134,9 @@ const customConditions: TElements = {
},
};
-const elementsValidations: TElements = {
+const elementsValidations: Partial<
+ Record boolean>
+> = {
selectLead: CONDITIONS.IS_NULL,
selectProduct: CONDITIONS.IS_NULL,
selectSupplierCurrency: CONDITIONS.IS_NULL,
@@ -163,36 +158,36 @@ const elementsValidations: TElements = {
tbxLeaseObjectCount: CONDITIONS.LESS_OR_EQUALS_ZERO,
};
-const elementsConditions = (Object.keys(
- elementsValidations,
-) as ElementsNames[]).reduce(
- (ac: TElements, elementName) => {
- ac[elementName] = pipe(
- getValue,
- elementsValidations[elementName],
- convertToValidationResult,
- );
- return ac;
+const elementsConditions = (
+ Object.keys(elementsValidations) as ElementsNames[]
+).reduce(
+ (ac: Partial>, elementName) => {
+ const validator = elementsValidations[elementName];
+ if (validator)
+ ac[elementName] = pipe(getValue, validator, convertToValidationResult);
+ return ac;
},
{},
);
-const entityElementsConditions = ([
+const entityElementsConditions = (
+ [
'selectIndAgentRewardCondition',
'selectCalcBrokerRewardCondition',
'selectFinDepartmentRewardCondtion',
-] as ElementsNames[]).reduce(
- (ac: TElements, elementName) => {
- const valueName = getValueName(elementName);
- ac[elementName] = (calculationStore, elementName) => {
- if (isNil(calculationStore.getValue(valueName))) {
- return { isValid: true };
- }
- return {
- isValid: calculationStore.getOption(elementName) !== undefined,
+ ] as ElementsNames[]
+).reduce(
+ (ac: Partial>, elementName) => {
+ const valueName = getValueName(elementName);
+ ac[elementName] = (calculationStore, elementName) => {
+ if (isNil(calculationStore.getValue(valueName))) {
+ return { isValid: true };
+ }
+ return {
+ isValid: calculationStore.getOption(elementName) !== undefined,
+ };
};
- };
- return ac;
+ return ac;
},
{},
);
diff --git a/src/client/stores/CalculationStore/Effects/actions/createKP.ts b/src/client/stores/CalculationStore/Effects/actions/createKP.ts
index 8177bc3..3613db1 100644
--- a/src/client/stores/CalculationStore/Effects/actions/createKP.ts
+++ b/src/client/stores/CalculationStore/Effects/actions/createKP.ts
@@ -3,12 +3,12 @@ import { AxiosError } from 'axios';
import { openNotification } from 'client/Elements/Notification';
import UserStore from 'client/stores/UserStore';
import { CRM_PROXY_URL } from 'core/constants/urls';
-import { getQuotesByLeadQuery } from 'core/graphql/query/crm/quote';
import CrmService from 'core/services/CrmService';
+import { quotesByLeadQuery } from 'core/services/CrmService/graphql/query/quote';
+import { IQuote } from 'core/services/CrmService/types/entities';
import { ICalculationStore } from 'core/types/Calculation/Store';
-import { IQuote } from 'core/types/Entities/crmEntities';
import { toJS } from 'mobx';
-import customValues from '../lib/customValues';
+import { insKaskoPriceLeasePeriod } from '../computed';
import calculate from './calculate';
async function composeRequest(this: ICalculationStore) {
@@ -32,10 +32,9 @@ async function composeRequest(this: ICalculationStore) {
})),
);
- const insKaskoPriceLeasePeriod =
- customValues.insKaskoPriceLeasePeriod.call(this);
+ const insKaskoPriceLeasePeriodValue = insKaskoPriceLeasePeriod.call(this);
const calculationValues = Object.assign({}, toJS(this.values), {
- insKaskoPriceLeasePeriod,
+ insKaskoPriceLeasePeriod: insKaskoPriceLeasePeriodValue,
});
const domainname = UserStore.getDomainName();
@@ -71,7 +70,7 @@ export default async function (this: ICalculationStore) {
const leadid = this.getValue('lead');
CrmService.getCRMOptions<'quotes', IQuote>({
- query: getQuotesByLeadQuery,
+ query: quotesByLeadQuery,
variables: {
leadid,
},
diff --git a/src/client/stores/CalculationStore/Effects/autorun.ts b/src/client/stores/CalculationStore/Effects/autorun.ts
index 0767a80..60cbe60 100644
--- a/src/client/stores/CalculationStore/Effects/autorun.ts
+++ b/src/client/stores/CalculationStore/Effects/autorun.ts
@@ -1,84 +1,9 @@
import { openNotification } from 'client/Elements/Notification';
import { IAutorunEffect } from 'core/types/Calculation/Store/effect';
-import { ElementStatus } from 'core/types/statuses';
+import { ElementStatus } from 'types/elements';
import { convertPrice } from './lib/tools';
const autorunEffects: IAutorunEffect[] = [
- calculationStore => () => {
- const { contactClient, contact } = calculationStore.values;
- if (contactClient || contact) {
- calculationStore.setValidation('selectContactClient', true);
- calculationStore.setValidation('tbxContact', true);
- }
- },
- calculationStore => () => {
- const { newClient, account } = calculationStore.values;
- if (newClient || account) {
- calculationStore.setValidation('tbxNewClient', true);
- calculationStore.setValidation('selectAccount', true);
- }
- },
- calculationStore => () => {
- const { commentLead } = calculationStore.values;
- if (commentLead) {
- calculationStore.setValidation('tbxCommentLead', true);
- }
- },
- calculationStore => () => {
- const { phoneNumber } = calculationStore.values;
- if (phoneNumber) {
- calculationStore.setValidation('tbxPhoneNumber', true);
- }
- },
-
- calculationStore => () => {
- const { channel } = calculationStore.values;
- if (channel) {
- calculationStore.setValidation('selectChannel', true);
-
- switch (channel) {
- case 100000000: {
- const { supplier, agent } = calculationStore.values;
- if (supplier) {
- calculationStore.setValidation('selectSupplier', true);
- }
- if (agent) {
- calculationStore.setValidation('selectAgent', true);
- }
- break;
- }
- case 100000001: {
- const { supplier, finDepartment } = calculationStore.values;
- if (supplier) {
- calculationStore.setValidation('selectSupplier', true);
- }
- if (finDepartment) {
- calculationStore.setValidation('selectFinDepartment', true);
- }
- break;
- }
-
- case 100000002: {
- const { agent } = calculationStore.values;
- if (agent) {
- calculationStore.setValidation('selectAgent', true);
- }
- break;
- }
- case 100000003: {
- const { broker } = calculationStore.values;
- if (broker) {
- calculationStore.setValidation('selectBroker', true);
- }
- break;
- }
- case 100000004:
- default: {
- break;
- }
- }
- }
- },
// calculationStore => () => {
// const {
// leaseObjectCategory,
@@ -131,11 +56,8 @@ const autorunEffects: IAutorunEffect[] = [
ElementStatus.Default,
);
- const {
- engineVolume,
- engineType,
- leaseObjectMotorPower,
- } = calculationStore.values;
+ const { engineVolume, engineType, leaseObjectMotorPower } =
+ calculationStore.values;
if (engineVolume <= 0) {
calculationStore.setValidation('tbxEngineVolume', false);
@@ -194,16 +116,13 @@ const autorunEffects: IAutorunEffect[] = [
calculationStore.setValue('subsidySum', subsidy?.evo_subsidy_summ);
} else {
if (subsidy?.evo_max_subsidy_summ) {
- const {
- leaseObjectPrice,
- supplierDiscountRub,
- } = calculationStore.values;
+ const { leaseObjectPrice, supplierDiscountRub } =
+ calculationStore.values;
const supplierCurrency = calculationStore.getOption(
'selectSupplierCurrency',
);
- const evo_currencychanges = calculationStore.getStaticData(
- 'evo_currencychange',
- );
+ const evo_currencychanges =
+ calculationStore.getStaticData('evo_currencychange');
const evo_currencychange = evo_currencychanges.find(
x =>
x.evo_ref_transactioncurrency ===
diff --git a/src/client/stores/CalculationStore/Effects/computed.ts b/src/client/stores/CalculationStore/Effects/computed.ts
index 1c1432a..be48a1d 100644
--- a/src/client/stores/CalculationStore/Effects/computed.ts
+++ b/src/client/stores/CalculationStore/Effects/computed.ts
@@ -1,6 +1,5 @@
import { ICalculationStore } from 'core/types/Calculation/Store';
-import { TValues } from 'core/types/Calculation/Store/values';
-import customValues from './lib/customValues';
+import { ComputedValuesNames } from 'core/types/Calculation/Store/values';
const LEASE_OBJECT_RISK = {
100000000: 'Низкий',
@@ -8,9 +7,32 @@ const LEASE_OBJECT_RISK = {
100000002: 'Высокий',
};
-const computedEffects: TValues<
- (this: ICalculationStore) => string | number | undefined
-> = {
+type ComputedEffect = (this: ICalculationStore) => string | number | undefined;
+
+export const insKaskoPriceLeasePeriod: ComputedEffect = function () {
+ const { leasingPeriod } = this.values;
+ const { rows } = this.tables.tableInsurance;
+ const kaskoRow = rows[1];
+ const dgoRow = rows[2];
+ const nsRow = rows[3];
+
+ let res = 0;
+ if (
+ leasingPeriod &&
+ leasingPeriod > 15 &&
+ kaskoRow?.insTerm?.value === 100000001
+ ) {
+ res =
+ (leasingPeriod / 12) *
+ (kaskoRow?.insCost?.value +
+ dgoRow?.insCost?.value +
+ nsRow?.insCost?.value);
+ }
+
+ return res;
+};
+
+const computedEffects: Record = {
leaseObjectRiskName: function () {
const configuration = this.getOption('selectConfiguration');
if (configuration) {
@@ -25,9 +47,7 @@ const computedEffects: TValues<
if (evo_leasingobject_risk)
return LEASE_OBJECT_RISK[evo_leasingobject_risk];
},
- insKaskoPriceLeasePeriod: function () {
- return customValues.insKaskoPriceLeasePeriod.call(this).toFixed(2);
- },
+ insKaskoPriceLeasePeriod,
irrInfo: function () {
const tarif = this.getOption('selectTarif');
if (tarif && tarif.evo_min_irr && tarif.evo_max_irr) {
diff --git a/src/client/stores/CalculationStore/Effects/lib/customValues.js b/src/client/stores/CalculationStore/Effects/lib/customValues.js
deleted file mode 100644
index bc39424..0000000
--- a/src/client/stores/CalculationStore/Effects/lib/customValues.js
+++ /dev/null
@@ -1,22 +0,0 @@
-export default {
- insKaskoPriceLeasePeriod() {
- const { leasingPeriod } = this.values;
- const { rows } = this.tables.tableInsurance;
- const kaskoRow = rows[1];
- const dgoRow = rows[2];
- const nsRow = rows[3];
-
- let res = 0;
- if (
- leasingPeriod &&
- leasingPeriod > 15 &&
- kaskoRow.insTerm.value === 100000001
- ) {
- res =
- (leasingPeriod / 12) *
- (kaskoRow.insCost.value + dgoRow.insCost.value + nsRow.insCost.value);
- }
-
- return res;
- },
-};
diff --git a/src/client/stores/CalculationStore/Effects/reactions/eltReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/eltReactions.ts
index 0c987e8..e6fe85e 100644
--- a/src/client/stores/CalculationStore/Effects/reactions/eltReactions.ts
+++ b/src/client/stores/CalculationStore/Effects/reactions/eltReactions.ts
@@ -1,15 +1,15 @@
import { message } from 'antd';
-import { resetFields as kaskoResetFields } from 'client/Components/Calculation/ELT/Content/Kasko/lib/validation';
-import { cancelRequests } from 'client/Components/Calculation/ELT/Content/lib/requests';
+import { resetFields as kaskoResetFields } from 'client/Containers/Calculation/Components/ELT/Kasko/lib/validation';
+import { cancelRequests } from 'client/Containers/Calculation/Components/ELT/lib/requests';
import {
initIns,
- resetIns,
-} from 'client/Components/Calculation/ELT/Content/lib/resetIns';
-import { resetFields as osagoResetFields } from 'client/Components/Calculation/ELT/Content/Osago/lib/validation';
-import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
+ resetIns
+} from 'client/Containers/Calculation/Components/ELT/lib/resetIns';
+import { resetFields as osagoResetFields } from 'client/Containers/Calculation/Components/ELT/Osago/lib/validation';
+import { getValueName } from 'client/Containers/Calculation/Elements/tools';
+import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess';
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
-import { ElementsNames } from 'core/types/Calculation/Store/elements';
import { ICalculationStore } from 'core/types/Calculation/Store/index';
import { Process } from 'core/types/Calculation/Store/process';
@@ -45,70 +45,72 @@ const eltReactions: IReactionEffect[] = [
},
}),
...resetConf.map(
- ({ insType, resetFields }) => (
- calculationStore: ICalculationStore,
- calculationProcess: TCalculationProcess,
- ) => ({
- expression: () => {
- return calculationStore.getValues(
- (resetFields as ElementsNames[]).map(getValueName),
- );
- },
- effect: () => {
- cancelRequests(insType);
+ ({ insType, resetFields }) =>
+ (
+ calculationStore: ICalculationStore,
+ calculationProcess: TCalculationProcess,
+ ) => ({
+ expression: () => {
+ return calculationStore.getValues(
+ (resetFields as ElementsNames[]).map(getValueName),
+ );
+ },
+ effect: () => {
+ cancelRequests(insType);
- if (
- calculationProcess.hasProcess(Process.Init) ||
- calculationProcess.hasProcess(Process.ELT) ||
- calculationProcess.hasProcess(Process.LoadKp)
- ) {
- return;
- }
+ if (
+ calculationProcess.hasProcess(Process.Init) ||
+ calculationProcess.hasProcess(Process.ELT) ||
+ calculationProcess.hasProcess(Process.LoadKp)
+ ) {
+ return;
+ }
- const { ELTStore } = calculationStore.stores;
- if (ELTStore[insType]?.isReseted()) {
- return;
- }
- message.warn({ content: RESET_MESSAGES[insType] });
- resetIns.call(calculationStore, insType);
- },
- }),
+ const { ELTStore } = calculationStore.stores;
+ if (ELTStore[insType]?.isReseted()) {
+ return;
+ }
+ message.warn({ content: RESET_MESSAGES[insType] });
+ resetIns.call(calculationStore, insType);
+ },
+ }),
),
...resetConf.map(
- ({ insType, tableRowNumber }) => (
- calculationStore: ICalculationStore,
- calculationProcess: TCalculationProcess,
- ) => ({
- expression: () => {
- return [
- ...['insuranceCompany', 'insCost'].map(
- fieldName =>
- calculationStore.tables.tableInsurance.rows[tableRowNumber][
- fieldName
- ].value,
- ),
- ];
- },
- effect: () => {
- cancelRequests(insType);
+ ({ insType, tableRowNumber }) =>
+ (
+ calculationStore: ICalculationStore,
+ calculationProcess: TCalculationProcess,
+ ) => ({
+ expression: () => {
+ return [
+ ...['insuranceCompany', 'insCost'].map(
+ fieldName =>
+ calculationStore.tables.tableInsurance.rows[tableRowNumber][
+ fieldName
+ ].value,
+ ),
+ ];
+ },
+ effect: () => {
+ cancelRequests(insType);
- if (
- calculationProcess.hasProcess(Process.Init) ||
- calculationProcess.hasProcess(Process.ELT) ||
- calculationProcess.hasProcess(Process.LoadKp)
- ) {
- return;
- }
+ if (
+ calculationProcess.hasProcess(Process.Init) ||
+ calculationProcess.hasProcess(Process.ELT) ||
+ calculationProcess.hasProcess(Process.LoadKp)
+ ) {
+ return;
+ }
- const { ELTStore } = calculationStore.stores;
- if (ELTStore[insType]?.isReseted()) {
- return;
- }
- message.warn({ content: RESET_MESSAGES[insType] });
- resetIns.call(calculationStore, insType);
- },
- }),
+ const { ELTStore } = calculationStore.stores;
+ if (ELTStore[insType]?.isReseted()) {
+ return;
+ }
+ message.warn({ content: RESET_MESSAGES[insType] });
+ resetIns.call(calculationStore, insType);
+ },
+ }),
),
];
diff --git a/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts
index e633d6a..481f4f6 100644
--- a/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts
+++ b/src/client/stores/CalculationStore/Effects/reactions/gibddReactions.ts
@@ -1,20 +1,18 @@
import { gql } from '@apollo/client';
-import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
+import { getValueName } from 'client/Containers/Calculation/Elements/tools';
+import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { openNotification } from 'client/Elements/Notification';
import _1CService from 'core/services/1CService';
import CrmService from 'core/services/CrmService';
+import { IEvoTown } from 'core/services/CrmService/types/entities';
import { currentDate } from 'core/tools/date';
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
-import {
- ElementsNames,
- TElements,
-} from 'core/types/Calculation/Store/elements';
import { Process } from 'core/types/Calculation/Store/process';
-import { IEvoTown } from 'core/types/Entities/crmEntities';
-import { ElementStatus } from 'core/types/statuses';
import { get } from 'lodash';
+import { ElementStatus } from 'types/elements';
-const v: TElements = {
+//TODO: beautify
+const v = {
tbxVehicleTaxInYear: { value: 0, validator: value => value === 0 },
radioTypePTS: { value: null, validator: value => value === null },
// selectObjectRegionRegistration: {
diff --git a/src/client/stores/CalculationStore/Effects/reactions/linkReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/linkReactions.ts
index 96a73dd..9fb50af 100644
--- a/src/client/stores/CalculationStore/Effects/reactions/linkReactions.ts
+++ b/src/client/stores/CalculationStore/Effects/reactions/linkReactions.ts
@@ -1,5 +1,5 @@
+import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
-import { ElementsNames } from 'core/types/Calculation/Store/elements';
import { LinksNames } from 'core/types/Calculation/Store/links';
export default ([
diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts
index ef13aa0..37dab16 100644
--- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts
+++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts
@@ -1,37 +1,33 @@
import { message } from 'antd';
-import { resetIns } from 'client/Components/Calculation/ELT/Content/lib/resetIns';
-import { numberElementsProps } from 'client/Containers/Calculation/lib/elements/elementsProps';
-import {
- getTitle,
- getValueName
-} from 'client/Containers/Calculation/lib/elements/tools';
-import { elementsValues } from 'client/Containers/Calculation/lib/elements/values';
+import { resetIns } from 'client/Containers/Calculation/Components/ELT/lib/resetIns';
+import { numberElementsProps } from 'client/Containers/Calculation/Elements/props/common';
+import { getTitle, getValueName } from 'client/Containers/Calculation/Elements/tools';
+import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { openNotification } from 'client/Elements/Notification';
import initialValues from 'client/stores/CalculationStore/config/initialValues';
-import {
- getMainOptionsForQuote,
- getQuoteQuery,
- getSecondaryOptionsForQuote,
- getSingleOptionsForQuote
-} from 'core/graphql/query/crm/quote';
import CrmService from 'core/services/CrmService';
-import { TOptionizedEntity } from 'core/services/CrmService/types/common';
-import { currentISODate } from 'core/tools/date';
-import { NIL } from 'core/tools/uuid';
-import { IReactionEffect } from 'core/types/Calculation/Store/effect';
-import { ElementsNames } from 'core/types/Calculation/Store/elements';
-import { Process } from 'core/types/Calculation/Store/process';
-import { TValues, ValuesNames } from 'core/types/Calculation/Store/values';
import {
+ mainOptionsForQuoteQuery,
+ quoteQuery,
+ secondaryOptionsForQuoteQuery,
+ singleOptionsForQuoteQuery
+} from 'core/services/CrmService/graphql/query/quote';
+import { TOptionizedEntity } from 'core/services/CrmService/types/common';
+import {
+ CRMEntity,
IAccount,
IEvoGraph,
IEvoTown,
- IQuote,
- TCRMEntity
-} from 'core/types/Entities/crmEntities';
-import { ElementStatus } from 'core/types/statuses';
+ IQuote
+} from 'core/services/CrmService/types/entities';
+import { currentISODate } from 'core/tools/date';
+import { NIL } from 'core/tools/uuid';
+import { IReactionEffect } from 'core/types/Calculation/Store/effect';
+import { Process } from 'core/types/Calculation/Store/process';
import { get, invert, isEqual, isNil } from 'lodash';
-import { getKpPropName } from './mapKpToValues';
+import { ElementStatus } from 'types/elements';
+import { getValuesFromKP } from './mapKpToValues';
+
const map_add_product_types_to_values = {
technicalCard: 100000000,
@@ -87,7 +83,7 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
const { calculationProcess } = calculationStore.stores;
CrmService.getCRMEntities<'quote', IQuote>({
- query: getQuoteQuery,
+ query: quoteQuery,
variables: {
quoteId,
},
@@ -95,397 +91,415 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
.then(async ({ quote }) => {
if (!quote) throw new Error('no quote');
calculationProcess.addProcess(Process.LoadKp);
- if (!Array.isArray(quote)) {
- const newValues: TValues = Object.assign(
- {},
- ...(Object.values(elementsValues) as ValuesNames[]).map(
- valueName => ({
- //@ts-ignore
- [valueName]: quote[getKpPropName(valueName)],
- }),
- ),
- );
- const mainOptions = await CrmService.getCRMOptions<
- ElementsNames,
- TCRMEntity
+ const newValues = getValuesFromKP(quote);
+
+ const mainOptions = await CrmService.getCRMOptions<
+ ElementsNames,
+ CRMEntity
+ >({
+ query: mainOptionsForQuoteQuery,
+ variables: {
+ statecode: 0,
+ evo_brandid: quote.evo_brandid || NIL,
+ evo_modelid: quote.evo_modelid || NIL,
+ salonaccountid: quote.evo_supplier_accountid || NIL,
+ currentDate: currentISODate,
+ dealer_person_accountid: quote.evo_dealer_person_accountid || NIL,
+ dealer_broker_accountid: quote.evo_dealer_broker_accountid || NIL,
+ // ind_agent_accountid: quote.evo_agent_accountid || NIL,
+ double_agent_accountid: quote.evo_double_agent_accountid || NIL,
+ // broker_accountid: quote.evo_broker_accountid || NIL,
+ // findepartment_accountid:
+ // quote.evo_fin_department_accountid || NIL,
+ evo_gps_brandid: quote.evo_gps_brandid || NIL,
+ evo_regionid: quote.evo_regionid || NIL,
+ evo_legal_regionid: quote.evo_legal_regionid || NIL,
+ evo_agency_agreementid_param: { has: true },
+ },
+ });
+
+ // selectDealerBroker query
+ let selectDealerBroker: TOptionizedEntity[] = [];
+ const dealer_broker_accountid =
+ mainOptions?.selectDealerPerson &&
+ mainOptions?.selectDealerPerson?.length > 0 &&
+ mainOptions.selectDealerPerson[0].evo_broker_accountid;
+ if (dealer_broker_accountid) {
+ const selectDealerBrokerRes = await CrmService.getCRMOptions<
+ 'selectDealerBroker',
+ IAccount
>({
- query: getMainOptionsForQuote,
+ query: singleOptionsForQuoteQuery,
variables: {
- statecode: 0,
- evo_brandid: quote.evo_brandid || NIL,
- evo_modelid: quote.evo_modelid || NIL,
- salonaccountid: quote.evo_supplier_accountid || NIL,
- currentDate: currentISODate,
- dealer_person_accountid: quote.evo_dealer_person_accountid || NIL,
- dealer_broker_accountid: quote.evo_dealer_broker_accountid || NIL,
- // ind_agent_accountid: quote.evo_agent_accountid || NIL,
- double_agent_accountid: quote.evo_double_agent_accountid || NIL,
- // broker_accountid: quote.evo_broker_accountid || NIL,
- // findepartment_accountid:
- // quote.evo_fin_department_accountid || NIL,
- evo_gps_brandid: quote.evo_gps_brandid || NIL,
- evo_regionid: quote.evo_regionid || NIL,
- evo_legal_regionid: quote.evo_legal_regionid || NIL,
- evo_agency_agreementid_param: { has: true },
+ dealer_broker_accountid,
},
});
+ if (selectDealerBrokerRes?.selectDealerBroker)
+ selectDealerBroker = selectDealerBrokerRes.selectDealerBroker;
+ }
+ // selectDealerBroker query
- // selectDealerBroker query
- let selectDealerBroker: TOptionizedEntity[] = [];
- const dealer_broker_accountid =
- mainOptions?.selectDealerPerson &&
- mainOptions?.selectDealerPerson?.length > 0 &&
- mainOptions.selectDealerPerson[0].evo_broker_accountid;
- if (dealer_broker_accountid) {
- const selectDealerBrokerRes = await CrmService.getCRMOptions<
- 'selectDealerBroker',
- IAccount
- >({
- query: getSingleOptionsForQuote,
- variables: {
- dealer_broker_accountid,
- },
- });
- if (selectDealerBrokerRes?.selectDealerBroker)
- selectDealerBroker = selectDealerBrokerRes.selectDealerBroker;
- }
- // selectDealerBroker query
+ calculationStore.applyOptions({
+ ...mainOptions,
+ selectDealerBroker: selectDealerBroker,
+ });
- calculationStore.applyOptions({
- ...mainOptions,
- selectDealerBroker: selectDealerBroker,
- });
+ // agents
+ //TODO: refactor
+ const { indAgent, calcBroker, calcFinDepartment } =
+ calculationStore.values;
+ let {
+ indAgentRewardCondition,
+ indAgentRewardSumm,
+ calcBrokerRewardCondition,
+ calcBrokerRewardSum,
+ finDepartmentRewardCondtion,
+ finDepartmentRewardSumm,
+ } = calculationStore.values;
+ if (indAgent === quote.evo_agent_accountid) {
+ indAgentRewardCondition = quote.evo_agent_reward_conditionid;
+ indAgentRewardSumm = quote.evo_agent_reward_total;
+ }
- // agents
- //TODO: refactor
- const { indAgent, calcBroker, calcFinDepartment } =
- calculationStore.values;
- let {
- indAgentRewardCondition,
- indAgentRewardSumm,
- calcBrokerRewardCondition,
- calcBrokerRewardSum,
- finDepartmentRewardCondtion,
- finDepartmentRewardSumm,
- } = calculationStore.values;
- if (indAgent === quote.evo_agent_accountid) {
- indAgentRewardCondition = quote.evo_agent_reward_conditionid;
- indAgentRewardSumm = quote.evo_agent_reward_total;
- }
+ if (calcBroker === quote.evo_broker_accountid) {
+ calcBrokerRewardCondition = quote.evo_broker_reward_conditionid;
+ calcBrokerRewardSum = quote.evo_broker_reward_total;
+ }
- if (calcBroker === quote.evo_broker_accountid) {
- calcBrokerRewardCondition = quote.evo_broker_reward_conditionid;
- calcBrokerRewardSum = quote.evo_broker_reward_total;
- }
+ if (calcFinDepartment === quote.evo_fin_department_accountid) {
+ finDepartmentRewardCondtion =
+ quote.evo_fin_department_reward_conditionid;
+ finDepartmentRewardSumm = quote.evo_fin_department_reward_total;
+ }
- if (calcFinDepartment === quote.evo_fin_department_accountid) {
- finDepartmentRewardCondtion =
- quote.evo_fin_department_reward_conditionid;
- finDepartmentRewardSumm = quote.evo_fin_department_reward_total;
- }
+ const agentsValues = {
+ indAgentRewardCondition,
+ indAgentRewardSumm,
+ calcBrokerRewardCondition,
+ calcBrokerRewardSum,
+ finDepartmentRewardCondtion,
+ finDepartmentRewardSumm,
+ };
+ // agents
- const agentsValues = {
- indAgentRewardCondition,
- indAgentRewardSumm,
- calcBrokerRewardCondition,
- calcBrokerRewardSum,
- finDepartmentRewardCondtion,
- finDepartmentRewardSumm,
- };
- // agents
-
- // fill insurance table
- calculationStore.setTableRows(
- 'tableInsurance',
- 0,
- )([
- {
- insuranceCompany: {
- value: quote?.evo_osago_accountid,
- },
- insured: { value: quote.evo_osago_payer },
- insCost: { value: quote.evo_osago_price },
- },
- {
- insuranceCompany: {
- value: quote.evo_kasko_accountid,
- },
- insured: { value: quote.evo_kasko_payer },
- insCost: { value: quote.evo_kasko_price },
- insTerm: { value: quote.evo_insurance_period },
- },
- {
- insuranceCompany: {
- value: quote.evo_kasko_accountid,
- },
- insured: { value: quote.evo_kasko_payer },
- insCost: { value: quote.evo_dgo_price },
- insTerm: { value: quote.evo_insurance_period },
- },
- {
- insuranceCompany: {
- value: quote.evo_kasko_accountid,
- },
- insured: { value: quote.evo_kasko_payer },
- insCost: { value: quote.evo_ns_price },
- insTerm: { value: quote.evo_insurance_period },
- },
- ]);
- // fill insurance table
-
- // fill payments table
- let evo_graph: IEvoGraph = {};
- if (quote.evo_graphs) {
- evo_graph = quote.evo_graphs.sort(
- //@ts-ignore
- (a, b) => b.createdon - a.createdon,
- )[0];
- if (evo_graph.evo_planpayments) {
- const payments = evo_graph.evo_planpayments
- .slice(1, evo_graph.evo_planpayments.length - 1)
- .map((evo_planpayment, i) => ({
- paymentRelation: {
- validation: undefined,
- value: evo_planpayment.evo_payment_ratio,
- status: tablePaymentsStatuses(
- quote.evo_graph_type,
- quote.evo_period,
- )?.includes(i + 1)
- ? ElementStatus.Default
- : ElementStatus.Disabled,
- },
- }));
- calculationStore.replaceTableRows('tablePayments')([
- {
- paymentRelation: {
- value: quote.evo_first_payment_perc,
- status: ElementStatus.Disabled,
- },
- },
- ...payments,
- {
- paymentRelation: {
- value: quote.evo_last_payment_perc,
- status: ElementStatus.Disabled,
- },
- },
- ]);
- }
- }
- // fill payments table
-
- // get product evo_id
- const base_product = calculationStore.getOption('selectProduct', {
- evo_baseproductid: newValues.product,
- });
- const product = base_product?.evo_id;
- // get product evo_id
-
- // get addproducts
- let addProducts = Object.assign(
- {},
- ...Object.keys(map_add_product_types_to_values).map(valueName => {
- const target_add_product_type = quote?.evo_addproduct_types?.find(
- x =>
- x.evo_product_type ===
- map_add_product_types_to_values[valueName],
- );
-
- return {
- [valueName]: target_add_product_type?.evo_addproduct_typeid,
- };
- }),
- );
- // get addproducts
-
- // get clientRisk
- let clientRisk = quote.evo_client_riskid;
- if (opportunity) {
- const current_opportunity = calculationStore.getOption(
- 'selectOpportunity',
- {
- value: opportunity,
- },
- );
-
- if (current_opportunity) {
- const { evo_programsolution, evo_client_riskid } =
- current_opportunity;
-
- if (evo_programsolution === 100000000) {
- const midClientRisk = calculationStore.getOption(
- 'selectClientRisk',
- {
- evo_id: '2',
- },
- );
- if (midClientRisk) {
- clientRisk = midClientRisk.evo_client_riskid;
- }
- } else if (
- evo_programsolution !== 100000000 &&
- evo_client_riskid
- ) {
- clientRisk = evo_client_riskid;
- }
- }
- }
- // get clientRisk
-
- // recalc fields
- let vehicleTaxInYear = quote['evo_vehicle_tax_year'];
- let leaseObjectCount = quote.evo_object_count;
- let requirementTelematic = quote.evo_req_telematic;
- if (recalcWithRevision) {
- requirementTelematic = quote.evo_req_telematic_accept;
- if (quote['evo_vehicle_tax_approved']) {
- vehicleTaxInYear = quote['evo_vehicle_tax_approved'];
- }
- if (quote.evo_recalc_limit) {
- leaseObjectCount = quote.evo_recalc_limit;
- }
- // telematic/tracker
- addProducts.telematic = undefined;
- addProducts.tracker = undefined;
- const add_product_types = calculationStore.getStaticData(
- 'evo_addproduct_type',
- );
- const targetAddproduct = add_product_types.find(
- x =>
- x.evo_addproduct_typeid ===
- quote.evo_accept_control_addproduct_typeid,
- );
- if (targetAddproduct?.evo_product_type) {
- const targetAddProductValueName = invert(
- map_add_product_types_to_values,
- )[targetAddproduct?.evo_product_type];
- addProducts[targetAddProductValueName] =
- targetAddproduct.evo_addproduct_typeid;
- }
- }
- // recalc fields
-
- // regions & towns
- let legalClientRegion;
- let regionRegistration;
- let legalClientTown;
- let townRegistration;
+ // fill insurance table
+ calculationStore.setTableRows(
+ 'tableInsurance',
+ 0,
+ )([
{
- const lead = calculationStore.getOption('selectLead');
- const opportunity = calculationStore.getOption('selectOpportunity');
+ insuranceCompany: {
+ value: quote?.evo_osago_accountid,
+ },
+ insured: { value: quote.evo_osago_payer },
+ insCost: { value: quote.evo_osago_price },
+ },
+ {
+ insuranceCompany: {
+ value: quote.evo_kasko_accountid,
+ },
+ insured: { value: quote.evo_kasko_payer },
+ insCost: { value: quote.evo_kasko_price },
+ insTerm: { value: quote.evo_insurance_period },
+ },
+ {
+ insuranceCompany: {
+ value: quote.evo_kasko_accountid,
+ },
+ insured: { value: quote.evo_kasko_payer },
+ insCost: { value: quote.evo_dgo_price },
+ insTerm: { value: quote.evo_insurance_period },
+ },
+ {
+ insuranceCompany: {
+ value: quote.evo_kasko_accountid,
+ },
+ insured: { value: quote.evo_kasko_payer },
+ insCost: { value: quote.evo_ns_price },
+ insTerm: { value: quote.evo_insurance_period },
+ },
+ ]);
+ // fill insurance table
- const evo_region_fias_id = get(
- lead?.accountidData || opportunity?.accountidData,
- 'evo_address_legalidData.evo_region_fias_id',
- undefined,
+ // fill payments table
+ let evo_graph: IEvoGraph = {};
+ if (quote.evo_graphs) {
+ evo_graph = quote.evo_graphs.sort(
+ //@ts-ignore
+ (a, b) => b.createdon - a.createdon,
+ )[0];
+ if (evo_graph.evo_planpayments) {
+ const payments = evo_graph.evo_planpayments
+ .slice(1, evo_graph.evo_planpayments.length - 1)
+ .map((evo_planpayment, i) => ({
+ paymentRelation: {
+ validation: undefined,
+ value: evo_planpayment.evo_payment_ratio,
+ status: tablePaymentsStatuses(
+ quote.evo_graph_type,
+ quote.evo_period,
+ )?.includes(i + 1)
+ ? ElementStatus.Default
+ : ElementStatus.Disabled,
+ },
+ }));
+ calculationStore.replaceTableRows('tablePayments')([
+ {
+ paymentRelation: {
+ value: quote.evo_first_payment_perc,
+ status: ElementStatus.Disabled,
+ },
+ },
+ ...payments,
+ {
+ paymentRelation: {
+ value: quote.evo_last_payment_perc,
+ status: ElementStatus.Disabled,
+ },
+ },
+ ]);
+ }
+ }
+ // fill payments table
+
+ // get product evo_id
+ const base_product = calculationStore.getOption('selectProduct', {
+ evo_baseproductid: newValues.product,
+ });
+ const product = base_product?.evo_id;
+ // get product evo_id
+
+ // get addproducts
+ let addProducts = Object.assign(
+ {},
+ ...Object.keys(map_add_product_types_to_values).map(valueName => {
+ const target_add_product_type = quote?.evo_addproduct_types?.find(
+ x =>
+ x.evo_product_type ===
+ map_add_product_types_to_values[valueName],
);
- // legalClientRegion
+ return {
+ [valueName]: target_add_product_type?.evo_addproduct_typeid,
+ };
+ }),
+ );
+ // get addproducts
+
+ // get clientRisk
+ let clientRisk = quote.evo_client_riskid;
+ if (opportunity) {
+ const current_opportunity = calculationStore.getOption(
+ 'selectOpportunity',
+ {
+ value: opportunity,
+ },
+ );
+
+ if (current_opportunity) {
+ const { evo_programsolution, evo_client_riskid } =
+ current_opportunity;
+
+ if (evo_programsolution === 100000000) {
+ const midClientRisk = calculationStore.getOption(
+ 'selectClientRisk',
+ {
+ evo_id: '2',
+ },
+ );
+ if (midClientRisk) {
+ clientRisk = midClientRisk.evo_client_riskid;
+ }
+ } else if (evo_programsolution !== 100000000 && evo_client_riskid) {
+ clientRisk = evo_client_riskid;
+ }
+ }
+ }
+ // get clientRisk
+
+ // recalc fields
+ let vehicleTaxInYear = quote['evo_vehicle_tax_year'];
+ let leaseObjectCount = quote.evo_object_count;
+ let requirementTelematic = quote.evo_req_telematic;
+ if (recalcWithRevision) {
+ requirementTelematic = quote.evo_req_telematic_accept;
+ if (quote['evo_vehicle_tax_approved']) {
+ vehicleTaxInYear = quote['evo_vehicle_tax_approved'];
+ }
+ if (quote.evo_recalc_limit) {
+ leaseObjectCount = quote.evo_recalc_limit;
+ }
+ // telematic/tracker
+ addProducts.telematic = undefined;
+ addProducts.tracker = undefined;
+ const add_product_types = calculationStore.getStaticData(
+ 'evo_addproduct_type',
+ );
+ const targetAddproduct = add_product_types.find(
+ x =>
+ x.evo_addproduct_typeid ===
+ quote.evo_accept_control_addproduct_typeid,
+ );
+ if (targetAddproduct?.evo_product_type) {
+ const targetAddProductValueName = invert(
+ map_add_product_types_to_values,
+ )[targetAddproduct?.evo_product_type];
+ addProducts[targetAddProductValueName] =
+ targetAddproduct.evo_addproduct_typeid;
+ }
+ }
+ // recalc fields
+
+ // regions & towns
+ let legalClientRegion;
+ let regionRegistration;
+ let legalClientTown;
+ let townRegistration;
+ {
+ const lead = calculationStore.getOption('selectLead');
+ const opportunity = calculationStore.getOption('selectOpportunity');
+
+ const evo_region_fias_id = get(
+ lead?.accountidData || opportunity?.accountidData,
+ 'evo_address_legalidData.evo_region_fias_id',
+ undefined,
+ );
+
+ // legalClientRegion
+ if (evo_region_fias_id) {
+ const region = calculationStore.getOption(
+ 'selectLegalClientRegion',
+ {
+ evo_fias_id: evo_region_fias_id,
+ },
+ );
+ legalClientRegion = region?.evo_regionid;
+ calculationStore.setStatus(
+ 'selectLegalClientRegion',
+ ElementStatus.Disabled,
+ );
+ } else {
+ legalClientRegion = quote.evo_legal_regionid;
+ calculationStore.setStatus(
+ 'selectLegalClientRegion',
+ ElementStatus.Default,
+ );
+ }
+ // legalClientRegion
+
+ // regionRegistration
+ if (quote.evo_object_registration === 100000001) {
+ regionRegistration = quote.evo_regionid;
+ calculationStore.setFilter('selectRegionRegistration', regions =>
+ regions.filter(x => x.evo_businessunit_evolution === true),
+ );
+ calculationStore.setStatus(
+ 'selectRegionRegistration',
+ ElementStatus.Default,
+ );
+ } else {
+ calculationStore.setFilter('selectRegionRegistration', undefined);
if (evo_region_fias_id) {
const region = calculationStore.getOption(
- 'selectLegalClientRegion',
+ 'selectRegionRegistration',
{
evo_fias_id: evo_region_fias_id,
},
);
- legalClientRegion = region?.evo_regionid;
+
+ regionRegistration = region?.evo_regionid;
calculationStore.setStatus(
- 'selectLegalClientRegion',
+ 'selectRegionRegistration',
ElementStatus.Disabled,
);
} else {
- legalClientRegion = quote.evo_legal_regionid;
- calculationStore.setStatus(
- 'selectLegalClientRegion',
- ElementStatus.Default,
- );
- }
- // legalClientRegion
-
- // regionRegistration
- if (quote.evo_object_registration === 100000001) {
regionRegistration = quote.evo_regionid;
- calculationStore.setFilter('selectRegionRegistration', regions =>
- regions.filter(x => x.evo_businessunit_evolution === true),
- );
calculationStore.setStatus(
'selectRegionRegistration',
ElementStatus.Default,
);
- } else {
- calculationStore.setFilter('selectRegionRegistration', undefined);
- if (evo_region_fias_id) {
- const region = calculationStore.getOption(
- 'selectRegionRegistration',
- {
- evo_fias_id: evo_region_fias_id,
- },
- );
-
- regionRegistration = region?.evo_regionid;
- calculationStore.setStatus(
- 'selectRegionRegistration',
- ElementStatus.Disabled,
- );
- } else {
- regionRegistration = quote.evo_regionid;
- calculationStore.setStatus(
- 'selectRegionRegistration',
- ElementStatus.Default,
- );
- }
}
- // regionRegistration
+ }
+ // regionRegistration
- const secondaryOptions = await CrmService.getCRMOptions<
- ElementsNames,
- IEvoTown
- >({
- query: getSecondaryOptionsForQuote,
- variables: {
- statecode: 0,
- evo_regionid: regionRegistration || NIL,
- evo_legal_regionid: legalClientRegion || NIL,
- },
+ const secondaryOptions = await CrmService.getCRMOptions<
+ ElementsNames,
+ IEvoTown
+ >({
+ query: secondaryOptionsForQuoteQuery,
+ variables: {
+ statecode: 0,
+ evo_regionid: regionRegistration || NIL,
+ evo_legal_regionid: legalClientRegion || NIL,
+ },
+ });
+
+ calculationStore.applyOptions(secondaryOptions);
+
+ const evo_city_fias_id = get(
+ lead?.accountidData || opportunity?.accountidData,
+ 'evo_address_legalidData.evo_city_fias_id',
+ undefined,
+ );
+
+ // legalClientTown
+ if (evo_city_fias_id) {
+ const town = calculationStore.getOption('selectLegalClientTown', {
+ evo_fias_id: evo_city_fias_id,
});
-
- calculationStore.applyOptions(secondaryOptions);
-
- const evo_city_fias_id = get(
- lead?.accountidData || opportunity?.accountidData,
- 'evo_address_legalidData.evo_city_fias_id',
- undefined,
+ legalClientTown = town?.evo_townid;
+ calculationStore.setStatus(
+ 'selectLegalClientTown',
+ ElementStatus.Disabled,
);
+ } else {
+ if (
+ (
+ secondaryOptions?.selectLegalClientTown as IEvoTown[]
+ )?.findIndex(x => x.evo_townid === 'quote?.evo_legal_townid') > -1
+ ) {
+ legalClientTown = quote.evo_legal_townid;
+ }
+ calculationStore.setStatus(
+ 'selectLegalClientTown',
+ ElementStatus.Default,
+ );
+ }
+ // legalClientTown
- // legalClientTown
+ //townRegistration
+ if (quote.evo_object_registration === 100000001) {
+ if (
+ (
+ secondaryOptions?.selectTownRegistration as IEvoTown[]
+ )?.findIndex(x => x.evo_townid === quote.evo_townid) > -1
+ ) {
+ townRegistration = quote.evo_townid;
+ }
+ calculationStore.setFilter('selectTownRegistration', towns =>
+ towns.filter(x => x.evo_businessunit_evolution === true),
+ );
+ calculationStore.setStatus(
+ 'selectTownRegistration',
+ ElementStatus.Default,
+ );
+ } else {
+ calculationStore.setFilter('selectTownRegistration', undefined);
if (evo_city_fias_id) {
- const town = calculationStore.getOption('selectLegalClientTown', {
- evo_fias_id: evo_city_fias_id,
- });
- legalClientTown = town?.evo_townid;
+ const town = calculationStore.getOption(
+ 'selectTownRegistration',
+ {
+ evo_fias_id: evo_city_fias_id,
+ },
+ );
+
+ townRegistration = town?.evo_townid;
calculationStore.setStatus(
- 'selectLegalClientTown',
+ 'selectTownRegistration',
ElementStatus.Disabled,
);
} else {
- if (
- (
- secondaryOptions?.selectLegalClientTown as IEvoTown[]
- )?.findIndex(x => x.evo_townid === 'quote?.evo_legal_townid') >
- -1
- ) {
- legalClientTown = quote.evo_legal_townid;
- }
- calculationStore.setStatus(
- 'selectLegalClientTown',
- ElementStatus.Default,
- );
- }
- // legalClientTown
-
- //townRegistration
- if (quote.evo_object_registration === 100000001) {
if (
(
secondaryOptions?.selectTownRegistration as IEvoTown[]
@@ -493,185 +507,150 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
) {
townRegistration = quote.evo_townid;
}
- calculationStore.setFilter('selectTownRegistration', towns =>
- towns.filter(x => x.evo_businessunit_evolution === true),
- );
calculationStore.setStatus(
'selectTownRegistration',
ElementStatus.Default,
);
- } else {
- calculationStore.setFilter('selectTownRegistration', undefined);
- if (evo_city_fias_id) {
- const town = calculationStore.getOption(
- 'selectTownRegistration',
- {
- evo_fias_id: evo_city_fias_id,
- },
- );
-
- townRegistration = town?.evo_townid;
- calculationStore.setStatus(
- 'selectTownRegistration',
- ElementStatus.Disabled,
- );
- } else {
- if (
- (
- secondaryOptions?.selectTownRegistration as IEvoTown[]
- )?.findIndex(x => x.evo_townid === quote.evo_townid) > -1
- ) {
- townRegistration = quote.evo_townid;
- }
- calculationStore.setStatus(
- 'selectTownRegistration',
- ElementStatus.Default,
- );
- }
}
- //townRegistration
}
+ //townRegistration
+ }
- // redemptionPayment
- let redemptionPaymentSum =
- quote.evo_payment_redemption_sum ||
- initialValues.redemptionPaymentSum;
- // redemptionPayment
+ // redemptionPayment
+ let redemptionPaymentSum =
+ quote.evo_payment_redemption_sum ||
+ initialValues.redemptionPaymentSum;
+ // redemptionPayment
- const finalValues = {
- ...initialValues,
- ...newValues,
- product,
- ...addProducts,
- rate,
- lead,
- opportunity,
- quote: quoteId,
- recalcWithRevision,
- leaseObjectCount,
- clientRisk,
- calcType,
- totalPayments: evo_graph.evo_sumpay_withnds,
- indAgent,
- vehicleTaxInYear,
- INNForCalc,
- creditRate,
- infuranceOPF,
- legalClientRegion,
- regionRegistration,
- legalClientTown,
- townRegistration,
- calcBroker,
- calcFinDepartment,
- requirementTelematic,
- balanceHolder,
- redemptionPaymentSum,
- ...agentsValues,
- };
+ const finalValues = {
+ ...initialValues,
+ ...newValues,
+ product,
+ ...addProducts,
+ rate,
+ lead,
+ opportunity,
+ quote: quoteId,
+ recalcWithRevision,
+ leaseObjectCount,
+ clientRisk,
+ calcType,
+ totalPayments: evo_graph.evo_sumpay_withnds,
+ indAgent,
+ vehicleTaxInYear,
+ INNForCalc,
+ creditRate,
+ infuranceOPF,
+ legalClientRegion,
+ regionRegistration,
+ legalClientTown,
+ townRegistration,
+ calcBroker,
+ calcFinDepartment,
+ requirementTelematic,
+ balanceHolder,
+ redemptionPaymentSum,
+ ...agentsValues,
+ };
- // check min max number values
- let fixedElementsNames: ElementsNames[] = [];
- (Object.keys(numberElementsProps) as ElementsNames[]).forEach(
- elementName => {
- if (elementName in numberElementsProps) {
- const elementProps = numberElementsProps[elementName];
+ // check min max number values
+ let fixedElementsNames: ElementsNames[] = [];
+ (Object.keys(numberElementsProps) as ElementsNames[]).forEach(
+ elementName => {
+ const elementProps = numberElementsProps[elementName];
+ const valueName = getValueName(elementName);
- const valueName = getValueName(elementName);
- if (
- finalValues[valueName] &&
- ((elementProps?.min &&
- finalValues[valueName] < parseFloat(elementProps?.min)) ||
- (elementProps?.max &&
- finalValues[valueName] > parseFloat(elementProps?.max)))
- ) {
- finalValues[valueName] = initialValues[valueName];
- fixedElementsNames.push(elementName);
- }
- }
- },
+ if (
+ finalValues[valueName] &&
+ ((elementProps?.min &&
+ finalValues[valueName] < parseFloat(elementProps?.min)) ||
+ (elementProps?.max &&
+ finalValues[valueName] > parseFloat(elementProps?.max)))
+ ) {
+ finalValues[valueName] = initialValues[valueName];
+ fixedElementsNames.push(elementName);
+ }
+ },
+ );
+ if (fixedElementsNames.length > 0) {
+ const fieldsTitles = fixedElementsNames
+ .map(x => getTitle(x))
+ .join(', ');
+ openNotification({
+ type: 'warning',
+ title: 'Внимание',
+ description: 'При подгрузке КП были сброшены поля: ' + fieldsTitles,
+ })();
+ }
+ // check min max number values
+
+ calculationStore.setValues(finalValues, true);
+
+ message.success({
+ content: `КП ${quote?.evo_quotename || ''} загружено!`,
+ });
+
+ const { ELTStore } = calculationStore.stores;
+ // ELT KASKO
+ {
+ resetIns.call(calculationStore, 'kasko');
+ const kaskoIndex = ELTStore.kasko.list.findIndex(
+ x => x.accountid === quote.evo_kasko_accountid,
);
- if (fixedElementsNames.length > 0) {
- const fieldsTitles = fixedElementsNames
- .map(x => getTitle(x))
- .join(', ');
- openNotification({
- type: 'warning',
- title: 'Внимание',
- description:
- 'При подгрузке КП были сброшены поля: ' + fieldsTitles,
- })();
- }
- // check min max number values
- calculationStore.setValues(finalValues, true);
+ if (kaskoIndex >= 0) {
+ const mapQuoteToELTKasko = {
+ key: 'evo_kasko_accountid',
+ accountid: 'evo_kasko_accountid',
+ kaskoSum: 'evo_kasko_price',
+ requestId: 'evo_id_elt_kasko',
+ skCalcId: 'evo_id_kasko_calc',
+ totalFranchise: 'evo_franchise',
+ };
- message.success({
- content: `КП ${quote?.evo_quotename || ''} загружено!`,
- });
-
- const { ELTStore } = calculationStore.stores;
- // ELT KASKO
- {
- resetIns.call(calculationStore, 'kasko');
- const kaskoIndex = ELTStore.kasko.list.findIndex(
- x => x.accountid === quote.evo_kasko_accountid,
- );
-
- if (kaskoIndex >= 0) {
- const mapQuoteToELTKasko = {
- key: 'evo_kasko_accountid',
- accountid: 'evo_kasko_accountid',
- kaskoSum: 'evo_kasko_price',
- requestId: 'evo_id_elt_kasko',
- skCalcId: 'evo_id_kasko_calc',
- totalFranchise: 'evo_franchise',
- };
-
- let row = {};
- Object.keys(mapQuoteToELTKasko).forEach(rowFieldName => {
- const quoteFieldName = mapQuoteToELTKasko[rowFieldName];
- const quoteValue = get(quote, quoteFieldName);
- if (!isNil(quoteValue)) row[rowFieldName] = quoteValue;
- });
- if (
- Object.keys(mapQuoteToELTKasko).length ===
- Object.keys(row).length
- ) {
- ELTStore.addToCompanyRes('kasko', kaskoIndex, row);
- ELTStore.kasko.setKey(quote.evo_kasko_accountid);
- }
+ let row = {};
+ Object.keys(mapQuoteToELTKasko).forEach(rowFieldName => {
+ const quoteFieldName = mapQuoteToELTKasko[rowFieldName];
+ const quoteValue = get(quote, quoteFieldName);
+ if (!isNil(quoteValue)) row[rowFieldName] = quoteValue;
+ });
+ if (
+ Object.keys(mapQuoteToELTKasko).length === Object.keys(row).length
+ ) {
+ ELTStore.addToCompanyRes('kasko', kaskoIndex, row);
+ ELTStore.kasko.setKey(quote.evo_kasko_accountid);
}
}
+ }
- // ELT OSAGO
- {
- resetIns.call(calculationStore, 'osago');
- const osagoIndex = ELTStore.osago.list.findIndex(
- x => x.accountid === quote.evo_osago_accountid,
- );
- if (osagoIndex >= 0) {
- const mapQuoteToELTOsago = {
- key: 'evo_osago_accountid',
- accountid: 'evo_osago_accountid',
- numCalc: 'evo_id_elt_osago',
- premiumSum: 'evo_osago_price',
- };
+ // ELT OSAGO
+ {
+ resetIns.call(calculationStore, 'osago');
+ const osagoIndex = ELTStore.osago.list.findIndex(
+ x => x.accountid === quote.evo_osago_accountid,
+ );
+ if (osagoIndex >= 0) {
+ const mapQuoteToELTOsago = {
+ key: 'evo_osago_accountid',
+ accountid: 'evo_osago_accountid',
+ numCalc: 'evo_id_elt_osago',
+ premiumSum: 'evo_osago_price',
+ };
- let row = {};
- Object.keys(mapQuoteToELTOsago).forEach(rowFieldName => {
- const quoteFieldName = mapQuoteToELTOsago[rowFieldName];
- const quoteValue = get(quote, quoteFieldName);
- if (!isNil(quoteValue)) row[rowFieldName] = quoteValue;
- });
+ let row = {};
+ Object.keys(mapQuoteToELTOsago).forEach(rowFieldName => {
+ const quoteFieldName = mapQuoteToELTOsago[rowFieldName];
+ const quoteValue = get(quote, quoteFieldName);
+ if (!isNil(quoteValue)) row[rowFieldName] = quoteValue;
+ });
- if (row['numCalc']) {
- row['numCalc'] = parseInt(row['numCalc']);
- }
+ if (row['numCalc']) {
+ row['numCalc'] = parseInt(row['numCalc']);
+ }
- if (isEqual(Object.keys(row), Object.keys(mapQuoteToELTOsago))) {
- ELTStore.addToCompanyRes('osago', osagoIndex, row);
- ELTStore.osago.setKey(quote.evo_osago_accountid);
- }
+ if (isEqual(Object.keys(row), Object.keys(mapQuoteToELTOsago))) {
+ ELTStore.addToCompanyRes('osago', osagoIndex, row);
+ ELTStore.osago.setKey(quote.evo_osago_accountid);
}
}
}
diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts
index faf9640..ee54acf 100644
--- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts
+++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/mapKpToValues.ts
@@ -1,104 +1,107 @@
+import { IQuote } from 'core/services/CrmService/types/entities';
import { ValuesNames } from 'core/types/Calculation/Store/values';
-import { IQuote } from 'core/types/Entities/crmEntities';
-const mapKPtoValues: Partial> = {
- product: 'evo_baseproductid',
- clientType: 'evo_client_typeid',
- leaseObjectPrice: 'evo_supplier_currency_price',
- supplierCurrency: 'evo_transactioncurrencyid',
- supplierDiscountRub: 'evo_discount_supplier_currency',
- supplierDiscountPerc: 'evo_discount_perc',
- firstPaymentPerc: 'evo_first_payment_perc',
- lastPaymentRule: 'evo_last_payment_calc',
- lastPaymentPerc: 'evo_last_payment_perc',
- lastPaymentRub: 'evo_last_payment_rub',
- // balanceHolder: 'evo_balance_holder',
- graphType: 'evo_graph_type',
- parmentsDecreasePercent: 'evo_payments_decrease_perc',
- seasonType: 'evo_seasons_type',
- highSeasonStart: 'evo_high_season',
- comissionPerc: 'evo_comission_perc',
- comissionRub: 'evo_comission_rub',
- saleBonus: 'evo_sale_bonus',
- leasingPeriod: 'evo_period',
- tarif: 'evo_tarifid',
- // creditRate: 'evo_rate',
- IRR_Perc: 'evo_msfo_irr',
- leaseObjectType: 'evo_leasingobject_typeid',
- deliveryTime: 'evo_delivery_time',
- brand: 'evo_brandid',
- model: 'evo_modelid',
- configuration: 'evo_equipmentid',
- leaseObjectYear: 'evo_year',
- engineType: 'evo_engine_type',
- leaseObjectCategory: 'evo_category',
- leaseObjectMotorPower: 'evo_power',
- engineVolume: 'evo_engine_volume',
- leaseObjectUseFor: 'evo_use_for',
- withTrailer: 'evo_trailer',
- leaseObjectUsed: 'evo_leasingobject_used',
- maxMass: 'evo_max_mass',
- countSeats: 'evo_seats',
- maxSpeed: 'evo_max_speed',
- dealer: 'evo_supplier_accountid',
- dealerPerson: 'evo_dealer_person_accountid',
- dealerRewardCondition: 'evo_dealer_reward_conditionid',
- dealerRewardSumm: 'evo_dealer_reward_total',
- dealerBroker: 'evo_dealer_broker_accountid',
- dealerBrokerRewardCondition: 'evo_dealer_broker_reward_conditionid',
- dealerBrokerRewardSumm: 'evo_dealer_broker_reward_total',
- // indAgent: 'evo_agent_accountid',
- // indAgentRewardCondition: 'evo_agent_reward_conditionid',
- // indAgentRewardSumm: 'evo_agent_reward_total',
- calcDoubleAgent: 'evo_double_agent_accountid',
- calcDoubleAgentRewardCondition: 'evo_double_agent_reward_conditionid',
- calcDoubleAgentRewardSumm: 'evo_double_agent_reward_total',
- // calcBroker: 'evo_broker_accountid',
- // calcBrokerRewardCondition: 'evo_broker_reward_conditionid',
- // calcBrokerRewardSum: 'evo_broker_reward_total',
- // calcFinDepartment: 'evo_fin_department_accountid',
- // finDepartmentRewardCondtion: 'evo_fin_department_reward_conditionid',
- // finDepartmentRewardSumm: 'evo_fin_department_reward_total',
- GPSBrand: 'evo_gps_brandid',
- GPSModel: 'evo_gps_modelid',
- infuranceOPF: 'evo_ins_legal_form',
- insKaskoType: 'evo_insurance_type',
- insKaskoPriceLeasePeriod: 'evo_kasko_price_leasperiod',
- insDecentral: 'evo_insurance_decentral',
- insPeriod: 'evo_insurance_period',
- insFranchise: 'evo_franchise',
- insUnlimitDrivers: 'evo_unlimit_drivers',
- insAgeDrivers: 'evo_age_drivers',
- insExpDrivers: 'evo_exp_drivers',
- lastPaymentRedemption: 'evo_last_payment_redemption',
- priceWithDiscount: 'evo_price_with_discount',
- costIncrease: 'evo_cost_increace',
- insurance: 'evo_insurance',
- registrationQuote: 'evo_registration_quote',
- technicalCardQuote: 'evo_card_quote',
- NSIB: 'evo_nsib_quote',
- quoteName: 'evo_contact_name',
- quoteContactGender: 'evo_gender',
- quoteRedemptionGraph: 'evo_redemption_graph',
- minPriceChange: 'evo_min_change_price',
- maxPriceChange: 'evo_max_price_change',
- importerRewardPerc: 'evo_importer_reward_perc',
- importerRewardRub: 'evo_importer_reward_rub',
- // requirementTelematic: 'evo_req_telematic_accept',
- mileage: 'evo_mileage',
- fullPriceWithDiscount: 'evo_price_without_discount_quote',
- objectRegistration: 'evo_object_registration',
- objectRegionRegistration: 'evo_registration_regionid',
- // vehicleTaxInYear: 'evo_vehicle_tax_approved',
- objectCategoryTax: 'evo_category_tr',
- objectTypeTax: 'evo_vehicle_type_tax',
- typePTS: 'evo_pts_type',
- subsidy: 'evo_subsidyid',
- subsidySum: 'evo_subsidy_summ',
+const mapKPtoValues: Partial> = {
+ evo_baseproductid: 'product',
+ evo_client_typeid: 'clientType',
+ evo_supplier_currency_price: 'leaseObjectPrice',
+ evo_transactioncurrencyid: 'supplierCurrency',
+ evo_discount_supplier_currency: 'supplierDiscountRub',
+ evo_discount_perc: 'supplierDiscountPerc',
+ evo_first_payment_perc: 'firstPaymentPerc',
+ evo_last_payment_calc: 'lastPaymentRule',
+ evo_last_payment_perc: 'lastPaymentPerc',
+ evo_last_payment_rub: 'lastPaymentRub',
+ // evo_balance_holder: 'balanceHolder',
+ evo_graph_type: 'graphType',
+ evo_payments_decrease_perc: 'parmentsDecreasePercent',
+ evo_seasons_type: 'seasonType',
+ evo_high_season: 'highSeasonStart',
+ evo_comission_perc: 'comissionPerc',
+ evo_comission_rub: 'comissionRub',
+ evo_sale_bonus: 'saleBonus',
+ evo_period: 'leasingPeriod',
+ evo_tarifid: 'tarif',
+ // evo_rate: 'creditRate',
+ evo_msfo_irr: 'IRR_Perc',
+ evo_leasingobject_typeid: 'leaseObjectType',
+ evo_delivery_time: 'deliveryTime',
+ evo_brandid: 'brand',
+ evo_modelid: 'model',
+ evo_equipmentid: 'configuration',
+ evo_year: 'leaseObjectYear',
+ evo_engine_type: 'engineType',
+ evo_category: 'leaseObjectCategory',
+ evo_power: 'leaseObjectMotorPower',
+ evo_engine_volume: 'engineVolume',
+ evo_use_for: 'leaseObjectUseFor',
+ evo_trailer: 'withTrailer',
+ evo_leasingobject_used: 'leaseObjectUsed',
+ evo_max_mass: 'maxMass',
+ evo_seats: 'countSeats',
+ evo_max_speed: 'maxSpeed',
+ evo_supplier_accountid: 'dealer',
+ evo_dealer_person_accountid: 'dealerPerson',
+ evo_dealer_reward_conditionid: 'dealerRewardCondition',
+ evo_dealer_reward_total: 'dealerRewardSumm',
+ evo_dealer_broker_accountid: 'dealerBroker',
+ evo_dealer_broker_reward_conditionid: 'dealerBrokerRewardCondition',
+ evo_dealer_broker_reward_total: 'dealerBrokerRewardSumm',
+ // evo_agent_accountid: indAgent,
+ // evo_agent_reward_conditionid: 'indAgentRewardCondition',
+ // evo_agent_reward_total: indAgentRewardSumm,
+ evo_double_agent_accountid: 'calcDoubleAgent',
+ evo_double_agent_reward_conditionid: 'calcDoubleAgentRewardCondition',
+ evo_double_agent_reward_total: 'calcDoubleAgentRewardSumm',
+ // evo_broker_accountid: 'calcBroker',
+ // evo_broker_reward_conditionid: 'calcBrokerRewardCondition',
+ // evo_broker_reward_total: 'calcBrokerRewardSum',
+ // evo_fin_department_accountid: 'calcFinDepartment',
+ // evo_fin_department_reward_conditionid: 'finDepartmentRewardCondtion',
+ // evo_fin_department_reward_total: 'finDepartmentRewardSumm'
+ evo_gps_brandid: 'GPSBrand',
+ evo_gps_modelid: 'GPSModel',
+ evo_ins_legal_form: 'infuranceOPF',
+ evo_insurance_type: 'insKaskoType',
+ evo_insurance_decentral: 'insDecentral',
+ evo_franchise: 'insFranchise',
+ evo_unlimit_drivers: 'insUnlimitDrivers',
+ evo_age_drivers: 'insAgeDrivers',
+ evo_exp_drivers: 'insExpDrivers',
+ evo_last_payment_redemption: 'lastPaymentRedemption',
+ evo_price_with_discount: 'priceWithDiscount',
+ evo_cost_increace: 'costIncrease',
+ evo_insurance: 'insurance',
+ evo_registration_quote: 'registrationQuote',
+ evo_card_quote: 'technicalCardQuote',
+ evo_nsib_quote: 'NSIB',
+ evo_contact_name: 'quoteName',
+ evo_gender: 'quoteContactGender',
+ evo_redemption_graph: 'quoteRedemptionGraph',
+ evo_min_change_price: 'minPriceChange',
+ evo_max_price_change: 'maxPriceChange',
+ evo_importer_reward_perc: 'importerRewardPerc',
+ evo_importer_reward_rub: 'importerRewardRub',
+ // evo_req_telematic_accept: 'requirementTelematic',
+ evo_mileage: 'mileage',
+ evo_price_without_discount_quote: 'fullPriceWithDiscount',
+ evo_object_registration: 'objectRegistration',
+ evo_registration_regionid: 'objectRegionRegistration',
+ // evo_vehicle_tax_approved: vehicleTaxInYear,
+ evo_category_tr: 'objectCategoryTax',
+ evo_vehicle_type_tax: 'objectTypeTax',
+ evo_pts_type: 'typePTS',
+ evo_subsidyid: 'subsidy',
+ evo_subsidy_summ: 'subsidySum',
};
-export const getKpPropName = (
- valueName: ValuesNames,
-): keyof IQuote | string | undefined => mapKPtoValues[valueName];
-
-export default mapKPtoValues;
+export function getValuesFromKP(quote: IQuote) {
+ return Object.keys(mapKPtoValues).reduce((acc, kpProp) => {
+ const valueName = mapKPtoValues[kpProp];
+ if (valueName) {
+ const value = quote[kpProp];
+ acc[valueName] = value;
+ }
+ return acc;
+ }, {} as Partial>);
+}
diff --git a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts
index 7065651..84ec078 100644
--- a/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts
+++ b/src/client/stores/CalculationStore/Effects/reactions/otherReactions.ts
@@ -3,24 +3,10 @@ import valuesConstants from 'core/constants/values';
import { pipe } from 'core/tools/func';
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
import { Process } from 'core/types/Calculation/Store/process';
-import { ElementStatus } from 'core/types/statuses';
import { get, intersection, round } from 'lodash';
+import { ElementStatus } from 'types/elements';
const reactionEffects: IReactionEffect[] = [
- // calculationStore => ({
- // expression: () => {
- // const { options } = calculationStore;
- // return options.selectQuote;
- // },
- // effect: quotes => {
- // if (quotes.length > 0) {
- // calculationStore.setStatus('tbxQuoteName', Status.Disabled);
- // } else {
- // calculationStore.setStatus('tbxQuoteName', Status.Default);
- // }
- // },
- // }),
-
calculationStore => ({
expression: () => {
const { opportunity } = calculationStore.values;
@@ -37,131 +23,6 @@ const reactionEffects: IReactionEffect[] = [
},
}),
- calculationStore => ({
- expression: () => {
- const { agent } = calculationStore.values;
- return agent;
- },
- effect: agentid => {
- if (!agentid) {
- calculationStore.setStatus('selectDoubleAgent', ElementStatus.Disabled);
- } else {
- calculationStore.setStatus('selectDoubleAgent', ElementStatus.Default);
- }
- },
- }),
-
- calculationStore => ({
- expression: () => {
- const { channel } = calculationStore.values;
- return channel;
- },
- effect: channel => {
- switch (channel) {
- case 100000000:
- calculationStore.setStatus('selectSupplier', ElementStatus.Default);
- calculationStore.setStatus('selectAgent', ElementStatus.Default);
-
- calculationStore.setStatus(
- 'selectFinDepartment',
- ElementStatus.Disabled,
- );
- calculationStore.setValue('finDepartment', null);
-
- calculationStore.setStatus('selectBroker', ElementStatus.Disabled);
- calculationStore.setValue('broker', null);
- break;
-
- case 100000001:
- calculationStore.setStatus('selectSupplier', ElementStatus.Default);
- calculationStore.setStatus('selectAgent', ElementStatus.Default);
-
- calculationStore.setStatus(
- 'selectFinDepartment',
- ElementStatus.Default,
- );
-
- calculationStore.setStatus('selectBroker', ElementStatus.Disabled);
- calculationStore.setValue('broker', null);
- break;
- case 100000002:
- calculationStore.setStatus('selectSupplier', ElementStatus.Disabled);
- calculationStore.setValue('supplier', null);
-
- calculationStore.setStatus('selectAgent', ElementStatus.Default);
-
- calculationStore.setStatus(
- 'selectFinDepartment',
- ElementStatus.Disabled,
- );
- calculationStore.setValue('finDepartment', null);
-
- calculationStore.setStatus('selectBroker', ElementStatus.Disabled);
- calculationStore.setValue('broker', null);
- break;
- case 100000003:
- calculationStore.setStatus('selectSupplier', ElementStatus.Disabled);
- calculationStore.setValue('supplier', null);
-
- calculationStore.setStatus('selectAgent', ElementStatus.Default);
- calculationStore.setValue('agent', null);
-
- calculationStore.setStatus(
- 'selectFinDepartment',
- ElementStatus.Disabled,
- );
- calculationStore.setValue('finDepartment', null);
-
- calculationStore.setStatus('selectBroker', ElementStatus.Default);
- break;
- case 100000004:
- default:
- calculationStore.setStatus('selectSupplier', ElementStatus.Disabled);
- calculationStore.setValue('supplier', null);
-
- calculationStore.setStatus('selectAgent', ElementStatus.Disabled);
- calculationStore.setValue('agent', null);
-
- calculationStore.setStatus(
- 'selectFinDepartment',
- ElementStatus.Disabled,
- );
- calculationStore.setValue('finDepartment', null);
-
- calculationStore.setStatus('selectBroker', ElementStatus.Disabled);
- calculationStore.setValue('broker', null);
- break;
- }
- },
- options: {
- fireImmediately: true,
- },
- }),
-
- calculationStore => ({
- expression: () => {
- const { newClient } = calculationStore.values;
- return newClient;
- },
- effect: newClient => {
- if (newClient && newClient.length > 0) {
- calculationStore.setValue('account', null);
- calculationStore.setValue('contactClient', null);
- calculationStore.setStatus('selectAccount', ElementStatus.Disabled);
- calculationStore.setStatus(
- 'selectContactClient',
- ElementStatus.Disabled,
- );
- } else {
- calculationStore.setStatus('selectAccount', ElementStatus.Default);
- calculationStore.setStatus(
- 'selectContactClient',
- ElementStatus.Default,
- );
- }
- },
- }),
-
(calculationStore, calculationProcess) => ({
expression: () => {
const { indAgentRewardCondition } = calculationStore.values;
@@ -578,50 +439,6 @@ const reactionEffects: IReactionEffect[] = [
},
}),
- calculationStore => ({
- expression: () => {
- const { insUnlimitDrivers } = calculationStore.values;
- return insUnlimitDrivers;
- },
- effect: insUnlimitDrivers => {
- if (insUnlimitDrivers) {
- calculationStore.setStatus('tbxInsAgeDrivers', ElementStatus.Disabled);
- calculationStore.setStatus('tbxInsExpDrivers', ElementStatus.Disabled);
- calculationStore.setStatus(
- 'btnDriversApplication',
- ElementStatus.Disabled,
- );
- } else {
- calculationStore.setStatus('tbxInsAgeDrivers', ElementStatus.Default);
- calculationStore.setStatus('tbxInsExpDrivers', ElementStatus.Default);
- calculationStore.setStatus(
- 'btnDriversApplication',
- ElementStatus.Default,
- );
- }
- },
- options: {
- fireImmediately: true,
- },
- }),
-
- calculationStore => ({
- expression: () => {
- const { insFranchise } = calculationStore.values;
- return insFranchise;
- },
- effect: insFranchise => {
- if (!insFranchise || parseInt(insFranchise) === 0) {
- calculationStore.setStatus('btnFranschise', ElementStatus.Disabled);
- } else {
- calculationStore.setStatus('btnFranschise', ElementStatus.Default);
- }
- },
- options: {
- fireImmediately: true,
- },
- }),
-
calculationStore => ({
expression: () => {
const { lastPaymentRule } = calculationStore.values;
diff --git a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts
index 6a01169..8a74da8 100644
--- a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts
+++ b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts
@@ -1,13 +1,13 @@
-import { getFieldName } from 'client/Containers/Calculation/lib/elements/tools';
+import { getFieldName } from 'client/Containers/Calculation/Elements/tools';
+import { InteractionElementsNames } from 'client/Containers/Calculation/types/elements';
+import { TableNames } from 'client/Containers/Calculation/types/tables';
import { openNotification } from 'client/Elements/Notification';
import valuesConstants from 'core/constants/values';
import { pipe } from 'core/tools/func';
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
-import { ElementsNames } from 'core/types/Calculation/Store/elements';
import { Process } from 'core/types/Calculation/Store/process';
-import { TableNames } from 'core/types/Calculation/Store/tables';
import { ValuesNames } from 'core/types/Calculation/Store/values';
-import { ElementStatus } from 'core/types/statuses';
+import { ElementStatus } from 'types/elements';
import { convertPrice } from '../lib/tools';
import { getPrice } from './priceReactions/calculate';
@@ -265,11 +265,8 @@ const reactionEffects: IReactionEffect[] = [
calculationStore => ({
expression: () => {
- const {
- countSeats,
- leaseObjectCategory,
- recalcWithRevision,
- } = calculationStore.values;
+ const { countSeats, leaseObjectCategory, recalcWithRevision } =
+ calculationStore.values;
return {
countSeats,
leaseObjectCategory,
@@ -579,7 +576,7 @@ const map_add_product_types_to_values = {
telematics: 100000004,
};
-const elementsToDisable: (ElementsNames | TableNames)[] = [
+const elementsToDisable: (InteractionElementsNames | TableNames)[] = [
'tablePayments',
'selectLead',
'selectOpportunity',
@@ -605,7 +602,6 @@ const elementsToDisable: (ElementsNames | TableNames)[] = [
'selectIndAgent',
'selectCalcBroker',
'selectCalcFinDepartment',
- 'tbxInsKaskoPriceLeasePeriod',
'selectTarif',
'tbxCreditRate',
'selectRate',
@@ -620,7 +616,7 @@ const elementsToDisable: (ElementsNames | TableNames)[] = [
];
// Для recalc = true и первого платежа = 0
-const agentsElementsToDisable: ElementsNames[] = [
+const agentsElementsToDisable: InteractionElementsNames[] = [
'selectDealerRewardCondition',
'tbxDealerRewardSumm',
'selectDealerBroker',
diff --git a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts
index 7cbcae5..b5f092f 100644
--- a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts
+++ b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts
@@ -1,9 +1,6 @@
import { gql } from '@apollo/client';
-import { getQuotesByLeadQuery } from 'core/graphql/query/crm/quote';
import CrmService from 'core/services/CrmService';
-import { currentISODate } from 'core/tools/date';
-import { IReactionEffect } from 'core/types/Calculation/Store/effect';
-import { Process } from 'core/types/Calculation/Store/process';
+import { quotesByLeadQuery } from 'core/services/CrmService/graphql/query/quote';
import {
IAccount,
IEvoEquipment,
@@ -13,8 +10,11 @@ import {
IEvoTown,
IQuote,
ISalonProvider,
-} from 'core/types/Entities/crmEntities';
-import { ElementStatus } from 'core/types/statuses';
+} from 'core/services/CrmService/types/entities';
+import { currentISODate } from 'core/tools/date';
+import { IReactionEffect } from 'core/types/Calculation/Store/effect';
+import { Process } from 'core/types/Calculation/Store/process';
+import { ElementStatus } from 'types/elements';
export default [
(calculationStore, calculationProcess) => ({
@@ -51,7 +51,7 @@ export default [
if (lead?.leadid) {
CrmService.getCRMOptions<'quotes', IQuote>({
- query: getQuotesByLeadQuery,
+ query: quotesByLeadQuery,
variables: {
leadid: lead?.leadid,
},
@@ -259,24 +259,6 @@ export default [
},
}),
- (calculationStore, calculationProcess) => ({
- expression: () => {
- const { account } = calculationStore.values;
- return account;
- },
- effect: account => {
- if (calculationProcess.hasProcess(Process.LoadKp)) {
- return;
- }
- if (account && account.length > 0) {
- calculationStore.setStatus('tbxNewClient', ElementStatus.Disabled);
- calculationStore.setValue('newClient', null);
- } else {
- calculationStore.setStatus('tbxNewClient', ElementStatus.Default);
- }
- },
- }),
-
(calculationStore, calculationProcess) => ({
expression: () => {
const { indAgent } = calculationStore.values;
@@ -899,113 +881,6 @@ export default [
},
}),
- (calculationStore, calculationProcess) => ({
- expression: () => {
- const { supplier } = calculationStore.values;
- return supplier;
- },
- effect: supplierId => {
- if (calculationProcess.hasProcess(Process.LoadKp)) {
- return;
- }
- calculationStore.setOptions('selectFinDepartment', []);
- calculationStore.setValue('finDepartment', null);
- if (supplierId) {
- const supplier = calculationStore.getOption('selectSupplier', {
- accountid: supplierId,
- });
- if (supplier && supplier.evo_fin_department_accountid)
- CrmService.getCRMOptions<'accountOptions', IAccount>({
- query: gql`
- query selectFinDepartment($accountid: Uuid!) {
- accountOptions: account(accountid: $accountid) {
- accountid
- name
- }
- }
- `,
- variables: {
- accountid: supplier.evo_fin_department_accountid,
- },
- }).then(({ accountOptions }) => {
- if (accountOptions) {
- calculationStore.setOptions(
- 'selectFinDepartment',
- accountOptions,
- );
- }
- });
- }
- },
- }),
- (calculationStore, calculationProcess) => ({
- expression: () => {
- const { supplier, channel } = calculationStore.values;
- return { supplierId: supplier, channelId: channel };
- },
- //TODO: add $ownerid: Uuid
- effect: ({ supplierId, channelId }) => {
- if (calculationProcess.hasProcess(Process.LoadKp)) {
- return;
- }
- calculationStore.setOptions('selectAgent', []);
- calculationStore.setValue('agent', null);
- if (channelId === 100000002) {
- CrmService.getCRMOptions<'accountOptions', IAccount>({
- query: gql`
- query selectAgent_1(
- $statecode: Int
- $evo_account_type: [Int!]
- $evo_legal_form: Int
- ) {
- accountOptions: accounts(
- statecode: $statecode
- evo_account_type: $evo_account_type
- evo_legal_form: $evo_legal_form
- ) {
- accountid
- name
- }
- }
- `,
- variables: {
- statecode: 0,
- evo_account_type: [100000005],
- evo_legal_form: 100000004,
- },
- }).then(({ accountOptions }) => {
- if (accountOptions) {
- calculationStore.setOptions('selectAgent', accountOptions);
- }
- });
- } else {
- if (supplierId) {
- CrmService.getCRMOptions<'accountOptions', IAccount>({
- query: gql`
- query selectAgent_2($statecode: Int, $salonaccountid: Uuid!) {
- account: salon_agents(
- statecode: $statecode
- salonaccountid: $salonaccountid
- ) {
- accountid
- name
- }
- }
- `,
- variables: {
- statecode: 0,
- salonaccountid: supplierId,
- },
- }).then(({ accountOptions }) => {
- if (accountOptions) {
- calculationStore.setOptions('selectAgent', accountOptions);
- }
- });
- }
- }
- },
- }),
-
(calculationStore, calculationProcess) => ({
expression: () => {
const { GPSBrand } = calculationStore.values;
diff --git a/src/client/stores/CalculationStore/Effects/reactions/statusReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/statusReactions.ts
index f1e76be..23983ed 100644
--- a/src/client/stores/CalculationStore/Effects/reactions/statusReactions.ts
+++ b/src/client/stores/CalculationStore/Effects/reactions/statusReactions.ts
@@ -1,6 +1,6 @@
+import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
-import { ElementsNames } from 'core/types/Calculation/Store/elements';
-import { ElementStatus } from 'core/types/statuses';
+import { ElementStatus } from 'types/elements';
const elementsNames: ElementsNames[] = [
'selectModel',
diff --git a/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts
index 05b1dc9..c046633 100644
--- a/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts
+++ b/src/client/stores/CalculationStore/Effects/reactions/tablesReactions.ts
@@ -1,4 +1,4 @@
-/* eslint-disable @typescript-eslint/ban-ts-comment */
+import { Table } from 'client/Containers/Calculation/types/tables';
import { openNotification } from 'client/Elements/Notification';
import {
insuranceKaskoDefaultFilter,
@@ -9,9 +9,9 @@ import valuesConstants from 'core/constants/values';
import { shift, shiftRight } from 'core/tools/array';
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
import { Process } from 'core/types/Calculation/Store/process';
-import { ITableCell, TableProps } from 'core/types/Calculation/Store/tables';
-import { ElementStatus } from 'core/types/statuses';
import { toJS } from 'mobx';
+import { ElementStatus } from 'types/elements';
+
const { PERIODS_NUMBER } = valuesConstants;
export default [
@@ -122,9 +122,8 @@ export default [
},
effect: ({ insTerm, leasingPeriod }) => {
const quote = calculationStore.getOption('selectQuote');
- const recalcWithRevision = calculationStore.getValue(
- 'recalcWithRevision',
- );
+ const recalcWithRevision =
+ calculationStore.getValue('recalcWithRevision');
if (
recalcWithRevision &&
quote?.evo_one_year_insurance &&
@@ -406,12 +405,8 @@ export default [
(calculationStore, calculationProcess) => ({
expression: () => {
- const {
- leasingPeriod,
- graphType,
- parmentsDecreasePercent,
- seasonType,
- } = calculationStore.values;
+ const { leasingPeriod, graphType, parmentsDecreasePercent, seasonType } =
+ calculationStore.values;
const highSeasonStart = calculationStore.getOption(
'selectHighSeasonStart',
@@ -442,7 +437,7 @@ export default [
const prevValues = toJS(calculationStore.tables.tablePayments.rows).map(
x => x.paymentRelation?.value,
);
- let payments: TableProps[] = [
+ let payments: Table['rows'] = [
{
paymentRelation: {
value: firstPaymentPerc,
@@ -753,7 +748,8 @@ export default [
const prevIsTrailer = prevLeaseObjectCategory === 100000004;
if (nextIsTrailer) {
- const otherInsuranceCompany = calculationStore.tables.tableInsurance.options?.insuranceCompany?.find(
+ const otherInsuranceCompany =
+ calculationStore.tables.tableInsurance.options?.insuranceCompany?.find(
x => x.name?.includes('ПРОЧИЕ'),
);
if (otherInsuranceCompany) {
diff --git a/src/client/stores/CalculationStore/Effects/when.ts b/src/client/stores/CalculationStore/Effects/when.ts
index d6aa06a..63db053 100644
--- a/src/client/stores/CalculationStore/Effects/when.ts
+++ b/src/client/stores/CalculationStore/Effects/when.ts
@@ -1,4 +1,4 @@
-import { initIns } from 'client/Components/Calculation/ELT/Content/lib/resetIns';
+import { initIns } from 'client/Containers/Calculation/Components/ELT/lib/resetIns';
import { IWhenEffect } from 'core/types/Calculation/Store/effect';
const whenEffects: IWhenEffect[] = [
diff --git a/src/client/stores/CalculationStore/config/initialFilters.ts b/src/client/stores/CalculationStore/config/initialFilters.ts
index 96bd1a1..2f0fdc4 100644
--- a/src/client/stores/CalculationStore/config/initialFilters.ts
+++ b/src/client/stores/CalculationStore/config/initialFilters.ts
@@ -1,10 +1,7 @@
-import {
- ElementsNames,
- TElements,
-} from 'core/types/Calculation/Store/elements';
+import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { TElementFilter } from 'core/types/Calculation/Store/filters';
-const initialFilters: TElements = {};
+const initialFilters: Partial> = {};
export const noResetValueElements: ElementsNames[] = ['selectTechnicalCard'];
diff --git a/src/client/stores/CalculationStore/config/initialOptions.ts b/src/client/stores/CalculationStore/config/initialOptions.ts
index 08eb924..0f5cb8a 100644
--- a/src/client/stores/CalculationStore/config/initialOptions.ts
+++ b/src/client/stores/CalculationStore/config/initialOptions.ts
@@ -1,42 +1,8 @@
+import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { IBaseOption } from 'core/services/CrmService/types/common';
-import { TElements } from 'core/types/Calculation/Store/elements';
import { orderBy } from 'lodash';
-const initialOptions: TElements = {
- selectChannel: [
- {
- name: 'От агента-ФЛ-сотрудника поставщика',
- value: 100000000,
- },
- {
- name: 'Поставщик (финотдел)',
- value: 100000001,
- },
- {
- name: 'От агента-ФЛ (не сотрудник поставщика)',
- value: 100000002,
- },
- {
- name: 'Брокер (ЮЛ/ИП не связан с поставщиком)',
- value: 100000003,
- },
- {
- name: 'Прочее',
- value: 100000004,
- },
- ],
-
- radioContactGender: [
- {
- name: 'Мужской',
- value: 100000000,
- },
- {
- name: 'Женский',
- value: 100000001,
- },
- ],
-
+const initialOptions: Partial> = {
radioLastPaymentRule: [
{
name: 'рублей',
diff --git a/src/client/stores/CalculationStore/config/initialStatuses.ts b/src/client/stores/CalculationStore/config/initialStatuses.ts
index 9784cab..33e2543 100644
--- a/src/client/stores/CalculationStore/config/initialStatuses.ts
+++ b/src/client/stores/CalculationStore/config/initialStatuses.ts
@@ -1,13 +1,13 @@
-import { TElements } from 'core/types/Calculation/Store/elements';
-import { ElementStatus } from 'core/types/statuses';
+import { InteractionElementsNames } from 'client/Containers/Calculation/types/elements';
+import { ElementStatus } from 'types/elements';
-const initialStatuses: TElements = {
+const initialStatuses: Partial<
+ Record
+> = {
selectIndAgent: ElementStatus.Disabled,
selectCalcBroker: ElementStatus.Disabled,
selectCalcFinDepartment: ElementStatus.Disabled,
- selectDoubleAgent: ElementStatus.Disabled,
selectCalcDoubleAgent: ElementStatus.Disabled,
- tbxInsKaskoPriceLeasePeriod: ElementStatus.Disabled,
selectClientType: ElementStatus.Disabled,
// selectTelematic: ElementStatus.Disabled,
tbxImporterRewardRub: ElementStatus.Disabled,
@@ -17,23 +17,6 @@ const initialStatuses: TElements = {
selectRate: ElementStatus.Disabled,
selectTarif: ElementStatus.Disabled,
- selectChannel: ElementStatus.Disabled,
- tbxNewClient: ElementStatus.Disabled,
- selectAccount: ElementStatus.Disabled,
- tbxINN: ElementStatus.Disabled,
- tbxKPP: ElementStatus.Disabled,
- selectContactClient: ElementStatus.Disabled,
- tbxContact: ElementStatus.Disabled,
- radioContactGender: ElementStatus.Disabled,
- tbxPhoneNumber: ElementStatus.Disabled,
- tbxEmailAddress: ElementStatus.Disabled,
- selectSupplier: ElementStatus.Disabled,
- selectFinDepartment: ElementStatus.Disabled,
- selectBroker: ElementStatus.Disabled,
- selectAgent: ElementStatus.Disabled,
- tbxCommentLead: ElementStatus.Disabled,
- btnCreateLead: ElementStatus.Disabled,
-
// selectTracker: ElementStatus.Disabled,
tbxVehicleTaxInLeasingPeriod: ElementStatus.Disabled,
diff --git a/src/client/stores/CalculationStore/config/initialTables.ts b/src/client/stores/CalculationStore/config/initialTables.ts
index 0212a40..bc82d51 100644
--- a/src/client/stores/CalculationStore/config/initialTables.ts
+++ b/src/client/stores/CalculationStore/config/initialTables.ts
@@ -1,4 +1,4 @@
-import tables from 'client/Containers/Calculation/lib/elements/tables';
+import tables from 'client/Containers/Calculation/Elements/tables';
import { pick } from 'lodash';
export default Object.keys(tables).reduce((o, tableName) => {
diff --git a/src/client/stores/CalculationStore/config/initialValues.ts b/src/client/stores/CalculationStore/config/initialValues.ts
index 9d661db..f8c09fa 100644
--- a/src/client/stores/CalculationStore/config/initialValues.ts
+++ b/src/client/stores/CalculationStore/config/initialValues.ts
@@ -1,16 +1,12 @@
import valuesConstants from 'core/constants/values';
import { currentYear } from 'core/tools/date';
-import { TValue, TValues } from 'core/types/Calculation/Store/values';
+import { ValuesNames } from 'core/types/Calculation/Store/values';
-const initialValues: TValues = {
+const initialValues: Partial> = {
lead: null,
opportunity: null,
quote: null,
- channel: null,
- contactClient: null,
- account: null,
recalcWithRevision: false,
- contactGender: 100000000,
leaseObjectPrice: 1000000,
supplierCurrency: 'RUB',
supplierDiscountRub: 0,
diff --git a/src/client/stores/CalculationStore/init/requests.ts b/src/client/stores/CalculationStore/init/requests.ts
index 1bb9f75..cb987c7 100644
--- a/src/client/stores/CalculationStore/init/requests.ts
+++ b/src/client/stores/CalculationStore/init/requests.ts
@@ -1,44 +1,38 @@
+
+import { ElementsNames } from 'client/Containers/Calculation/types/elements';
+import { TableValuesNames } from 'client/Containers/Calculation/types/tables';
import UserStore from 'client/stores/UserStore';
-import {
- getInsuranceOptionsQuery,
- getMainOptionsQuery,
- getOwnerOptionsQuery,
-} from 'core/graphql/query/crm/options';
-import {
- getStaticDataQuery,
- getSystemUserQuery,
-} from 'core/graphql/query/crm/staticData';
import CrmService from 'core/services/CrmService';
-import { ElementsNames } from 'core/types/Calculation/Store/elements';
-import { TableValuesNames } from 'core/types/Calculation/Store/tables';
import {
- IAccount,
- ILead,
- IOpportunity,
- ISystemUser,
- TCRMEntity,
-} from 'core/types/Entities/crmEntities';
-import { CRMEntityNames } from 'core/types/Entities/crmEntityNames';
+ insuranceOptionsQuery,
+ mainOptionsQuery,
+ ownerOptionsQuery
+} from 'core/services/CrmService/graphql/query/options';
+import {
+ staticDataQuery,
+ systemUserQuery
+} from 'core/services/CrmService/graphql/query/staticData';
+import { CRMEntity, CRMEntityNames, IAccount, ILead, IOpportunity, ISystemUser } from 'core/services/CrmService/types/entities';
import {
insuranceVariables,
mainOptionsVariables,
- staticDataVariables,
+ staticDataVariables
} from './variables';
+
export function composeRequests() {
- const mainOptionsRequest = CrmService.getCRMOptions<
- ElementsNames,
- TCRMEntity
- >({
- query: getMainOptionsQuery,
- variables: mainOptionsVariables,
- });
+ const mainOptionsRequest = CrmService.getCRMOptions(
+ {
+ query: mainOptionsQuery,
+ variables: mainOptionsVariables,
+ },
+ );
const staticDataRequest = CrmService.getCRMEntities<
CRMEntityNames,
- TCRMEntity[]
+ CRMEntity[]
>({
- query: getStaticDataQuery,
+ query: staticDataQuery,
variables: staticDataVariables,
});
@@ -48,7 +42,7 @@ export function composeRequests() {
'systemuser',
ISystemUser
>({
- query: getSystemUserQuery,
+ query: systemUserQuery,
variables: { domainname },
});
@@ -56,7 +50,7 @@ export function composeRequests() {
ElementsNames,
ILead & IOpportunity
>({
- query: getOwnerOptionsQuery,
+ query: ownerOptionsQuery,
variables: {
statecode: 0,
domainname,
@@ -65,7 +59,7 @@ export function composeRequests() {
const insuranceRequest = CrmService.getCRMOptions(
{
- query: getInsuranceOptionsQuery,
+ query: insuranceOptionsQuery,
variables: insuranceVariables,
},
);
diff --git a/src/client/stores/CalculationStore/init/variables.ts b/src/client/stores/CalculationStore/init/variables.ts
index 81dba3c..b2a26ec 100644
--- a/src/client/stores/CalculationStore/init/variables.ts
+++ b/src/client/stores/CalculationStore/init/variables.ts
@@ -1,8 +1,8 @@
+import { CRMEntity, IAccount } from 'core/services/CrmService/types/entities';
import { currentISODate } from 'core/tools/date';
-import { IAccount, TCRMEntity } from 'core/types/Entities/crmEntities';
export const mainOptionsVariables:
- | Partial>
+ | Partial>
| Record = {
currentDate: currentISODate,
statecode: 0,
diff --git a/src/client/stores/CalculationStore/subStores/calculationProcess.ts b/src/client/stores/CalculationStore/subStores/calculationProcess.ts
index 2495d78..eabe77a 100644
--- a/src/client/stores/CalculationStore/subStores/calculationProcess.ts
+++ b/src/client/stores/CalculationStore/subStores/calculationProcess.ts
@@ -1,12 +1,12 @@
+import { InteractionElementsNames } from 'client/Containers/Calculation/types/elements';
+import { TableNames } from 'client/Containers/Calculation/types/tables';
import { ElementParam } from 'core/types/Calculation/Store';
-import { ElementsNames } from 'core/types/Calculation/Store/elements';
-import { TableNames } from 'core/types/Calculation/Store/tables';
-import { ElementStatus } from 'core/types/statuses';
import { makeAutoObservable } from 'mobx';
+import { ElementStatus } from 'types/elements';
type BypassParams = {
param: ElementParam;
- target: (ElementsNames | TableNames)[];
+ target: (InteractionElementsNames | TableNames)[];
value: ElementStatus;
};
diff --git a/src/client/stores/CalculationStore/subStores/eltStore.ts b/src/client/stores/CalculationStore/subStores/eltStore.ts
index 54b8b0e..7392e49 100644
--- a/src/client/stores/CalculationStore/subStores/eltStore.ts
+++ b/src/client/stores/CalculationStore/subStores/eltStore.ts
@@ -1,5 +1,5 @@
-// @ts-nocheck
-import { initFields } from 'client/Components/Calculation/ELT/Content/lib/resetIns';
+//@ts-nocheck
+import { initFields } from 'client/Containers/Calculation/Components/ELT/lib/resetIns';
import { isEqual } from 'lodash';
import { makeAutoObservable, toJS } from 'mobx';
diff --git a/src/core/graphql/query/crm/options/index.js b/src/core/graphql/query/crm/options/index.js
deleted file mode 100644
index f78403c..0000000
--- a/src/core/graphql/query/crm/options/index.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import { loader } from 'graphql.macro';
-
-export const getMainOptionsQuery = loader('./getMainOptions.graphql');
-export const getOwnerOptionsQuery = loader('./getOwnerOptions.graphql');
-export const getInsuranceOptionsQuery = loader('./getInsuranceOptions.graphql');
diff --git a/src/core/graphql/query/crm/quote/index.js b/src/core/graphql/query/crm/quote/index.js
deleted file mode 100644
index 4ff1245..0000000
--- a/src/core/graphql/query/crm/quote/index.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import { loader } from 'graphql.macro';
-
-export const getQuotesByLeadQuery = loader('./getQuotesByLead.graphql');
-export const getQuoteQuery = loader('./getQuote.graphql');
-
-export const getMainOptionsForQuote = loader(
- './options/getMainOptions.graphql',
-);
-export const getSecondaryOptionsForQuote = loader(
- './options/getSecondaryOptions.graphql',
-);
-export const getSingleOptionsForQuote = loader(
- './options/getSingleOptions.graphql',
-);
diff --git a/src/core/graphql/query/crm/staticData/index.js b/src/core/graphql/query/crm/staticData/index.js
deleted file mode 100644
index 96c42e3..0000000
--- a/src/core/graphql/query/crm/staticData/index.js
+++ /dev/null
@@ -1,4 +0,0 @@
-import { loader } from 'graphql.macro';
-
-export const getStaticDataQuery = loader('./getStaticData.graphql');
-export const getSystemUserQuery = loader('./getSystemUser.graphql');
diff --git a/src/core/services/1CService/index.js b/src/core/services/1CService/index.js
index 8db7e56..f3e25e0 100644
--- a/src/core/services/1CService/index.js
+++ b/src/core/services/1CService/index.js
@@ -1,3 +1,3 @@
-import leasingTrial from './leasingTrial';
+import leasingTrial from './leasing-trial';
export default { leasingTrial };
diff --git a/src/core/services/1CService/leasing-trial.ts b/src/core/services/1CService/leasing-trial.ts
new file mode 100644
index 0000000..fd28cd4
--- /dev/null
+++ b/src/core/services/1CService/leasing-trial.ts
@@ -0,0 +1,13 @@
+import axios from 'axios';
+import { _1C_PROXY_URL } from 'core/constants/urls';
+import { IGetTransTaxRequest, IGetTransTaxResponse } from './types';
+
+export default class {
+ static getTransTax = (payload: IGetTransTaxRequest) =>
+ axios
+ .post(
+ String.prototype.concat(_1C_PROXY_URL, '/leasingTrial', '/transTax'),
+ payload,
+ )
+ .then(res => res.data);
+}
diff --git a/src/core/services/1CService/leasingTrial.ts b/src/core/services/1CService/leasingTrial.ts
deleted file mode 100644
index b07f06a..0000000
--- a/src/core/services/1CService/leasingTrial.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import axios from 'axios';
-import { _1C_PROXY_URL } from 'core/constants/urls';
-import { wrapRequest } from 'core/tools/request';
-import { IGetTransTaxRequest } from 'core/types/Calculation/Requests';
-import { IGetTransTaxResponse } from 'core/types/Calculation/Responses';
-
-export default class {
- static getTransTax = (
- payload: IGetTransTaxRequest,
- ): Promise =>
- wrapRequest(
- axios.post(
- String.prototype.concat(_1C_PROXY_URL, '/leasingTrial', '/transTax'),
- payload,
- ),
- );
-}
diff --git a/src/core/services/1CService/types.ts b/src/core/services/1CService/types.ts
new file mode 100644
index 0000000..3d05d0e
--- /dev/null
+++ b/src/core/services/1CService/types.ts
@@ -0,0 +1,11 @@
+export interface IGetTransTaxRequest {
+ calcDate: Date;
+ OKTMO: string;
+ carCategory: string;
+ power: number;
+ year: number;
+}
+export interface IGetTransTaxResponse {
+ tax: number;
+ error: string;
+}
diff --git a/src/core/services/CalculationService/index.ts b/src/core/services/CalculationService/index.ts
index 95fe4be..9732d57 100644
--- a/src/core/services/CalculationService/index.ts
+++ b/src/core/services/CalculationService/index.ts
@@ -1,28 +1,18 @@
import axios from 'axios';
import { CORE_PROXY_URL } from 'core/constants/urls';
-import { IPreparedData } from 'core/types/Calculation/Requests';
-import { IGetCalculationResponse } from 'core/types/Calculation/Responses';
+import { GetCalculationResponse, PreparedData } from './types/request';
export default class {
- static calculate = (
- preparedData: IPreparedData,
- ): Promise =>
- new Promise((resolve, reject) => {
- axios
- .post(
- String.prototype.concat(
- CORE_PROXY_URL,
- '/api',
- '/calculation',
- '/calculate',
- ),
- preparedData,
- )
- .then(res => {
- resolve(res.data);
- })
- .catch(err => {
- reject(err);
- });
- });
+ static calculate = (preparedData: PreparedData) =>
+ axios
+ .post(
+ String.prototype.concat(
+ CORE_PROXY_URL,
+ '/api',
+ '/calculation',
+ '/calculate',
+ ),
+ preparedData,
+ )
+ .then(res => res.data);
}
diff --git a/src/core/types/Calculation/Core.ts b/src/core/services/CalculationService/types/columns.ts
similarity index 86%
rename from src/core/types/Calculation/Core.ts
rename to src/core/services/CalculationService/types/columns.ts
index 2764f92..b86caf8 100644
--- a/src/core/types/Calculation/Core.ts
+++ b/src/core/services/CalculationService/types/columns.ts
@@ -1,4 +1,4 @@
-export type IColumn = {
+export type Column = {
irr: number;
xnpv: number;
nominal: number;
@@ -61,14 +61,3 @@ export type ColumnsNames =
| 'cashflowMsfoFinal2Column'
| 'cashflowNpvFinal2Column'
| 'npvFinal2Column';
-
-export interface PostValues {
- baseCost: number;
- bonusBase: number;
- priceUP: number;
- priceUP_PR: number;
- priceUP_Year: number;
- priceUP_Year_PR: number;
- npvni: number;
- bonusResult: number;
-}
diff --git a/src/core/services/CalculationService/types/post.ts b/src/core/services/CalculationService/types/post.ts
new file mode 100644
index 0000000..41a2d64
--- /dev/null
+++ b/src/core/services/CalculationService/types/post.ts
@@ -0,0 +1,10 @@
+export interface PostValues {
+ baseCost: number;
+ bonusBase: number;
+ priceUP: number;
+ priceUP_PR: number;
+ priceUP_Year: number;
+ priceUP_Year_PR: number;
+ npvni: number;
+ bonusResult: number;
+}
diff --git a/src/core/types/Calculation/Prepare.ts b/src/core/services/CalculationService/types/prepared.ts
similarity index 100%
rename from src/core/types/Calculation/Prepare.ts
rename to src/core/services/CalculationService/types/prepared.ts
diff --git a/src/core/services/CalculationService/types/request.ts b/src/core/services/CalculationService/types/request.ts
new file mode 100644
index 0000000..ff0ba6e
--- /dev/null
+++ b/src/core/services/CalculationService/types/request.ts
@@ -0,0 +1,17 @@
+import {
+ PreparedPayments,
+ PreparedValues,
+} from 'core/services/CalculationService/types/prepared';
+import { Column, ColumnsNames } from './columns';
+import { PostValues } from './post';
+
+export interface PreparedData {
+ preparedPayments: PreparedPayments;
+ preparedValues: PreparedValues;
+}
+
+export interface GetCalculationResponse {
+ columns: Record;
+ postValues: PostValues;
+ preparedValues: PreparedValues;
+}
diff --git a/src/core/services/CrmService/common/entitiesProps.ts b/src/core/services/CrmService/common/entities-props.ts
similarity index 93%
rename from src/core/services/CrmService/common/entitiesProps.ts
rename to src/core/services/CrmService/common/entities-props.ts
index c4c16d5..0735072 100644
--- a/src/core/services/CrmService/common/entitiesProps.ts
+++ b/src/core/services/CrmService/common/entities-props.ts
@@ -1,15 +1,15 @@
import {
+ CRMEntity,
+ CRMEntityNames,
IAccount,
IEvoAddproductType,
IEvoEquipment,
- TCRMEntity,
-} from 'core/types/Entities/crmEntities';
-import { CRMEntityNames } from 'core/types/Entities/crmEntityNames';
+} from '../types/entities';
type TGetName = (entity: any, targetName: string) => string;
-export type TEntityProps = Record<'value', keyof TCRMEntity> & {
- name?: keyof TCRMEntity;
+export type TEntityProps = Record<'value', keyof CRMEntity> & {
+ name?: keyof CRMEntity;
getName?: TGetName;
};
diff --git a/src/core/graphql/client.ts b/src/core/services/CrmService/graphql/client.ts
similarity index 100%
rename from src/core/graphql/client.ts
rename to src/core/services/CrmService/graphql/client.ts
diff --git a/src/core/graphql/query/crm/fragments/evo_addproduct_types_fields.graphql b/src/core/services/CrmService/graphql/query/fragments/evo_addproduct_types_fields.graphql
similarity index 100%
rename from src/core/graphql/query/crm/fragments/evo_addproduct_types_fields.graphql
rename to src/core/services/CrmService/graphql/query/fragments/evo_addproduct_types_fields.graphql
diff --git a/src/core/graphql/query/crm/fragments/evo_regions_fields.graphql b/src/core/services/CrmService/graphql/query/fragments/evo_regions_fields.graphql
similarity index 100%
rename from src/core/graphql/query/crm/fragments/evo_regions_fields.graphql
rename to src/core/services/CrmService/graphql/query/fragments/evo_regions_fields.graphql
diff --git a/src/core/services/CrmService/graphql/query/options/index.js b/src/core/services/CrmService/graphql/query/options/index.js
new file mode 100644
index 0000000..b19bb94
--- /dev/null
+++ b/src/core/services/CrmService/graphql/query/options/index.js
@@ -0,0 +1,5 @@
+import { loader } from 'graphql.macro';
+
+export const mainOptionsQuery = loader('./main_options.graphql');
+export const ownerOptionsQuery = loader('./owner_options.graphql');
+export const insuranceOptionsQuery = loader('./insurance_options.graphql');
diff --git a/src/core/graphql/query/crm/options/getInsuranceOptions.graphql b/src/core/services/CrmService/graphql/query/options/insurance_options.graphql
similarity index 100%
rename from src/core/graphql/query/crm/options/getInsuranceOptions.graphql
rename to src/core/services/CrmService/graphql/query/options/insurance_options.graphql
diff --git a/src/core/graphql/query/crm/options/getMainOptions.graphql b/src/core/services/CrmService/graphql/query/options/main_options.graphql
similarity index 100%
rename from src/core/graphql/query/crm/options/getMainOptions.graphql
rename to src/core/services/CrmService/graphql/query/options/main_options.graphql
diff --git a/src/core/graphql/query/crm/options/getOwnerOptions.graphql b/src/core/services/CrmService/graphql/query/options/owner_options.graphql
similarity index 100%
rename from src/core/graphql/query/crm/options/getOwnerOptions.graphql
rename to src/core/services/CrmService/graphql/query/options/owner_options.graphql
diff --git a/src/core/graphql/query/crm/quote/fragments/quoteFields.graphql b/src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql
similarity index 100%
rename from src/core/graphql/query/crm/quote/fragments/quoteFields.graphql
rename to src/core/services/CrmService/graphql/query/quote/fragments/quoteFields.graphql
diff --git a/src/core/graphql/query/crm/quote/fragments/quoteFieldsLite.graphql b/src/core/services/CrmService/graphql/query/quote/fragments/quoteFieldsLite.graphql
similarity index 100%
rename from src/core/graphql/query/crm/quote/fragments/quoteFieldsLite.graphql
rename to src/core/services/CrmService/graphql/query/quote/fragments/quoteFieldsLite.graphql
diff --git a/src/core/services/CrmService/graphql/query/quote/index.js b/src/core/services/CrmService/graphql/query/quote/index.js
new file mode 100644
index 0000000..d57c5eb
--- /dev/null
+++ b/src/core/services/CrmService/graphql/query/quote/index.js
@@ -0,0 +1,14 @@
+import { loader } from 'graphql.macro';
+
+export const quotesByLeadQuery = loader('./quotes_by_lead.graphql');
+export const quoteQuery = loader('./quote.graphql');
+
+export const mainOptionsForQuoteQuery = loader(
+ './options/main_options.graphql',
+);
+export const secondaryOptionsForQuoteQuery = loader(
+ './options/secondary_options.graphql',
+);
+export const singleOptionsForQuoteQuery = loader(
+ './options/single_options.graphql',
+);
diff --git a/src/core/graphql/query/crm/quote/options/getMainOptions.graphql b/src/core/services/CrmService/graphql/query/quote/options/main_options.graphql
similarity index 100%
rename from src/core/graphql/query/crm/quote/options/getMainOptions.graphql
rename to src/core/services/CrmService/graphql/query/quote/options/main_options.graphql
diff --git a/src/core/graphql/query/crm/quote/options/getSecondaryOptions.graphql b/src/core/services/CrmService/graphql/query/quote/options/secondary_options.graphql
similarity index 100%
rename from src/core/graphql/query/crm/quote/options/getSecondaryOptions.graphql
rename to src/core/services/CrmService/graphql/query/quote/options/secondary_options.graphql
diff --git a/src/core/graphql/query/crm/quote/options/getSingleOptions.graphql b/src/core/services/CrmService/graphql/query/quote/options/single_options.graphql
similarity index 100%
rename from src/core/graphql/query/crm/quote/options/getSingleOptions.graphql
rename to src/core/services/CrmService/graphql/query/quote/options/single_options.graphql
diff --git a/src/core/graphql/query/crm/quote/getQuote.graphql b/src/core/services/CrmService/graphql/query/quote/quote.graphql
similarity index 100%
rename from src/core/graphql/query/crm/quote/getQuote.graphql
rename to src/core/services/CrmService/graphql/query/quote/quote.graphql
diff --git a/src/core/graphql/query/crm/quote/getQuotesByLead.graphql b/src/core/services/CrmService/graphql/query/quote/quotes_by_lead.graphql
similarity index 100%
rename from src/core/graphql/query/crm/quote/getQuotesByLead.graphql
rename to src/core/services/CrmService/graphql/query/quote/quotes_by_lead.graphql
diff --git a/src/core/services/CrmService/graphql/query/staticData/index.js b/src/core/services/CrmService/graphql/query/staticData/index.js
new file mode 100644
index 0000000..0bedca7
--- /dev/null
+++ b/src/core/services/CrmService/graphql/query/staticData/index.js
@@ -0,0 +1,4 @@
+import { loader } from 'graphql.macro';
+
+export const staticDataQuery = loader('./static_data.graphql');
+export const systemUserQuery = loader('./systemuser.graphql');
diff --git a/src/core/graphql/query/crm/staticData/getStaticData.graphql b/src/core/services/CrmService/graphql/query/staticData/static_data.graphql
similarity index 100%
rename from src/core/graphql/query/crm/staticData/getStaticData.graphql
rename to src/core/services/CrmService/graphql/query/staticData/static_data.graphql
diff --git a/src/core/graphql/query/crm/staticData/getSystemUser.graphql b/src/core/services/CrmService/graphql/query/staticData/systemuser.graphql
similarity index 100%
rename from src/core/graphql/query/crm/staticData/getSystemUser.graphql
rename to src/core/services/CrmService/graphql/query/staticData/systemuser.graphql
diff --git a/src/core/graphql/schemas/crm.graphql b/src/core/services/CrmService/graphql/schema.graphql
similarity index 100%
rename from src/core/graphql/schemas/crm.graphql
rename to src/core/services/CrmService/graphql/schema.graphql
diff --git a/src/core/services/CrmService/index.ts b/src/core/services/CrmService/index.ts
index f6031e4..c4e39c7 100644
--- a/src/core/services/CrmService/index.ts
+++ b/src/core/services/CrmService/index.ts
@@ -1,9 +1,9 @@
import { QueryOptions } from '@apollo/client';
import axios from 'axios';
import { CRM_PROXY_URL } from 'core/constants/urls';
-import GQLClient from 'core/graphql/client';
-import { IQuote } from 'core/types/Entities/crmEntities';
+import GQLClient from './graphql/client';
import { optionizeEntities } from './tools/entity';
+import { IQuote } from './types/entities';
export default class {
public static getCRMEntities(
diff --git a/src/core/services/CrmService/tools/entity.ts b/src/core/services/CrmService/tools/entity.ts
index babfd7c..a5ebdb0 100644
--- a/src/core/services/CrmService/tools/entity.ts
+++ b/src/core/services/CrmService/tools/entity.ts
@@ -1,6 +1,6 @@
-import { CoreEntity } from 'core/types/Entities/crmEntities';
-import entitiesProps, { TEntityProps } from '../common/entitiesProps';
+import entitiesProps, { TEntityProps } from '../common/entities-props';
import { TOptionizedEntity } from '../types/common';
+import { CoreEntity } from '../types/entities';
function convertEntityToOption(
targetName: string,
@@ -12,9 +12,11 @@ function convertEntityToOption(
throw new Error(`${entityName} was not found in propsMap!`);
}
- const { name: nameProp, getName, value: valueProp } = entitiesProps[
- entityName
- ];
+ const {
+ name: nameProp,
+ getName,
+ value: valueProp,
+ } = entitiesProps[entityName];
let name: string = entity[nameProp];
if (getName) name = getName(entity, targetName);
diff --git a/src/core/services/CrmService/types/common.ts b/src/core/services/CrmService/types/common.ts
index 5655b6c..bc0271d 100644
--- a/src/core/services/CrmService/types/common.ts
+++ b/src/core/services/CrmService/types/common.ts
@@ -1,8 +1,10 @@
-import { BaseEntity } from 'core/types/Entities/crmEntities';
+import { BaseEntity } from './entities';
+
export type IBaseOption = {
name: string;
value: any;
[prop: string]: any;
};
+// TODO: T extends BaseEntity
export type TOptionizedEntity = T & IBaseOption;
diff --git a/src/core/types/Entities/crmEntities.ts b/src/core/services/CrmService/types/entities.ts
similarity index 94%
rename from src/core/types/Entities/crmEntities.ts
rename to src/core/services/CrmService/types/entities.ts
index 3a95a0e..5057482 100644
--- a/src/core/types/Entities/crmEntities.ts
+++ b/src/core/services/CrmService/types/entities.ts
@@ -1,4 +1,35 @@
-import { CRMEntityNames } from './crmEntityNames';
+export type CRMEntityNames =
+ | 'account'
+ | 'lead'
+ | 'opportunity'
+ | 'quote'
+ | 'contact'
+ | 'transactioncurrency'
+ | 'evo_client_type'
+ | 'evo_client_risk'
+ | 'evo_baseproduct'
+ | 'evo_leasingobject_type'
+ | 'evo_brand'
+ | 'evo_model'
+ | 'evo_equipment'
+ | 'evo_reward_condition'
+ | 'evo_gps_brand'
+ | 'evo_gps_model'
+ | 'evo_region'
+ | 'evo_town'
+ | 'connection'
+ | 'evo_connection_role'
+ | 'evo_impairment_group'
+ | 'evo_currencychange'
+ | 'evo_statuscode'
+ | 'evo_coefficient'
+ | 'evo_addproduct_type'
+ | 'evo_tarif'
+ | 'evo_rate'
+ | 'evo_planpayment'
+ | 'systemuser'
+ | 'evo_sot_coefficient_type'
+ | 'evo_subsidy';
export interface CoreEntity {
__typename: CRMEntityNames;
@@ -421,7 +452,7 @@ export interface IEvoSubsidy extends BaseEntity {
accounts?: IAccount[];
}
-export type TCRMEntity = IAccount &
+export type CRMEntity = IAccount &
ILead &
IOpportunity &
IQuote &
diff --git a/src/core/services/ELTService/Kasko.js b/src/core/services/ELTService/Kasko.js
index 02c0b35..75896bc 100644
--- a/src/core/services/ELTService/Kasko.js
+++ b/src/core/services/ELTService/Kasko.js
@@ -1,16 +1,15 @@
import axios from 'axios';
import { ELT_PROXY_URL } from 'core/constants/urls';
-import { wrapRequest } from 'core/tools/request';
export default {
getCalculation: (payload, cancelToken) =>
- wrapRequest(
- axios.post(
+ axios
+ .post(
String.prototype.concat(ELT_PROXY_URL, '/insurance', '/calculateKasko'),
payload,
{
cancelToken,
},
- ),
- ),
+ )
+ .then(res => res.data),
};
diff --git a/src/core/services/ELTService/Osago.js b/src/core/services/ELTService/Osago.js
index 8d61fe6..486c164 100644
--- a/src/core/services/ELTService/Osago.js
+++ b/src/core/services/ELTService/Osago.js
@@ -1,14 +1,13 @@
import axios from 'axios';
import { ELT_PROXY_URL } from 'core/constants/urls';
-import { wrapRequest } from 'core/tools/request';
export default {
getCalculation: (payload, cancelToken) =>
- wrapRequest(
- axios.post(
+ axios
+ .post(
String.prototype.concat(ELT_PROXY_URL, '/insurance', '/calculateOsago'),
payload,
{ cancelToken },
- ),
- ),
+ )
+ .then(res => res.data),
};
diff --git a/src/core/services/UserService/index.js b/src/core/services/UserService/index.js
deleted file mode 100644
index c71b6fd..0000000
--- a/src/core/services/UserService/index.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import axios from 'axios';
-import { AUTH_PROXY_URL } from 'core/constants/urls';
-import { wrapRequest } from 'core/tools/request';
-
-export default class {
- static fetchUser = () =>
- wrapRequest(axios.get(String.prototype.concat(AUTH_PROXY_URL, '/user')));
-}
diff --git a/src/core/services/UserService/index.ts b/src/core/services/UserService/index.ts
new file mode 100644
index 0000000..98d95c4
--- /dev/null
+++ b/src/core/services/UserService/index.ts
@@ -0,0 +1,10 @@
+import axios from 'axios';
+import { AUTH_PROXY_URL } from 'core/constants/urls';
+import { User } from './types';
+
+export default class {
+ static fetchUser = () =>
+ axios
+ .get(String.prototype.concat(AUTH_PROXY_URL, '/user'))
+ .then(res => res.data);
+}
diff --git a/src/core/services/UserService/types.ts b/src/core/services/UserService/types.ts
new file mode 100644
index 0000000..11e110a
--- /dev/null
+++ b/src/core/services/UserService/types.ts
@@ -0,0 +1,7 @@
+export interface User {
+ department: string;
+ displayName: string;
+ domain: string;
+ mail: string;
+ username: string;
+}
diff --git a/src/core/tools/request.js b/src/core/tools/request.js
deleted file mode 100644
index 951c044..0000000
--- a/src/core/tools/request.js
+++ /dev/null
@@ -1,10 +0,0 @@
-export const wrapRequest = request =>
- new Promise((resolve, reject) => {
- request
- .then(res => {
- resolve(res.data);
- })
- .catch(err => {
- reject(err);
- });
- });
diff --git a/src/core/tools/validate.js b/src/core/tools/validate.js
deleted file mode 100644
index 42f2ccd..0000000
--- a/src/core/tools/validate.js
+++ /dev/null
@@ -1,91 +0,0 @@
-import isEmail from 'validator/es/lib/isEmail';
-import isMobilePhone from 'validator/es/lib/isMobilePhone';
-
-const isINNIndividual = value => {
- const valueToString = value ? value.toString() : '';
- const getN = index => parseInt(valueToString[index]);
- if (valueToString.length === 12) {
- const dgt11 =
- ((7 * getN(0) +
- 2 * getN(1) +
- 4 * getN(2) +
- 10 * getN(3) +
- 3 * getN(4) +
- 5 * getN(5) +
- 9 * getN(6) +
- 4 * getN(7) +
- 6 * getN(8) +
- 8 * getN(9)) %
- 11) %
- 10;
-
- const dgt12 =
- ((3 * getN(0) +
- 7 * getN(1) +
- 2 * getN(2) +
- 4 * getN(3) +
- 10 * getN(4) +
- 3 * getN(5) +
- 5 * getN(6) +
- 9 * getN(7) +
- 4 * getN(8) +
- 6 * getN(9) +
- 8 * getN(10)) %
- 11) %
- 10;
-
- return getN(10) === dgt11 && getN(11) === dgt12;
- }
- return false;
-};
-
-const isINNLegalEntity = value => {
- const valueToString = value ? value.toString() : '';
- const getN = index => parseInt(valueToString[index]);
- if (valueToString.length === 10) {
- const dgt10 =
- ((2 * getN(0) +
- 4 * getN(1) +
- 10 * getN(2) +
- 3 * getN(3) +
- 5 * getN(4) +
- 9 * getN(5) +
- 4 * getN(6) +
- 6 * getN(7) +
- 8 * getN(8)) %
- 11) %
- 10;
- return getN(9) === dgt10;
- }
- return false;
-};
-
-export function validateInn(value) {
- const stringValue = value ? value.toString() : '';
-
- if (stringValue.length === 10) {
- return isINNLegalEntity(stringValue);
- }
- if (stringValue.length === 12) {
- return isINNIndividual(stringValue);
- }
-
- return false;
-}
-
-export function validateKpp(value) {
- const stringValue = value ? value.toString() : '';
- if (stringValue.length !== 9) return false;
- if (!stringValue.match(/\d{4}[\dA-Z][\dA-Z]\d{3}/)) return false;
- return true;
-}
-
-export function validatePhone(value) {
- const stringValue = value ? value.toString() : '';
- return isMobilePhone(stringValue, ['ru-RU']);
-}
-
-export function validateEmail(value) {
- const stringValue = value ? value.toString() : '';
- return isEmail(stringValue);
-}
diff --git a/src/core/types/Calculation/Requests.ts b/src/core/types/Calculation/Requests.ts
deleted file mode 100644
index 0a3f2d2..0000000
--- a/src/core/types/Calculation/Requests.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import {
- PreparedPayments,
- PreparedValues,
-} from 'core/types/Calculation/Prepare';
-
-export interface IPreparedData {
- preparedPayments: PreparedPayments;
- preparedValues: PreparedValues;
-}
-
-export interface IGetTransTaxRequest {
- calcDate: Date;
- OKTMO: string;
- carCategory: string;
- power: number;
- year: number;
-}
diff --git a/src/core/types/Calculation/Responses.ts b/src/core/types/Calculation/Responses.ts
deleted file mode 100644
index 7beb35b..0000000
--- a/src/core/types/Calculation/Responses.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { ColumnsNames, IColumn, PostValues } from './Core';
-import { PreparedValues } from './Prepare';
-
-export interface IGetCalculationResponse {
- columns: { [column in ColumnsNames]?: IColumn };
- postValues: PostValues;
- preparedValues: PreparedValues;
-}
-
-export interface IGetTransTaxResponse {
- tax: number;
- error: string;
-}
diff --git a/src/core/types/Calculation/Store/effect.ts b/src/core/types/Calculation/Store/effect.ts
index b7771ee..1f5d0ed 100644
--- a/src/core/types/Calculation/Store/effect.ts
+++ b/src/core/types/Calculation/Store/effect.ts
@@ -2,7 +2,7 @@ import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/ca
import { IReactionOptions, IReactionPublic, Lambda } from 'mobx';
import { ICalculationStore } from './';
-export type ActionsNames = 'createLead' | 'calculate' | 'createKP';
+export type ActionsNames = 'calculate' | 'createKP';
export type TAction = {
[actionName in ActionsNames]?: () => void;
diff --git a/src/core/types/Calculation/Store/filters.ts b/src/core/types/Calculation/Store/filters.ts
index 5e4ad79..fd316ef 100644
--- a/src/core/types/Calculation/Store/filters.ts
+++ b/src/core/types/Calculation/Store/filters.ts
@@ -1,5 +1,4 @@
-import { IBaseOption } from 'core/services/CrmService/types/common';
-import { TCRMEntity } from 'core/types/Entities/crmEntities';
+import { TOptionizedEntity } from 'core/services/CrmService/types/common';
export type TElementFilter = (
- options: (TCRMEntity & IBaseOption)[],
-) => (TCRMEntity & IBaseOption)[];
+ options: TOptionizedEntity[],
+) => TOptionizedEntity[];
diff --git a/src/core/types/Calculation/Store/index.ts b/src/core/types/Calculation/Store/index.ts
index f329c75..a1c2d2f 100644
--- a/src/core/types/Calculation/Store/index.ts
+++ b/src/core/types/Calculation/Store/index.ts
@@ -1,3 +1,12 @@
+import {
+ ElementsNames,
+ InteractionElementsNames,
+} from 'client/Containers/Calculation/types/elements';
+import {
+ Table,
+ TableNames,
+ TableValuesNames,
+} from 'client/Containers/Calculation/types/tables';
import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess';
import { TCalculationUrls } from 'client/stores/CalculationStore/subStores/calculationUrls';
import { TELTStore } from 'client/stores/CalculationStore/subStores/eltStore';
@@ -5,21 +14,14 @@ import {
IBaseOption,
TOptionizedEntity,
} from 'core/services/CrmService/types/common';
-import { TCRMEntity } from '../../Entities/crmEntities';
-import { CRMEntityNames } from '../../Entities/crmEntityNames';
-import { ElementStatus } from '../../statuses';
-import { ElementsNames, TElements } from './elements';
+import {
+ CRMEntity,
+ CRMEntityNames,
+} from 'core/services/CrmService/types/entities';
+import { ElementStatus } from 'types/elements';
import { TElementFilter } from './filters';
import { TStaticData } from './staticData';
-import {
- ITable,
- ITableCell,
- StoreTables,
- TableNames,
- TableProps,
- TableValuesNames,
-} from './tables';
-import { ResultValuesNames, TValue, TValues, ValuesNames } from './values';
+import { AllValues, ValuesNames } from './values';
export type ElementParam =
| 'value'
@@ -30,26 +32,28 @@ export type ElementParam =
interface ICalculationValues {
staticData: TStaticData;
- getStaticData: (dataName: CRMEntityNames) => TCRMEntity[];
+ getStaticData: (dataName: CRMEntityNames) => CRMEntity[];
applyStaticData: (data: TStaticData) => void;
- options: TElements;
+ options: Record;
getOption: (
elementName: ElementsNames,
- fields?: { [field in keyof (IBaseOption & TCRMEntity)]?: any },
- ) => (IBaseOption & TCRMEntity) | undefined;
+ fields?: { [field in keyof TOptionizedEntity]?: any },
+ ) => (IBaseOption & CRMEntity) | undefined;
getOptions: (
elementName: ElementsNames,
- fields?: { [field in keyof (IBaseOption & TCRMEntity)]?: any },
+ fields?: { [field in keyof (IBaseOption & CRMEntity)]?: any },
filtered?: boolean,
- ) => (IBaseOption & TCRMEntity)[] | undefined;
+ ) => (IBaseOption & CRMEntity)[] | undefined;
setOptions: (
elementName: ElementsNames,
options: TOptionizedEntity[],
) => void;
- applyOptions: (options: TElements) => void;
+ applyOptions: (
+ options: Partial>,
+ ) => void;
- filters: TElements;
+ filters: Record;
getFilter: (elementName: ElementsNames) => TElementFilter | undefined;
setFilter: (
elementName: ElementsNames,
@@ -57,21 +61,27 @@ interface ICalculationValues {
) => void;
// applyFilters: (filters: TElementFilter[]) => void;
- values: TValues;
- getValue: (sourceValueName: ValuesNames) => TValue;
- getValues: (valuesNames: ValuesNames[]) => TValues;
- setValue: (
- sourceValueName: ValuesNames | ResultValuesNames,
- newValue: TValue,
+ values: Record;
+ getValue: (sourceValueName: ValuesNames) => any;
+ getValues: (valuesNames: ValuesNames[]) => Partial>;
+ setValue: (sourceValueName: ValuesNames, newValue: any) => void;
+ setValues: (
+ values: Partial>,
+ override?: boolean,
) => void;
- setValues: (values: TValues, override?: boolean) => void;
- statuses: TElements;
- getStatus: (elementName: ElementsNames) => ElementStatus;
- setStatus: (elementName: ElementsNames, status: ElementStatus) => void;
- setStatuses: (statuses: TElements, override?: boolean) => void;
+ statuses: Record;
+ getStatus: (elementName: InteractionElementsNames) => ElementStatus;
+ setStatus: (
+ elementName: InteractionElementsNames,
+ status: ElementStatus,
+ ) => void;
+ setStatuses: (
+ statuses: Partial>,
+ override?: boolean,
+ ) => void;
- validations: TElements;
+ validations: Record;
getValidation: (elementName: ElementsNames) => boolean;
setValidation: (
elementName: ElementsNames,
@@ -80,18 +90,18 @@ interface ICalculationValues {
}
interface ICalculationTables {
- tables: StoreTables;
+ tables: Record;
cleanTable: (tableName: TableNames) => void;
getTableRowValues: (
tableName: TableNames,
- rowIndex: number | ((rows: TableProps[]) => number),
+ rowIndex: number | ((rows: Table['rows']) => number),
paramName: ElementParam,
- ) => TableProps;
+ ) => Record;
getTableRowValue: (
tableName: TableNames,
- rowIndex: number | ((rows: TableProps[]) => number),
+ rowIndex: number | ((rows: Table['rows']) => number),
propName: TableValuesNames,
paramName: ElementParam,
) => any;
@@ -99,28 +109,26 @@ interface ICalculationTables {
getTableOptions: (
tableName: TableNames,
propName: TableValuesNames,
- ) => (IBaseOption & TCRMEntity)[] | undefined;
+ ) => TOptionizedEntity[];
- replaceTableRows: (
- tableName: TableNames,
- ) => (rows: TableProps[]) => void;
+ replaceTableRows: (tableName: TableNames) => (rows: Table['rows']) => void;
setTableRows: (
tableName: TableNames,
startIndex: number,
override?: boolean,
- ) => (rows: TableProps[]) => void;
+ ) => (rows: Table['rows']) => void;
setTableRow: (
tableName: TableNames,
- rowIndex: number | ((rows: TableProps[]) => number),
+ rowIndex: number | ((rows: Table['rows']) => number),
override?: boolean,
- ) => (row: TableProps) => void;
+ ) => (row: Table['rows'][number]) => void;
setTableColumns: (
tableName: TableNames,
override?: boolean,
- ) => ({ options }: { options?: TableProps }) => void;
+ ) => ({ options }: { options?: Table['options'] }) => void;
}
interface ICalculationStores {
diff --git a/src/core/types/Calculation/Store/staticData.ts b/src/core/types/Calculation/Store/staticData.ts
index 42e47db..db4ccb7 100644
--- a/src/core/types/Calculation/Store/staticData.ts
+++ b/src/core/types/Calculation/Store/staticData.ts
@@ -1,4 +1,6 @@
-import { TCRMEntity } from './../../Entities/crmEntities';
-import { TEntities } from './../../Entities/crmEntityNames';
+import {
+ CRMEntity,
+ CRMEntityNames,
+} from 'core/services/CrmService/types/entities';
-export type TStaticData = TEntities;
+export type TStaticData = Record;
diff --git a/src/core/types/Calculation/Store/tables.ts b/src/core/types/Calculation/Store/tables.ts
deleted file mode 100644
index 1fe51d6..0000000
--- a/src/core/types/Calculation/Store/tables.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess';
-import { IBaseOption } from 'core/services/CrmService/types/common';
-import { Component } from 'core/types/Calculation/components';
-import { ElementStatus } from '../../statuses';
-import { ElementProps } from '../components';
-import { ICalculationStore } from './';
-import { TCRMEntity } from './../../Entities/crmEntities';
-import { TElementFilter } from './filters';
-
-export type TableNames = 'tableInsurance' | 'tablePayments' | 'tableResults';
-export type TableValuesNames =
- | 'policyType'
- | 'insuranceCompany'
- | 'insured'
- | 'insCost'
- | 'insTerm'
- | 'paymentNumber'
- | 'paymentRelation'
- | 'paymentSum'
- | 'ndsCompensation'
- | 'redemptionAmount';
-
-export type TCellCallback = (props: {
- calculationStore: ICalculationStore;
- calculationProcess: TCalculationProcess;
- tableName: TableNames;
- rowIndex: number;
- value: any;
-}) => void;
-
-export type ITableCell = {
- value?: any;
- status?: ElementStatus;
- validation?: boolean;
- filter?: TElementFilter;
-};
-
-export type TableProps = {
- [propName in TableValuesNames]?: T;
-};
-
-export type TableRow = TableProps;
-export type TableColumnOptions = TableProps<(IBaseOption & TCRMEntity)[]>;
-export type TableColumnCallbacks = TableProps;
-
-export type TableColumn = {
- name: TableValuesNames;
- title: string;
- Component: Component;
- props?: ElementProps;
-};
-
-export type TableColumnFeatures = {
- [feature: string]: any;
-};
-
-export type TableParams = {
- features?: TableColumnFeatures;
- [param: string]: any;
-};
-
-export type ITable = {
- columns: TableColumn[];
- rows: TableRow[];
- options?: TableColumnOptions;
- params?: TableParams;
- callbacks?: TableColumnCallbacks;
-};
-
-export type StoreTables = {
- [table in TableNames]: T;
-};
diff --git a/src/core/types/Calculation/Store/values.ts b/src/core/types/Calculation/Store/values.ts
index f04a0cc..3f26b65 100644
--- a/src/core/types/Calculation/Store/values.ts
+++ b/src/core/types/Calculation/Store/values.ts
@@ -3,23 +3,6 @@ export type ValuesNames =
| 'opportunity'
| 'quote'
| 'recalcWithRevision'
- | 'template'
- | 'channel'
- | 'newClient'
- | 'account'
- | 'INN'
- | 'KPP'
- | 'contactClient'
- | 'contact'
- | 'contactGender'
- | 'phoneNumber'
- | 'emailAddress'
- | 'supplier'
- | 'finDepartment'
- | 'agent'
- | 'doubleAgent'
- | 'broker'
- | 'commentLead'
| 'product'
| 'clientRisk'
| 'clientType'
@@ -88,9 +71,7 @@ export type ValuesNames =
| 'townRegistration'
| 'infuranceOPF'
| 'insKaskoType'
- | 'insKaskoPriceLeasePeriod'
| 'insDecentral'
- | 'insPeriod'
| 'insFranchise'
| 'insUnlimitDrivers'
| 'insAgeDrivers'
@@ -136,7 +117,23 @@ export type ValuesNames =
| 'subsidy'
| 'subsidySum'
| 'fuelCard'
- | 'minPriceChange';
+ | 'minPriceChange'
+ | 'resultTotalGraphwithNDS'
+ | 'resultPlPrice'
+ | 'resultPriceUpPr'
+ | 'resultIRRGraphPerc'
+ | 'resultIRRNominalPerc'
+ | 'resultInsKasko'
+ | 'resultInsOsago'
+ | 'resultDopProdSum'
+ | 'resultFirstPayment'
+ | 'resultLastPayment'
+ | 'resultTerm'
+ | 'resultAB_FL'
+ | 'resultAB_UL'
+ | 'resultBonusMPL'
+ | 'resultDopMPLLeasing'
+ | 'resultBonusDopProd';
export type ComputedValuesNames =
| 'leaseObjectRiskName'
@@ -144,29 +141,4 @@ export type ComputedValuesNames =
| 'irrInfo'
| 'registrationDescription';
-export const resultsValues = [
- 'resultTotalGraphwithNDS',
- 'resultPlPrice',
- 'resultPriceUpPr',
- 'resultIRRGraphPerc',
- 'resultIRRNominalPerc',
- 'resultInsKasko',
- 'resultInsOsago',
- 'resultDopProdSum',
- 'resultFirstPayment',
- 'resultLastPayment',
- 'resultTerm',
- 'resultAB_FL',
- 'resultAB_UL',
- 'resultBonusMPL',
- 'resultDopMPLLeasing',
- 'resultBonusDopProd',
-] as const;
-type SuitTuple = typeof resultsValues;
-export type ResultValuesNames = SuitTuple[number];
-
-export type TValues = {
- [valueName in ValuesNames | ResultValuesNames | ComputedValuesNames]?: T;
-};
-
-export type TValue = any;
+export type AllValues = ValuesNames | ComputedValuesNames;
diff --git a/src/core/types/Calculation/components.ts b/src/core/types/Calculation/components.ts
deleted file mode 100644
index 8b6f658..0000000
--- a/src/core/types/Calculation/components.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { FC } from 'react';
-import { AllElements } from './Store/elements';
-import { TableNames } from './Store/tables';
-
-export type ElementProps = { [key: string]: any };
-export type Component = FC;
-
-interface IBlock {
- title?: string;
- elements: (AllElements | TableNames)[];
- [key: string]: any;
-}
-
-export interface IGroup {
- title?: string;
- blocks?: IBlock[];
- style?: { [key: string]: any };
-}
-
-export interface ISection {
- title?: string;
- groups?: IGroup[];
-}
diff --git a/src/core/types/Entities/crmEntityNames.ts b/src/core/types/Entities/crmEntityNames.ts
deleted file mode 100644
index 17391c0..0000000
--- a/src/core/types/Entities/crmEntityNames.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-export type CRMEntityNames =
- | 'account'
- | 'lead'
- | 'opportunity'
- | 'quote'
- | 'contact'
- | 'transactioncurrency'
- | 'evo_client_type'
- | 'evo_client_risk'
- | 'evo_baseproduct'
- | 'evo_leasingobject_type'
- | 'evo_brand'
- | 'evo_model'
- | 'evo_equipment'
- | 'evo_reward_condition'
- | 'evo_gps_brand'
- | 'evo_gps_model'
- | 'evo_region'
- | 'evo_town'
- | 'connection'
- | 'evo_connection_role'
- | 'evo_impairment_group'
- | 'evo_currencychange'
- | 'evo_statuscode'
- | 'evo_coefficient'
- | 'evo_addproduct_type'
- | 'evo_tarif'
- | 'evo_rate'
- | 'evo_planpayment'
- | 'systemuser'
- | 'evo_sot_coefficient_type'
- | 'evo_subsidy';
-
-//TODO: or string
-export type TEntities = {
- [entityName in CRMEntityNames]?: T;
-};
diff --git a/src/core/types/user.ts b/src/core/types/user.ts
deleted file mode 100644
index 83c54a9..0000000
--- a/src/core/types/user.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export type User = {
- domain?: string;
- username?: string;
- domainname?: string;
-};
diff --git a/src/core/validation/validate.ts b/src/core/validation/validate.ts
index a59ed31..7fe7e81 100644
--- a/src/core/validation/validate.ts
+++ b/src/core/validation/validate.ts
@@ -1,10 +1,8 @@
-import { getValueName } from 'client/Containers/Calculation/lib/elements/tools';
+
+import { getValueName } from 'client/Containers/Calculation/Elements/tools';
+import { ElementsNames } from 'client/Containers/Calculation/types/elements';
import { openNotification } from 'client/Elements/Notification';
-import {
- ElementsNames,
- TElements,
-} from './../types/Calculation/Store/elements';
-import { ICalculationStore } from './../types/Calculation/Store/index';
+import { ICalculationStore } from 'core/types/Calculation/Store/index';
export type ValidationResult = {
isValid: boolean;
@@ -18,11 +16,11 @@ export type ValidationCondition = (
export const validate = (
calculationStore: ICalculationStore,
- conditions: TElements,
+ conditions: Partial>,
) => {
- const validationResult: TElements = (Object.keys(
- conditions,
- ) as ElementsNames[]).reduce((ac, elementName) => {
+ const validationResult: Partial> = (
+ Object.keys(conditions) as ElementsNames[]
+ ).reduce((ac, elementName) => {
const condition = conditions[elementName];
ac[elementName] = condition && condition(calculationStore, elementName);
return ac;
@@ -42,7 +40,7 @@ export const getValue = (
export const convertToValidationResult = result => ({ isValid: !result });
export function showValidationMessages(
- validationsResult: TElements,
+ validationsResult: Partial>,
title: string,
): { hasMessages: boolean } {
let messages: string[] = [];
diff --git a/src/core/types/statuses.ts b/src/types/elements.ts
similarity index 63%
rename from src/core/types/statuses.ts
rename to src/types/elements.ts
index 9c8bccb..a3a6675 100644
--- a/src/core/types/statuses.ts
+++ b/src/types/elements.ts
@@ -5,3 +5,5 @@ export enum ElementStatus {
Loading,
Readonly,
}
+
+export type ElementProps = Record;