diff --git a/.storybook/main.js b/.storybook/main.js
new file mode 100644
index 0000000..6283b05
--- /dev/null
+++ b/.storybook/main.js
@@ -0,0 +1,16 @@
+module.exports = {
+ stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
+ addons: [
+ '@storybook/addon-links',
+ '@storybook/addon-essentials',
+ {
+ name: '@storybook/preset-create-react-app',
+ options: {
+ craOverrides: {
+ fileLoaderExcludes: ['less'],
+ },
+ },
+ },
+ '@storybook/preset-ant-design',
+ ],
+};
diff --git a/.storybook/preview.js b/.storybook/preview.js
new file mode 100644
index 0000000..645f52d
--- /dev/null
+++ b/.storybook/preview.js
@@ -0,0 +1,10 @@
+
+export const parameters = {
+ actions: { argTypesRegex: "^on[A-Z].*" },
+ controls: {
+ matchers: {
+ color: /(background|color)$/i,
+ date: /Date$/,
+ },
+ },
+}
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 8507475..37e4fb0 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -20,5 +20,6 @@
"source.organizeImports": true,
"source.fixAll": true
},
- "editor.formatOnSave": true
+ "editor.formatOnSave": true,
+ "workbench.editor.labelFormat": "short"
}
diff --git a/package.json b/package.json
index 50428f8..fabb102 100644
--- a/package.json
+++ b/package.json
@@ -4,13 +4,11 @@
"dependencies": {
"@ant-design/icons": "^4.6.2",
"@apollo/client": "^3.3.13",
- "@babel/code-frame": "^7.10.4",
- "@babel/helper-split-export-declaration": "^7.11.0",
"@craco/craco": "^6.1.1",
- "@testing-library/jest-dom": "^4.2.4",
- "@testing-library/react": "^9.3.2",
- "@testing-library/user-event": "^7.1.2",
- "antd": "^4.15.0",
+ "@testing-library/jest-dom": "^5.11.4",
+ "@testing-library/react": "^11.1.0",
+ "@testing-library/user-event": "^12.1.10",
+ "antd": "^4.15.5",
"axios": "^0.21.1",
"babel-plugin-transform-imports": "^2.0.0",
"craco-antd": "^1.19.0",
@@ -33,30 +31,65 @@
"validator": "^13.5.2"
},
"devDependencies": {
+ "@storybook/addon-actions": "^6.2.9",
+ "@storybook/addon-essentials": "^6.2.9",
+ "@storybook/addon-links": "^6.2.9",
+ "@storybook/node-logger": "^6.2.9",
+ "@storybook/preset-ant-design": "^0.0.2",
+ "@storybook/preset-create-react-app": "^3.1.7",
+ "@storybook/react": "^6.2.9",
"@types/jest": "^26.0.15",
"@types/lodash": "^4.14.168",
+ "@types/node": "^12.0.0",
"@types/pluralize": "^0.0.29",
- "@types/react": "^17.0.3",
- "@types/react-dom": "^17.0.3",
+ "@types/react": "^17.0.0",
+ "@types/react-dom": "^17.0.0",
"@types/react-router-dom": "^5.1.7",
"@types/rebass": "^4.0.8",
"@types/styled-components": "^5.1.9",
+ "@types/uuid": "^8.3.0",
"commitizen": "^4.2.3",
"cz-conventional-changelog": "^3.3.0",
"source-map-explorer": "^2.5.2"
},
+ "resolutions": {
+ "babel-loader": "8.1.0"
+ },
"scripts": {
- "test": "craco test",
+ "test": "react-scripts test",
"eject": "react-scripts eject",
"start": "craco start",
"build": "craco build",
"eslint": "eslint ./src",
"eslint:fix": "eslint ./src --fix",
"commit": "git-cz",
- "analyze": "source-map-explorer 'build/static/js/*.js'"
+ "analyze": "source-map-explorer 'build/static/js/*.js'",
+ "storybook": "start-storybook -p 6006 -s public",
+ "build-storybook": "build-storybook -s public"
},
"eslintConfig": {
- "extends": "react-app"
+ "extends": [
+ "react-app",
+ "react-app/jest"
+ ],
+ "overrides": [
+ {
+ "files": [
+ "**/*.stories.*"
+ ],
+ "rules": {
+ "import/no-anonymous-default-export": "off"
+ }
+ },
+ {
+ "files": [
+ "**/*.stories.*"
+ ],
+ "rules": {
+ "import/no-anonymous-default-export": "off"
+ }
+ }
+ ]
},
"browserslist": {
"production": [
diff --git a/src/client/App.tsx b/src/client/App.jsx
similarity index 100%
rename from src/client/App.tsx
rename to src/client/App.jsx
index eb79d3b..ffd15b9 100644
--- a/src/client/App.tsx
+++ b/src/client/App.jsx
@@ -1,11 +1,11 @@
+import { ConfigProvider, message } from 'antd';
+import ruRu from 'antd/es/locale/ru_RU';
import { StoreProvider } from 'client/contexts/storeContext';
import theme from 'client/UIKit/theme';
import { BrowserRouter } from 'react-router-dom';
import { ThemeProvider } from 'styled-components';
import './App.less';
import Layout from './Layout';
-import { ConfigProvider, message } from 'antd';
-import ruRu from 'antd/es/locale/ru_RU';
message.config({
top: 70,
diff --git a/src/client/Components/Calculation/ELT/Content/Components/InsContent.jsx b/src/client/Components/Calculation/ELT/Content/Components/InsContent.jsx
new file mode 100644
index 0000000..d18cb6a
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Components/InsContent.jsx
@@ -0,0 +1,74 @@
+import Alert from 'client/Elements/Alert';
+import { useStores } from 'client/hooks/useStores';
+import { useEffect, useState } from 'react';
+import { getFieldsNames, validate } from '../lib/validation';
+import InsTable from './InsTable';
+import Controls from './TableControls';
+
+export default ({
+ title,
+ insType,
+ getData,
+ onSelectRow,
+ requiredFields,
+ ...tableProps
+}) => props => {
+ const { calculationStore } = useStores();
+ const { ELTStore } = calculationStore.stores;
+ const [selectedKey, selectKey] = useState('');
+ const [alert, setAlert] = useState({
+ message: undefined,
+ type: undefined,
+ });
+ const [isPending, setIsPending] = useState(false);
+
+ useEffect(() => {
+ selectKey(ELTStore[insType].selectedKey);
+ }, []);
+
+ const handleGetData = () => {
+ const missingFields = validate.call(calculationStore, requiredFields);
+ if (missingFields && missingFields.length > 0) {
+ const fieldsNames = getFieldsNames(missingFields);
+ const msgText = String.prototype.concat(
+ 'Не заполнены поля: ',
+ fieldsNames.join(', '),
+ );
+ setAlert({ message: msgText, type: 'error' });
+ return;
+ } else {
+ setAlert({ message: undefined, type: undefined });
+ }
+
+ setIsPending(true);
+ const resetPending = () => setIsPending(false);
+ getData.call(calculationStore, resetPending);
+ };
+
+ const handleSelectRow = () => {
+ ELTStore[insType].setKey(selectedKey);
+ onSelectRow.call(calculationStore, insType, selectedKey);
+ setAlert({ message: 'Выбранные параметры сохранены', type: 'success' });
+ setTimeout(() => {
+ setAlert({ message: undefined, type: undefined });
+ }, 2500);
+ };
+
+ return (
+
+ {alert.message && }
+
+
+ );
+};
diff --git a/src/client/Components/Calculation/ELT/Content/Components/InsTable.tsx b/src/client/Components/Calculation/ELT/Content/Components/InsTable.tsx
new file mode 100644
index 0000000..0621b60
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Components/InsTable.tsx
@@ -0,0 +1,39 @@
+import { Table as AntTable, TableProps } from 'antd';
+import { Box } from 'client/UIKit/grid';
+import { toJS } from 'mobx';
+import { observer } from 'mobx-react-lite';
+import React from 'react';
+import styled from 'styled-components';
+
+const TableWrapper = styled(Box)`
+ .ant-table-row-level-1 .ant-table-selection-column {
+ visibility: hidden;
+ }
+`;
+
+interface ITableProps {
+ selectKey: (key: string) => void;
+ selectedKey: string;
+ tableConfig: TableProps;
+ dataSource: any[];
+}
+
+export default observer(
+ ({ selectKey, selectedKey, tableConfig, dataSource, ...props }) => {
+ return (
+
+ {
+ selectKey(record.key);
+ },
+ })}
+ dataSource={toJS(dataSource)}
+ {...props}
+ >
+
+ );
+ },
+) as React.FC;
diff --git a/src/client/Components/Calculation/ELT/Content/Components/TableControls.jsx b/src/client/Components/Calculation/ELT/Content/Components/TableControls.jsx
new file mode 100644
index 0000000..656583a
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Components/TableControls.jsx
@@ -0,0 +1,34 @@
+import ReloadOutlined from '@ant-design/icons/lib/icons/ReloadOutlined';
+import Button from 'client/Elements/Button';
+import { PrimaryText } from 'client/Elements/Text';
+import { Flex } from 'client/UIKit/grid';
+import { ElementStatus } from 'core/types/statuses';
+import styled from 'styled-components';
+
+const TopControls = ({ title, getData, isLoading }) => (
+
+ {title}
+ }
+ />
+
+);
+
+const BottomControls = ({ selectRow }) => (
+
+);
+
+const ContentWrapper = styled(Flex)`
+ width: 550px !important;
+`;
+
+export default ({ children, ...props }) => (
+
+
+ {children}
+
+
+);
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/Kasko.stories.jsx b/src/client/Components/Calculation/ELT/Content/Kasko/Kasko.stories.jsx
new file mode 100644
index 0000000..d6650b3
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Kasko/Kasko.stories.jsx
@@ -0,0 +1,43 @@
+import InsTable from '../InsTable';
+import tableConfig from '../lib/config';
+
+export default {
+ title: 'Components/Calculation/ELT/Kasko',
+ component: InsTable,
+};
+
+const Template = args => ;
+
+const dataSource = [
+ {
+ key: '1',
+ evo_id_elt: 'Alfa',
+ name: 'Альфа',
+ sumTitle: 'Премия по договору',
+ premiumSum: 55555,
+ message: 'Комментарий альфы',
+ children: [
+ {
+ key: '1',
+ sumTitle: 'КАСКО',
+ premiumSum: 1111,
+ },
+ {
+ key: '1',
+ sumTitle: 'ДГО',
+ premiumSum: 4444,
+ },
+ {
+ key: '1',
+ sumTitle: 'НС',
+ premiumSum: 8888,
+ },
+ ],
+ },
+];
+
+export const WithData = Template.bind({});
+WithData.args = {
+ tableConfig,
+ dataSource,
+};
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/index.jsx b/src/client/Components/Calculation/ELT/Content/Kasko/index.jsx
new file mode 100644
index 0000000..5d26e12
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Kasko/index.jsx
@@ -0,0 +1,18 @@
+import InsContent from '../Components/InsContent';
+import tableConfig from '../lib/config';
+import getData from '../lib/getData';
+import composeRequest from './lib/composeRequest';
+import convertEltResult from './lib/convertEltResult';
+import onSelectRow from './lib/onSelectRow';
+import { requiredFields } from './lib/validation';
+
+const insType = 'kasko';
+
+export default InsContent({
+ title: 'КАСКО',
+ insType,
+ getData: getData(insType, composeRequest, convertEltResult),
+ onSelectRow,
+ tableConfig,
+ requiredFields,
+});
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.test.js b/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.test.js
new file mode 100644
index 0000000..aeb135f
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.test.js
@@ -0,0 +1,145 @@
+import CalculationStore from 'client/stores/CalculationStore';
+import { currentDate } from 'core/tools/date';
+import composeRequest from './composeRequest';
+
+CalculationStore.options = {
+ selectRegionRegistration: [
+ {
+ evo_name: 'Рязанская область',
+ value: 'rznregion',
+ },
+ ],
+ selectTownRegistration: [
+ {
+ evo_name: 'Рязань',
+ value: 'rzntown',
+ },
+ ],
+ selectGPSBrand: [
+ {
+ evo_id: 'gps_brand_evo_id',
+ value: 'gpsbrand',
+ },
+ ],
+ selectGPSModel: [
+ {
+ evo_id: 'gps_model_evo_id',
+ value: 'gpsmodel',
+ },
+ ],
+ selectBrand: [
+ {
+ evo_id: 'AUDI',
+ value: 'brandid',
+ },
+ ],
+ selectModel: [
+ {
+ evo_id: 'A5',
+ value: 'modelid',
+ },
+ ],
+};
+
+CalculationStore.values = {
+ regionRegistration: 'rznregion',
+ townRegistration: 'rzntown',
+ brand: 'brandid',
+ model: 'modelid',
+ leaseObjectUsed: false,
+ leaseObjectYear: 2021,
+ leaseObjectMotorPower: 5.5,
+ engineType: undefined,
+ leasingPeriod: 12,
+ leaseObjectPrice: 2000,
+ supplierDiscountRub: 1000,
+ insFranchise: 5,
+ GPSBrand: 'gpsbrand',
+ GPSModel: 'gpsmodel',
+ insUnlimitDrivers: true,
+ leaseObjectCategory: 100000002,
+ maxMass: 1000,
+ leaseObjectUseFor: 100000001,
+ INNForCalc: 1010,
+};
+
+CalculationStore.tables = {
+ tableInsurance: {
+ rows: [{}, {}, { insCost: 10000 }],
+ },
+};
+
+const expected = {
+ preparams: {
+ regionName: 'Рязанская область',
+ cityName: 'Рязань',
+ brandId: 'AUDI',
+ modelId: 'A5',
+ },
+ ELTParams: {
+ currency: 'RUR',
+ isNew: false,
+ usageStart: currentDate,
+ vehicleYear: 2021,
+ modification: {
+ power: 5.5,
+ engineType: '5',
+ engineVolume: 0,
+ KPPTypeId: '1',
+ BodyType: '9',
+ },
+ duration: 12,
+ bankId: '245',
+ cost: 1000,
+ franchise: '5',
+ ssType: '1',
+ STOA: '0',
+ OfficialDealer: true,
+ PUUs: [
+ {
+ mark: 'gps_brand_evo_id',
+ model: 'gps_model_evo_id',
+ },
+ ],
+ driversCount: 1,
+ risk: 0,
+ payType: 0,
+ vehicle: {
+ maxAllowedMass: 1000,
+ mileage: 0,
+ vehicleUsage: 1,
+ seatingCapacity: 0,
+ category: 'C2',
+ classification: '11635',
+ },
+ drivers: [{ age: 18, experience: 0, sex: '0' }],
+ GO: { limitSumId: '1000000', globalLimitSum: 1000000 },
+ NS: { LimitSum: 1000000 },
+ Insurer: {
+ SubjectType: 1,
+ SubjectTypeSpecified: true,
+ },
+ Owner: {
+ SubjectType: 1,
+ SubjectTypeSpecified: true,
+ },
+ Lessee: {
+ SubjectType: 1,
+ SubjectTypeSpecified: true,
+ INN: '1010',
+ },
+ FullDriversInfo: [
+ {
+ surname: 'Иванов',
+ name: 'Иван',
+ patronymic: 'Иванович',
+ sex: '0',
+ expertienceStart: new Date('2000-01-01'),
+ },
+ ],
+ },
+};
+
+it('ELT/Kasko/composeRequest', () => {
+ expect(composeRequest.call(CalculationStore)).toEqual(expected);
+});
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.ts b/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.ts
new file mode 100644
index 0000000..2ab8f07
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Kasko/lib/composeRequest.ts
@@ -0,0 +1,200 @@
+import { currentDate } from 'core/tools/date';
+import { ICalculationStore } from 'core/types/Calculation/Store/index';
+import { isNull } from 'lodash';
+
+const mapEngineType = {
+ 100000000: '0',
+ 100000001: '1',
+ 100000003: '2',
+ 100000004: '3',
+};
+
+const mapVehicleUsage = {
+ 100000000: 0,
+ 100000001: 1,
+ 100000002: 5,
+ 100000003: 5,
+ 100000004: 2,
+ 100000005: 6,
+ 100000006: 5,
+ 100000007: 4,
+ 100000008: 4,
+ 100000009: 0,
+ 100000010: 0,
+ 100000011: 3,
+ 100000012: 3,
+ 100000013: 9,
+};
+
+const mapCategory = {
+ 100000000: 'A',
+ 100000001: 'B',
+ 100000002: 'C2',
+ 100000003: 'D',
+ 100000004: 'E1',
+};
+
+const getSpecified = value => !isNull(value);
+
+export default function (this: ICalculationStore) {
+ const regionName = this.getOption('selectRegionRegistration')?.evo_name;
+ const cityName = this.getOption('selectTownRegistration')?.evo_name;
+ const brandId = this.getOption('selectBrand')?.evo_id;
+ const modelId = this.getOption('selectModel')?.evo_id;
+
+ const isNew = !this.getValue('leaseObjectUsed');
+ const vehicleYear = this.getValue('leaseObjectYear');
+ const power = this.getValue('leaseObjectMotorPower');
+ const powerSpecified = getSpecified(power);
+
+ let engineType = '5';
+ const engineTypeValue = this.getValue('engineType');
+ if (engineTypeValue) {
+ engineType = mapEngineType[engineTypeValue];
+ }
+
+ const duration = this.getValue('leasingPeriod');
+ const cost =
+ this.getValue('leaseObjectPrice') - this.getValue('supplierDiscountRub');
+
+ const franchise = this.getValue('insFranchise');
+ const franchiseSpecified = getSpecified(franchise);
+ const puuMark = this.getOption('selectGPSBrand')?.evo_id;
+ const puuModel = this.getOption('selectGPSModel')?.evo_id;
+ const puuModelSpecified = getSpecified(puuModel);
+
+ let age = this.getValue('insAgeDrivers'),
+ experience = this.getValue('insExpDrivers'),
+ sex = '0',
+ driversCount = 1;
+
+ if (this.getValue('insUnlimitDrivers')) {
+ age = 18;
+ experience = 0;
+ driversCount = 0;
+ }
+ const sexSpecified = getSpecified(sex);
+
+ let maxAllowedMass = 0;
+ if (this.getValue('leaseObjectCategory') === 100000002) {
+ maxAllowedMass = this.getValue('maxMass');
+ }
+ const maxAllowedMassSpecified = getSpecified(maxAllowedMass);
+
+ let mileage = 0;
+ if (this.getValue('leaseObjectUsed')) {
+ mileage = this.getValue('mileage');
+ }
+ const mileageSpecified = getSpecified(mileage);
+
+ let vehicleUsage = 0;
+ const leaseObjectUseForValue = this.getValue('leaseObjectUseFor');
+ if (leaseObjectUseForValue) {
+ vehicleUsage = mapVehicleUsage[leaseObjectUseForValue] || 0;
+ }
+ const vehicleUsageSpecified = getSpecified(vehicleUsage);
+
+ let seatingCapacity = 0;
+ if (this.getValue('leaseObjectCategory') === 100000003) {
+ seatingCapacity = this.getValue('countSeats');
+ }
+ const seatingCapacitySpecified = getSpecified(seatingCapacity);
+
+ const category = mapCategory[this.getValue('leaseObjectCategory')];
+
+ const classification = [100000002, 100000003, 100000004].includes(
+ this.getValue('leaseObjectCategory'),
+ )
+ ? '11635'
+ : '0';
+
+ const globalLimitSum = this.getTableRowValues('tableInsurance', 2, 'value')
+ .insCost
+ ? 1000000
+ : 0;
+ const globalLimitSumSpecified = getSpecified(globalLimitSum);
+ const limitSumId = globalLimitSum + '';
+
+ const INN = this.getValue('INNForCalc') || '' + '';
+
+ return {
+ preparams: {
+ regionName,
+ cityName,
+ brandId,
+ modelId,
+ },
+ ELTParams: {
+ currency: 'RUR',
+ isNew,
+ usageStart: currentDate,
+ vehicleYear,
+ modification: {
+ power,
+ powerSpecified,
+ engineType,
+ engineVolume: 0,
+ engineVolumeSpecified: true,
+ KPPTypeId: 1,
+ BodyType: 9,
+ },
+ duration,
+ bankId: '245',
+ cost,
+ franchise,
+ franchiseSpecified,
+ ssType: '1',
+ STOA: '0',
+ OfficialDealerSpecified: true,
+ OfficialDealer: true,
+ PUUs: puuMark && [
+ {
+ mark: puuMark,
+ model: puuModel,
+ modelSpecified: puuModelSpecified,
+ },
+ ],
+ driversCount,
+ risk: 0,
+ payType: '0',
+ vehicle: {
+ maxAllowedMass,
+ maxAllowedMassSpecified,
+ mileage,
+ mileageSpecified,
+ vehicleUsage,
+ vehicleUsageSpecified,
+ seatingCapacity,
+ seatingCapacitySpecified,
+ category,
+ classification,
+ },
+ drivers: [{ age, experience, sex, sexSpecified }],
+ GO: { limitSumId, globalLimitSum, globalLimitSumSpecified },
+ NS: { LimitSum: '1000000' },
+ Insurer: {
+ SubjectType: 1,
+ SubjectTypeSpecified: true,
+ },
+ Owner: {
+ SubjectType: 1,
+ SubjectTypeSpecified: true,
+ },
+ Lessee: {
+ SubjectType: 1,
+ SubjectTypeSpecified: true,
+ INN,
+ },
+ // FullDriversInfo: [
+ // {
+ // surname,
+ // name,
+ // patronymic,
+ // sex,
+ // sexSpecified,
+ // expertienceStart,
+ // },
+ // ],
+ },
+ };
+}
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/convertEltResult.js b/src/client/Components/Calculation/ELT/Content/Kasko/lib/convertEltResult.js
new file mode 100644
index 0000000..8e73af2
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Kasko/lib/convertEltResult.js
@@ -0,0 +1,47 @@
+import { get, pick } from 'lodash';
+
+const mapKaskoSums = [
+ {
+ sumTitle: 'КАСКО',
+ sumPath: 'paymentPeriods[0].kaskoSum',
+ },
+ {
+ sumTitle: 'ДГО',
+ sumPath: 'paymentPeriods[0].goSum',
+ },
+ {
+ sumTitle: 'НС',
+ sumPath: 'paymentPeriods[0].nsSum',
+ },
+];
+
+export default function (resultCompany, key) {
+ if (!resultCompany || Object.keys(resultCompany).length === 0) {
+ return;
+ }
+
+ const dataFromResult = pick(
+ resultCompany,
+ ['message', 'requestId', 'skCalcId'],
+ '',
+ );
+ const sumsFromResult = Object.fromEntries(
+ ['kaskoSum', 'goSum', 'nsSum', 'premiumSum'].map(x => [
+ x,
+ get(resultCompany, 'paymentPeriods[0].' + x, 0),
+ ]),
+ );
+
+ return {
+ key,
+ sumType: 'premiumSum',
+ sumTitle: 'Премия по договору',
+ ...dataFromResult,
+ ...sumsFromResult,
+ children: mapKaskoSums.map(({ sumPath, ...x }) => ({
+ key,
+ ...x,
+ premiumSum: get(resultCompany, sumPath, 0),
+ })),
+ };
+}
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/convertEltResult.test.js b/src/client/Components/Calculation/ELT/Content/Kasko/lib/convertEltResult.test.js
new file mode 100644
index 0000000..622597e
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Kasko/lib/convertEltResult.test.js
@@ -0,0 +1,79 @@
+import convertEltResult from './convertEltResult';
+
+export const resultCompany = {
+ requestId: '1364968',
+ skCalcId: '66758382',
+ product: '',
+ program: '',
+ productId: '',
+ programId: '1',
+ comment: null,
+ message: 'Комментарий альфы',
+ error: '',
+ errorType: null,
+ premiumSum: 0,
+ kaskoSum: 0,
+ doSum: 0,
+ goSum: 0,
+ nsSum: 0,
+ gapSum: 0,
+ paymentPeriods: [
+ {
+ num: 1,
+ PremiumSum: 55555,
+ KASKOSum: 1111,
+ GOSum: 4444,
+ NSSum: 8888,
+ },
+ ],
+ kbmOsago: null,
+ totalFranchise: 0,
+ totalFranchiseSpecified: false,
+ insuranceCompanyFranchise: null,
+ insuranceCompanyGo: null,
+ policyNumber: null,
+ programCode: null,
+ calcInfo: null,
+ options: null,
+ unicusGUID: null,
+};
+
+const entityCompany = {
+ accountid: '0df9ccfb-1407-eb11-af50-00155d088a01',
+ name: 'Альфа',
+ evo_id_elt: 'Alfa',
+};
+
+it('ELT/Kasko/convertKaskoResultToRow', () => {
+ expect(convertEltResult(resultCompany, entityCompany, '0')).toEqual({
+ key: '0',
+ evo_id_elt: 'Alfa',
+ name: 'Альфа',
+ sumType: 'premiumSum',
+ sumTitle: 'Премия по договору',
+ PremiumSum: 55555,
+ KASKOSum: 1111,
+ GOSum: 4444,
+ NSSum: 8888,
+ message: 'Комментарий альфы',
+ requestId: '1364968',
+ skCalcId: '66758382',
+ children: [
+ {
+ key: '0',
+ sumTitle: 'КАСКО',
+ premiumSum: 1111,
+ },
+ {
+ key: '0',
+ sumTitle: 'ДГО',
+ premiumSum: 4444,
+ },
+ {
+ key: '0',
+ sumTitle: 'НС',
+ premiumSum: 8888,
+ },
+ ],
+ });
+});
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/onSelectRow.ts b/src/client/Components/Calculation/ELT/Content/Kasko/lib/onSelectRow.ts
new file mode 100644
index 0000000..df7c96f
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Kasko/lib/onSelectRow.ts
@@ -0,0 +1,35 @@
+import { ICalculationStore } from 'core/types/Calculation/Store';
+
+export default function (
+ this: ICalculationStore,
+ insType,
+ selectedKey: string,
+) {
+ const selectedRow = this.stores.ELTStore[insType].list.find(
+ x => x.key === selectedKey,
+ );
+ const { accountid, kaskoSum, goSum, nsSum } = selectedRow;
+ this.setTableRows(
+ 'tableInsurance',
+ 1,
+ )([
+ {
+ insuranceCompany: {
+ value: accountid,
+ },
+ insCost: { value: kaskoSum },
+ },
+ {
+ insuranceCompany: {
+ value: accountid,
+ },
+ insCost: { value: goSum },
+ },
+ {
+ insuranceCompany: {
+ value: accountid,
+ },
+ insCost: { value: nsSum },
+ },
+ ]);
+}
diff --git a/src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts b/src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts
new file mode 100644
index 0000000..223ed45
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Kasko/lib/validation.ts
@@ -0,0 +1,13 @@
+import { ElementsNames } from 'core/types/Calculation/Store/elements';
+
+export const requiredFields: ElementsNames[] = [
+ 'selectRegionRegistration',
+ 'selectTownRegistration',
+ 'selectBrand',
+ 'selectModel',
+ 'tbxLeaseObjectYear',
+ 'tbxLeaseObjectMotorPower',
+ 'tbxLeasingPeriod',
+ 'tbxLeaseObjectPrice',
+ 'selectLeaseObjectCategory',
+];
diff --git a/src/client/Components/Calculation/ELT/Content/Osago/index.jsx b/src/client/Components/Calculation/ELT/Content/Osago/index.jsx
new file mode 100644
index 0000000..8d384cd
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Osago/index.jsx
@@ -0,0 +1,18 @@
+import InsContent from '../Components/InsContent';
+import tableConfig from '../lib/config';
+import getData from '../lib/getData';
+import composeRequest from './lib/composeRequest';
+import convertEltResult from './lib/convertEltResult';
+import onSelectRow from './lib/onSelectRow';
+import { requiredFields } from './lib/validation';
+
+const insType = 'osago';
+
+export default InsContent({
+ title: 'ОСАГО',
+ insType,
+ getData: getData(insType, composeRequest, convertEltResult),
+ onSelectRow,
+ tableConfig,
+ requiredFields,
+});
diff --git a/src/client/Components/Calculation/ELT/Content/Osago/lib/composeRequest.ts b/src/client/Components/Calculation/ELT/Content/Osago/lib/composeRequest.ts
new file mode 100644
index 0000000..988b755
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Osago/lib/composeRequest.ts
@@ -0,0 +1,149 @@
+import { currentDate } from 'core/tools/date';
+import { ICalculationStore } from 'core/types/Calculation/Store';
+import { isNull } from 'lodash';
+
+const mapCategory = {
+ 100000000: 'A',
+ 100000001: 'B',
+ 100000002: 'C',
+ 100000003: 'D',
+ 100000004: 'ПРОЧИЕ ТС',
+};
+
+const mapSubCategoryBuilder = (leaseObjectUseFor, maxMass, countSeats) => ({
+ 100000000: () => '0',
+ 100000001: () => {
+ if (leaseObjectUseFor === 100000001) {
+ return '11';
+ }
+ return '10';
+ },
+ 100000002: () => {
+ if (maxMass <= 16000) {
+ return '20';
+ }
+ return '21';
+ },
+ 100000003: () => {
+ if (leaseObjectUseFor === 100000001) {
+ return '32';
+ }
+ if (countSeats <= 20) {
+ return 30;
+ }
+ return '31';
+ },
+ 100000004: () => '22',
+});
+
+const getSpecified = value => !isNull(value);
+
+export default function (this: ICalculationStore) {
+ const regionName = this.getOption('selectRegionRegistration')?.evo_name;
+ const cityName = this.getOption('selectTownRegistration')?.evo_name;
+ const brandId = this.getOption('selectBrand')?.evo_id;
+ const modelId = this.getOption('selectModel')?.evo_id;
+
+ const mark = this.getOption('selectGPSBrand')?.evo_id;
+ const model = this.getOption('selectGPSModel')?.evo_id;
+ const vehicleYear = this.getValue('leaseObjectYear') + '';
+ const leaseObjectCategory = this.getValue('leaseObjectCategory');
+ const vehiclePower =
+ leaseObjectCategory === 100000001
+ ? parseFloat(this.getValue('leaseObjectMotorPower') || '0')
+ : '0';
+
+ let category = '0';
+ if (Object.keys(mapCategory).includes(leaseObjectCategory)) {
+ category = mapCategory[leaseObjectCategory];
+ }
+
+ const leaseObjectUseFor = this.getValue('leaseObjectUseFor');
+ const maxMass = this.getValue('maxMass');
+ const countSeats = this.getValue('countSeats');
+ const mapSubCategory = mapSubCategoryBuilder(
+ leaseObjectUseFor,
+ maxMass,
+ countSeats,
+ );
+ const subCategory = mapSubCategory[leaseObjectCategory];
+
+ let seatingCapacity = 0;
+ if (leaseObjectCategory === 100000003) {
+ seatingCapacity = countSeats;
+ }
+ const seatingCapacitySpecified = getSpecified(seatingCapacity);
+
+ let maxAllowedMass = 0;
+ if (leaseObjectCategory === 100000002) {
+ maxAllowedMass = maxMass;
+ }
+ const maxAllowedMassSpecified = getSpecified(maxAllowedMass);
+
+ const useWithTrailer = this.getValue('withTrailer');
+ const useWithTrailerSpecified = true;
+
+ const address = {
+ resident: 1,
+ country: 'Российская Федерация',
+ region: 'Москва',
+ district: '0',
+ city: 'Москва',
+ cityKladr: '7700000000000',
+ street: 'ул. Котляковская',
+ streetKladr: '0',
+ house: '8',
+ korpus: '0',
+ flat: '337',
+ };
+
+ const owner = {
+ JuridicalName: 'ООО "ЛК "ЭВОЛЮЦИЯ"',
+ inn: '9724016636',
+ kpp: '772401001',
+ ogrn: '1207700245037',
+ registrationAddress: address,
+ factAddress: address,
+ phone: '8 (800) 333-75-75',
+ email: 'client@evoleasing.ru',
+ };
+
+ return {
+ preparams: {
+ regionName,
+ cityName,
+ brandId,
+ modelId,
+ },
+ ELTParams: {
+ tsToRegistrationPlace: 0,
+ contractBeginDate: currentDate,
+ duration: 12,
+ carInfo: {
+ mark,
+ model,
+ vehicleYear,
+ vehiclePower,
+ tsType: { category, subCategory },
+ vehicle: {
+ regNumber: '0',
+ bodyNumber: '0',
+ chassisNumber: '0',
+ VIN: '0',
+ seatingCapacity,
+ seatingCapacitySpecified,
+ maxAllowedMass,
+ maxAllowedMassSpecified,
+ },
+ useWithTrailer,
+ useWithTrailerSpecified,
+ },
+ owner,
+ FullDriversInfo: [
+ {
+ kbm: '3',
+ },
+ ],
+ },
+ };
+}
diff --git a/src/client/Components/Calculation/ELT/Content/Osago/lib/convertEltResult.js b/src/client/Components/Calculation/ELT/Content/Osago/lib/convertEltResult.js
new file mode 100644
index 0000000..b746fa0
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Osago/lib/convertEltResult.js
@@ -0,0 +1,20 @@
+import { pick } from 'lodash';
+
+export default function (resultCompany, key) {
+ if (!resultCompany || Object.keys(resultCompany).length === 0) {
+ return;
+ }
+
+ const dataFromResult = pick(
+ resultCompany,
+ ['numCalc', 'premiumSum', 'message'],
+ '',
+ );
+
+ return {
+ key,
+ sumType: 'premiumSum',
+ sumTitle: 'Премия по договору',
+ ...dataFromResult,
+ };
+}
diff --git a/src/client/Components/Calculation/ELT/Content/Osago/lib/onSelectRow.ts b/src/client/Components/Calculation/ELT/Content/Osago/lib/onSelectRow.ts
new file mode 100644
index 0000000..92050f9
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Osago/lib/onSelectRow.ts
@@ -0,0 +1,21 @@
+import { ICalculationStore } from 'core/types/Calculation/Store';
+
+export default function (
+ this: ICalculationStore,
+ insType,
+ selectedKey: string,
+) {
+ const selectedRow = this.stores.ELTStore[insType].list.find(
+ x => x.key === selectedKey,
+ );
+ const { accountid, premiumSum } = selectedRow;
+ this.setTableRow(
+ 'tableInsurance',
+ 0,
+ )({
+ insuranceCompany: {
+ value: accountid,
+ },
+ insCost: { value: premiumSum },
+ });
+}
diff --git a/src/client/Components/Calculation/ELT/Content/Osago/lib/validation.ts b/src/client/Components/Calculation/ELT/Content/Osago/lib/validation.ts
new file mode 100644
index 0000000..223ed45
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/Osago/lib/validation.ts
@@ -0,0 +1,13 @@
+import { ElementsNames } from 'core/types/Calculation/Store/elements';
+
+export const requiredFields: ElementsNames[] = [
+ 'selectRegionRegistration',
+ 'selectTownRegistration',
+ 'selectBrand',
+ 'selectModel',
+ 'tbxLeaseObjectYear',
+ 'tbxLeaseObjectMotorPower',
+ 'tbxLeasingPeriod',
+ 'tbxLeaseObjectPrice',
+ 'selectLeaseObjectCategory',
+];
diff --git a/src/client/Components/Calculation/ELT/Content/index.jsx b/src/client/Components/Calculation/ELT/Content/index.jsx
new file mode 100644
index 0000000..38e1cea
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/index.jsx
@@ -0,0 +1,20 @@
+import { Flex } from 'client/UIKit/grid';
+import mq from 'client/UIKit/mq';
+import styled from 'styled-components';
+import Kasko from './Kasko';
+import Osago from './Osago';
+
+const ContentDivider = styled.div`
+ margin: 16px 0;
+ ${mq.laptopHD`
+ margin: 0 16px;
+ `}
+`;
+
+export default () => (
+
+
+
+
+
+);
diff --git a/src/client/Components/Calculation/ELT/Content/lib/config/columns.ts b/src/client/Components/Calculation/ELT/Content/lib/config/columns.ts
new file mode 100644
index 0000000..2450641
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/lib/config/columns.ts
@@ -0,0 +1,21 @@
+export type KaskoDataNames = 'name' | 'sumTitle' | 'premiumSum';
+
+const columns: { title: string; dataIndex: KaskoDataNames }[] = [
+ {
+ title: 'Страховая компания',
+ dataIndex: 'name',
+ },
+ {
+ title: '',
+ dataIndex: 'sumTitle',
+ },
+ {
+ title: 'Сумма',
+ dataIndex: 'premiumSum',
+ //@ts-ignore
+ sorter: (a, b) => a.premiumSum - b.premiumSum,
+ sortDirections: ['descend', 'ascend'],
+ },
+];
+
+export default columns;
diff --git a/src/client/Components/Calculation/ELT/Content/lib/config/index.ts b/src/client/Components/Calculation/ELT/Content/lib/config/index.ts
new file mode 100644
index 0000000..f6add11
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/lib/config/index.ts
@@ -0,0 +1,18 @@
+import { TableProps } from 'antd';
+import columns from './columns';
+
+export default {
+ columns,
+ rowSelection: {
+ hideSelectAll: true,
+ type: 'radio',
+ },
+ expandable: {
+ // rowExpandable: record => record.message || record.children,
+ // expandedRowRender: record => record.message,
+ // expandRowByClick: true,
+ // expandIconColumnIndex: -1,
+ },
+ pagination: false,
+ size: 'small',
+} as TableProps;
diff --git a/src/client/Components/Calculation/ELT/Content/lib/getData.ts b/src/client/Components/Calculation/ELT/Content/lib/getData.ts
new file mode 100644
index 0000000..45deb9a
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/lib/getData.ts
@@ -0,0 +1,40 @@
+import ELTService from 'core/services/ELTService';
+import { ICalculationStore } from 'core/types/Calculation/Store';
+import { IAccount } from 'core/types/Entities/crmEntities';
+
+export default (insType: string, composeRequest, convertEltResult) =>
+ function (this: ICalculationStore, callback: () => any) {
+ const { ELTStore } = this.stores;
+ const request = composeRequest.call(this);
+
+ const requests = ELTStore[insType].list.map(
+ (company: IAccount, i: number) =>
+ new Promise((resolve, reject) => {
+ ELTService[insType]
+ .getCalculation({
+ companyIds: [company.evo_id_elt],
+ ...request,
+ })
+ .then(res => {
+ if (!company.evo_id_elt || !res[company.evo_id_elt]) {
+ return;
+ }
+ const converted = convertEltResult(
+ res[company.evo_id_elt],
+ company.accountid,
+ );
+ ELTStore.setCompanyRes(
+ insType,
+ i,
+ Object.assign(company, converted),
+ );
+ resolve();
+ })
+ .catch(err => {
+ reject(err);
+ });
+ }),
+ );
+
+ Promise.allSettled(requests).then(() => callback());
+ };
diff --git a/src/client/Components/Calculation/ELT/Content/lib/validation.ts b/src/client/Components/Calculation/ELT/Content/lib/validation.ts
new file mode 100644
index 0000000..0f93f7e
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/Content/lib/validation.ts
@@ -0,0 +1,19 @@
+import { elementsTitles } from 'client/Containers/Calculation/lib/elements/titles';
+import { elementsValues } from 'client/Containers/Calculation/lib/elements/values';
+import { ICalculationStore } from 'core/types/Calculation/Store';
+import { ElementsNames } from 'core/types/Calculation/Store/elements';
+
+export function validate(this: ICalculationStore, requiredValues) {
+ const missingValues = requiredValues.filter(x => {
+ const valueName = elementsValues[x] || '';
+
+ return (
+ this.values[valueName] === undefined || this.values[valueName] === null
+ );
+ });
+ return missingValues;
+}
+
+export function getFieldsNames(elementsNames: ElementsNames[]): string[] {
+ return elementsNames.map(x => elementsTitles[x] || '');
+}
diff --git a/src/client/Components/Calculation/ELT/index.jsx b/src/client/Components/Calculation/ELT/index.jsx
new file mode 100644
index 0000000..37f6b02
--- /dev/null
+++ b/src/client/Components/Calculation/ELT/index.jsx
@@ -0,0 +1,44 @@
+import { Modal } from 'antd';
+import { Outlined as SpinnerOutlined } from 'client/Components/Spinner';
+import Button from 'client/Elements/Button';
+import { Box } from 'client/UIKit/grid';
+import { lazy, Suspense, useState } from 'react';
+
+const Content = lazy(() => import('./Content'));
+
+const ELT = ({ title }) => {
+ const [isOpenModal, setIsOpenModal] = useState(false);
+ function closeModal() {
+ setIsOpenModal(false);
+ }
+ return (
+ <>
+
+
+ {isOpenModal && (
+
+ }>
+
+
+
+ )}
+ >
+ );
+};
+
+export default ELT;
diff --git a/src/client/Components/Spinner.jsx b/src/client/Components/Spinner.jsx
index e6c7e31..dba70d7 100644
--- a/src/client/Components/Spinner.jsx
+++ b/src/client/Components/Spinner.jsx
@@ -1,10 +1,21 @@
+import LoadingOutlined from '@ant-design/icons/lib/icons/LoadingOutlined';
import { Spin } from 'antd';
-import { Box, Flex } from 'client/UIKit/grid';
+import { Flex } from 'client/UIKit/grid';
-export default () => (
-
-
-
-
-
+const Wrapper = props => (
+
+ {props.children}
+
);
+
+const Spinner = props => (
+
+
+
+);
+
+export default Spinner;
+
+const loadingOutlined = ;
+
+export const Outlined = () => ;
diff --git a/src/client/Containers/Calculation/Results/index.jsx b/src/client/Containers/Calculation/Results/index.jsx
index e4c5a13..61304d4 100644
--- a/src/client/Containers/Calculation/Results/index.jsx
+++ b/src/client/Containers/Calculation/Results/index.jsx
@@ -11,10 +11,4 @@ const Results = props => (
);
-const styles = {
- divider: {
- margin: '12px 0',
- },
-};
-
export default Results;
diff --git a/src/client/Containers/Calculation/Sections/sectionsList.ts b/src/client/Containers/Calculation/Sections/sectionsList.ts
index cb5c3a2..5d6a465 100644
--- a/src/client/Containers/Calculation/Sections/sectionsList.ts
+++ b/src/client/Containers/Calculation/Sections/sectionsList.ts
@@ -307,7 +307,7 @@ const sections: ISection[] = [
style: { columnsNumber: 1 },
blocks: [
{
- elements: ['tableInsurance'],
+ elements: ['componentElt', 'tableInsurance'],
},
],
},
diff --git a/src/client/Containers/Calculation/lib/buildElement.js b/src/client/Containers/Calculation/lib/buildElement.js
index f7ebfa8..881eebc 100644
--- a/src/client/Containers/Calculation/lib/buildElement.js
+++ b/src/client/Containers/Calculation/lib/buildElement.js
@@ -49,6 +49,9 @@ export function buildElement(elementName) {
...elementProps,
});
}
+ case ElementType.Custom: {
+ return () => ;
+ }
default: {
return withValue(Component)({
name: elementName,
diff --git a/src/client/Containers/Calculation/lib/elements/components.ts b/src/client/Containers/Calculation/lib/elements/components.ts
index 49fca72..f02d322 100644
--- a/src/client/Containers/Calculation/lib/elements/components.ts
+++ b/src/client/Containers/Calculation/lib/elements/components.ts
@@ -1,3 +1,4 @@
+import ELT from 'client/Components/Calculation/ELT';
import Button from 'client/Elements/Button';
import Checkbox from 'client/Elements/Checkbox';
import Download from 'client/Elements/Download';
@@ -160,6 +161,7 @@ const elementsComponents: TElements = {
tbxMileage: InputNumber,
radioCalcType: Radio,
tbxTotalPayments: InputNumber,
+ componentElt: ELT,
};
const tablesComponents: StoreTables = {
diff --git a/src/client/Containers/Calculation/lib/elements/elementsProps.ts b/src/client/Containers/Calculation/lib/elements/elementsProps.ts
index 7edab06..255d3da 100644
--- a/src/client/Containers/Calculation/lib/elements/elementsProps.ts
+++ b/src/client/Containers/Calculation/lib/elements/elementsProps.ts
@@ -336,6 +336,9 @@ const elementsProps: TElements = {
step: 1000,
precision: 2,
},
+ componentElt: {
+ title: 'Расчет страховки в ЭЛТ',
+ },
};
const resultElementsProps: TElements = [
diff --git a/src/client/Containers/Calculation/lib/elements/titles.ts b/src/client/Containers/Calculation/lib/elements/titles.ts
index 822bcbe..f6584bc 100644
--- a/src/client/Containers/Calculation/lib/elements/titles.ts
+++ b/src/client/Containers/Calculation/lib/elements/titles.ts
@@ -1,7 +1,7 @@
import { TElements } from 'core/types/Calculation/Store/elements';
import { StoreTables } from 'core/types/Calculation/Store/tables';
-const elementsTitles: TElements = {
+export const elementsTitles: TElements = {
selectLead: 'Интерес',
selectOpportunity: 'Лизинговая сделка',
selectQuote: 'Предложение',
diff --git a/src/client/Containers/Calculation/lib/elements/types.ts b/src/client/Containers/Calculation/lib/elements/types.ts
index b8bf630..8254285 100644
--- a/src/client/Containers/Calculation/lib/elements/types.ts
+++ b/src/client/Containers/Calculation/lib/elements/types.ts
@@ -1,5 +1,5 @@
+import { ElementType, TElements } from 'core/types/Calculation/Store/elements';
import { StoreTables } from 'core/types/Calculation/Store/tables';
-import { TElements, ElementType } from 'core/types/Calculation/Store/elements';
const elementsTypes: TElements = {
labelLeaseObjectRisk: ElementType.Computed,
@@ -11,6 +11,7 @@ const elementsTypes: TElements = {
btnCalculate: ElementType.Action,
labelIrrInfo: ElementType.Computed,
linkDownloadKp: ElementType.Link,
+ componentElt: ElementType.Custom,
};
const tablesTypes: StoreTables = {
diff --git a/src/client/Containers/Calculation/lib/fetchData/index.js b/src/client/Containers/Calculation/lib/fetchData/index.js
index 2c1393a..d2aa985 100644
--- a/src/client/Containers/Calculation/lib/fetchData/index.js
+++ b/src/client/Containers/Calculation/lib/fetchData/index.js
@@ -37,14 +37,16 @@ export default () =>
{
entities: { systemuser },
},
- { entities: insuranceCompanies },
+ {
+ entities: { insuranceCompany },
+ },
]) => {
CalculationStore.applyOptions(ownerOptions);
CalculationStore.applyOptions(initialOptions);
CalculationStore.applyStaticData(staticEntities);
CalculationStore.applyStaticData({ systemuser: [systemuser] });
CalculationStore.setTableColumns('tableInsurance')({
- options: { ...insuranceCompanies },
+ options: { insuranceCompany },
});
const supplierCurrency = CalculationStore.options.selectSupplierCurrency?.find(
diff --git a/src/client/Containers/Calculation/lib/fetchData/queries/insuranceQuery.ts b/src/client/Containers/Calculation/lib/fetchData/queries/insuranceQuery.ts
index 561485d..1cfa6da 100644
--- a/src/client/Containers/Calculation/lib/fetchData/queries/insuranceQuery.ts
+++ b/src/client/Containers/Calculation/lib/fetchData/queries/insuranceQuery.ts
@@ -1,5 +1,5 @@
-import { IQueryToCRMGQL } from 'core/types/Calculation/Requests';
import { gql } from '@apollo/client';
+import { IQueryToCRMGQL } from 'core/types/Calculation/Requests';
const query = gql`
query($evo_account_type: [Int!], $statecode: Int) {
@@ -10,6 +10,7 @@ const query = gql`
accountid
name
evo_type_ins_policy
+ evo_id_elt
}
}
`;
diff --git a/src/client/Containers/Calculation/lib/fetchData/queries/optionsQuery.ts b/src/client/Containers/Calculation/lib/fetchData/queries/optionsQuery.ts
index 6815031..c74573c 100644
--- a/src/client/Containers/Calculation/lib/fetchData/queries/optionsQuery.ts
+++ b/src/client/Containers/Calculation/lib/fetchData/queries/optionsQuery.ts
@@ -66,6 +66,7 @@ const query = gql`
evo_client_riskid
}
selectBrand: evo_brands(statecode: $statecode) {
+ evo_id
evo_name
evo_brandid
evo_importer_reward_perc
diff --git a/src/client/Containers/Calculation/lib/renderSections.js b/src/client/Containers/Calculation/lib/renderSections.js
index b3cc79c..57f135f 100644
--- a/src/client/Containers/Calculation/lib/renderSections.js
+++ b/src/client/Containers/Calculation/lib/renderSections.js
@@ -1,4 +1,5 @@
-import { Divider as AntDivider, Tabs } from 'antd';
+import { Tabs } from 'antd';
+import Divider from 'client/Elements/Divider';
import { SecondaryColoredText } from 'client/Elements/Text';
import colors from 'client/UIKit/colors';
import { Box, Flex } from 'client/UIKit/grid';
@@ -37,13 +38,11 @@ const renderBlocks = ({ blocks }) => {
return null;
}
return blocks.map((block, ib) => {
- const { elements, title: blockTitle } = block;
+ const { elements, title } = block;
return (
- {blockTitle && (
- {blockTitle}
- )}
+ {title && {title}}
{renderElements({ elements })}
@@ -51,18 +50,11 @@ const renderBlocks = ({ blocks }) => {
});
};
-const BlocksTitle = ({ text }) =>
- text ? (
-
- {text}
-
- ) : null;
+const BlocksTitle = styled(Divider)`
+ margin: 16px 0;
+ color: ${colors.primary} !important;
+ font-size: 0.95rem;
+`;
const BlocksGrid = styled(Box)`
display: grid;
@@ -80,11 +72,11 @@ export const renderGroups = ({ groups }) => {
return null;
}
return groups.map((group, ig) => {
- const { title: blocksTitle, blocks, style } = group;
+ const { title, blocks, style } = group;
return (
-
+ {title && {title}}
{renderBlocks({ blocks })}
);
@@ -95,9 +87,9 @@ export const renderSections = ({ sectionsList }) => {
return (
{sectionsList.map((section, is) => {
- const { title: tabTitle, groups } = section;
+ const { title, groups } = section;
return (
-
+
{renderGroups({ groups })}
);
diff --git a/src/client/Elements/Alert.jsx b/src/client/Elements/Alert.jsx
new file mode 100644
index 0000000..ea10159
--- /dev/null
+++ b/src/client/Elements/Alert.jsx
@@ -0,0 +1,5 @@
+import { Alert as AntAlert } from 'antd';
+
+const Alert = props => ;
+
+export default Alert;
diff --git a/src/client/Elements/Divider.jsx b/src/client/Elements/Divider.jsx
new file mode 100644
index 0000000..efc0d4d
--- /dev/null
+++ b/src/client/Elements/Divider.jsx
@@ -0,0 +1,3 @@
+import { Divider } from 'antd';
+
+export default Divider;
diff --git a/src/client/Elements/Text.jsx b/src/client/Elements/Text.jsx
index 4d63e5c..c947692 100644
--- a/src/client/Elements/Text.jsx
+++ b/src/client/Elements/Text.jsx
@@ -14,3 +14,8 @@ export const SecondaryText = styled(PrimaryText)`
export const SecondaryColoredText = styled(SecondaryText)`
color: ${colors.secondary};
`;
+
+export const ErrorText = styled(PrimaryText)`
+ font-size: 0.9rem;
+ color: red;
+`;
diff --git a/src/client/hooks/Calculation/useUrl.js b/src/client/hooks/Calculation/useUrl.js
index ab80974..7c98a1c 100644
--- a/src/client/hooks/Calculation/useUrl.js
+++ b/src/client/hooks/Calculation/useUrl.js
@@ -1,7 +1,8 @@
import { useStores } from '../useStores';
export const useUrl = ({ urlName }) => {
- const { calculationUrls } = useStores();
+ const { calculationStore } = useStores();
+ const { calculationUrls } = calculationStore.stores;
const url = calculationUrls.urls[urlName];
return { url };
};
diff --git a/src/client/hooks/Calculation/useValue.js b/src/client/hooks/Calculation/useValue.js
index 65ec092..f1aa51f 100644
--- a/src/client/hooks/Calculation/useValue.js
+++ b/src/client/hooks/Calculation/useValue.js
@@ -40,7 +40,8 @@ export const useTableValue = ({
propName,
columnCallback,
}) => {
- const { calculationStore, calculationProcess } = useStores();
+ const { calculationStore } = useStores();
+ const { calculationProcess } = calculationStore.stores;
const [currentValue, setCurrentValue] = useState(undefined);
//get row value from store
diff --git a/src/client/stores/CalculationStore/Data/tables.js b/src/client/stores/CalculationStore/Data/tables.js
index b17bc74..2f51fc6 100644
--- a/src/client/stores/CalculationStore/Data/tables.js
+++ b/src/client/stores/CalculationStore/Data/tables.js
@@ -29,6 +29,10 @@ const tablesActions = {
return values;
},
+ getTableOptions(tableName, propName) {
+ return this.tables[tableName].options[propName];
+ },
+
replaceTableRows(tableName) {
return rows => {
this.tables[tableName].rows.replace(rows);
diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts
index 440527f..3098d35 100644
--- a/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts
+++ b/src/client/stores/CalculationStore/Effects/actions/calculate/prepareData.ts
@@ -3,7 +3,7 @@ import { currentDate } from 'core/tools/date';
import { PaymentRow, PreparedValues } from 'core/types/Calculation/Prepare';
import { IPreparedData } from 'core/types/Calculation/Requests';
import { ICalculationStore } from 'core/types/Calculation/Store';
-import NIL from 'uuid/dist/esm-browser/nil';
+import NIL from 'uuid/dist/nil';
import { convertPrice } from '../../lib/tools';
export default ({
diff --git a/src/client/stores/CalculationStore/Effects/actions/createKP.js b/src/client/stores/CalculationStore/Effects/actions/createKP.js
index 58bac7c..441d97d 100644
--- a/src/client/stores/CalculationStore/Effects/actions/createKP.js
+++ b/src/client/stores/CalculationStore/Effects/actions/createKP.js
@@ -5,13 +5,14 @@ import UserStore from 'client/stores/UserStore';
import { CRM_PROXY_URL } from 'core/constants/urls';
import CrmService from 'core/services/CrmService';
import { toJS } from 'mobx';
-import CalculationStore, { calculationUrls } from '../..';
+import CalculationStore from '../..';
import customValues from '../lib/customValues';
import { quoteFields } from '../lib/queries';
import calculate from './calculate';
export default async () => {
const { values, tables } = CalculationStore;
+ const { calculationUrls } = CalculationStore.stores;
const calculationRes = await calculate();
if (!calculationRes) {
diff --git a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts
index 9a7aa88..9dac562 100644
--- a/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts
+++ b/src/client/stores/CalculationStore/Effects/reactions/loadKpReaction/index.ts
@@ -2,7 +2,6 @@
import { message } from 'antd';
import { elementsValues } from 'client/Containers/Calculation/lib/elements/values';
import { openNotification } from 'client/Elements/Notification';
-import { calculationProcess } from 'client/stores/CalculationStore';
import initialValues from 'client/stores/CalculationStore/config/initialValues';
import CrmService from 'core/services/CrmService';
import { currentISODate } from 'core/tools/date';
@@ -12,7 +11,7 @@ import { TElements } from 'core/types/Calculation/Store/elements';
import { Process } from 'core/types/Calculation/Store/process';
import { IEvoGraph } from 'core/types/Entities/crmEntities';
import { ElementStatus } from 'core/types/statuses';
-import { NIL } from 'uuid';
+import NIL from 'uuid/dist/nil';
import mapKPtoValues from './mapKpToValues';
import optionsQuery from './optionsQuery';
import quoteQuery from './quoteQuery';
@@ -63,6 +62,8 @@ const loadKpReaction: IReactionEffect = calculationStore => ({
calculationStore.setStatus('btnCalculate', ElementStatus.Disabled);
calculationStore.setStatus('btnCreateKP', ElementStatus.Disabled);
+ const { calculationProcess } = calculationStore.stores;
+
CrmService.crmgqlquery({
query: quoteQuery,
variables: {
diff --git a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts
index 41c61f9..7abea0c 100644
--- a/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts
+++ b/src/client/stores/CalculationStore/Effects/reactions/requestReactions.ts
@@ -812,6 +812,7 @@ export default [
statecode: $statecode
evo_brandid: $evo_brandid
) {
+ evo_id
evo_name
evo_modelid
evo_leasingobject_risk
diff --git a/src/client/stores/CalculationStore/Effects/when.ts b/src/client/stores/CalculationStore/Effects/when.ts
new file mode 100644
index 0000000..6c9dc5a
--- /dev/null
+++ b/src/client/stores/CalculationStore/Effects/when.ts
@@ -0,0 +1,49 @@
+import { IWhenEffect } from 'core/types/Calculation/Store/effect'; // @ts-nocheck
+import { pick } from 'lodash';
+
+const mapInsType = {
+ kasko: 100000000,
+ osago: 100000001,
+};
+
+const whenEffects: IWhenEffect[] = [
+ calculationStore => ({
+ predicate: () => {
+ const insuranceCompanies = calculationStore.getTableOptions(
+ 'tableInsurance',
+ 'insuranceCompany',
+ );
+ return insuranceCompanies !== undefined && insuranceCompanies.length > 0;
+ },
+ effect: () => {
+ const insuranceCompanies = calculationStore.getTableOptions(
+ 'tableInsurance',
+ 'insuranceCompany',
+ );
+ if (insuranceCompanies === undefined) {
+ return;
+ }
+ const { ELTStore } = calculationStore.stores;
+ insuranceCompanies.forEach(company => {
+ if (company.evo_id_elt) {
+ const companyData = pick(
+ company,
+ ['evo_id_elt', 'name', 'accountid'],
+ '',
+ );
+ Object.keys(mapInsType).forEach(insType => {
+ if (
+ company &&
+ company.evo_type_ins_policy &&
+ company.evo_type_ins_policy.includes(mapInsType[insType])
+ ) {
+ ELTStore[insType].list.push(companyData);
+ }
+ });
+ }
+ });
+ },
+ }),
+];
+
+export default whenEffects;
diff --git a/src/client/stores/CalculationStore/index.ts b/src/client/stores/CalculationStore/index.ts
index 59547c7..ab6ca73 100644
--- a/src/client/stores/CalculationStore/index.ts
+++ b/src/client/stores/CalculationStore/index.ts
@@ -1,55 +1,20 @@
-import { ElementParam, ICalculationStore } from 'core/types/Calculation/Store';
-import { ElementsNames } from 'core/types/Calculation/Store/elements';
-import { LinksNames } from 'core/types/Calculation/Store/links';
-import { Process } from 'core/types/Calculation/Store/process';
-import { TableNames } from 'core/types/Calculation/Store/tables';
-import { ElementStatus } from 'core/types/statuses';
+import { ICalculationStore } from 'core/types/Calculation/Store';
import { isEqual } from 'lodash';
-import { autorun, makeAutoObservable, reaction } from 'mobx';
+import { autorun, makeAutoObservable, reaction, when } from 'mobx';
import staticData from './Data/static';
import tables from './Data/tables';
import values from './Data/values';
import autorunEffects from './Effects/autorun';
import computedEffects from './Effects/computed';
import reactionEffects from './Effects/reactions';
+import whenEffects from './Effects/when';
+import subStores from './subStores';
-export const calculationProcess = makeAutoObservable({
- process: Process.Default,
- setProcess(process) {
- this.process = process;
- },
-
- bypass: {
- status: undefined,
- },
- setBypass({
- param,
- target,
- value,
- }: {
- param: ElementParam;
- target: (ElementsNames | TableNames)[];
- value: ElementStatus;
- }) {
- this.bypass[param] = { target, value };
- },
- clearBypass(param: ElementParam) {
- this.bypass[param] = undefined;
- },
-});
-
-export const calculationUrls = makeAutoObservable({
- urls: {},
- setUrl({ name, url }: { name: LinksNames; url: string }) {
- this.urls[name] = url;
- },
-});
+const { calculationProcess } = subStores;
const CalculationStore: ICalculationStore = makeAutoObservable(
Object.assign({}, staticData, values, tables, computedEffects, {
- stores: {
- calculationProcess,
- },
+ stores: subStores,
}),
);
@@ -68,4 +33,9 @@ reactionEffects.map(reactionEffectBuilder => {
});
});
+whenEffects.map(whenEffectBuilder => {
+ const whenEffect = whenEffectBuilder(CalculationStore);
+ return when(whenEffect.predicate, whenEffect.effect);
+});
+
export default CalculationStore;
diff --git a/src/client/stores/CalculationStore/subStores/calculationProcess.ts b/src/client/stores/CalculationStore/subStores/calculationProcess.ts
new file mode 100644
index 0000000..66330ff
--- /dev/null
+++ b/src/client/stores/CalculationStore/subStores/calculationProcess.ts
@@ -0,0 +1,35 @@
+import { ElementParam } from 'core/types/Calculation/Store';
+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 { ElementStatus } from 'core/types/statuses';
+import { makeAutoObservable } from 'mobx';
+
+const calculationProcess = makeAutoObservable({
+ process: Process.Default,
+ setProcess(process) {
+ this.process = process;
+ },
+
+ bypass: {
+ status: undefined,
+ },
+ setBypass({
+ param,
+ target,
+ value,
+ }: {
+ param: ElementParam;
+ target: (ElementsNames | TableNames)[];
+ value: ElementStatus;
+ }) {
+ this.bypass[param] = { target, value };
+ },
+ clearBypass(param: ElementParam) {
+ this.bypass[param] = undefined;
+ },
+});
+
+export default calculationProcess;
+
+export type TCalculationProcess = typeof calculationProcess;
diff --git a/src/client/stores/CalculationStore/subStores/calculationUrls.ts b/src/client/stores/CalculationStore/subStores/calculationUrls.ts
new file mode 100644
index 0000000..513c696
--- /dev/null
+++ b/src/client/stores/CalculationStore/subStores/calculationUrls.ts
@@ -0,0 +1,13 @@
+import { LinksNames } from 'core/types/Calculation/Store/links';
+import { makeAutoObservable } from 'mobx';
+
+const calculationUrls = makeAutoObservable({
+ urls: {},
+ setUrl({ name, url }: { name: LinksNames; url: string }) {
+ this.urls[name] = url;
+ },
+});
+
+export default calculationUrls;
+
+export type TCalculationUrls = typeof calculationUrls;
diff --git a/src/client/stores/CalculationStore/subStores/eltStore.ts b/src/client/stores/CalculationStore/subStores/eltStore.ts
new file mode 100644
index 0000000..c8e7bf7
--- /dev/null
+++ b/src/client/stores/CalculationStore/subStores/eltStore.ts
@@ -0,0 +1,32 @@
+// @ts-nocheck
+import { makeAutoObservable } from 'mobx';
+
+const ELTStore = makeAutoObservable(
+ Object.assign(
+ {},
+ ...['osago', 'kasko'].map(x => ({
+ [x]: {
+ list: [],
+ selectedKey: '',
+ setKey(key) {
+ this.selectedKey = key;
+ },
+ getSelectedCompany() {
+ const selectedItem = this.list.find(
+ x => x.evo_id_elt === this.selectedKey,
+ );
+ return selectedItem;
+ },
+ },
+ })),
+ {
+ setCompanyRes(insType, index, res) {
+ this[insType].list[index] = res;
+ },
+ },
+ ),
+);
+
+export type TELTStore = typeof ELTStore;
+
+export default ELTStore;
diff --git a/src/client/stores/CalculationStore/subStores/index.js b/src/client/stores/CalculationStore/subStores/index.js
new file mode 100644
index 0000000..080e880
--- /dev/null
+++ b/src/client/stores/CalculationStore/subStores/index.js
@@ -0,0 +1,9 @@
+import calculationProcess from './calculationProcess';
+import calculationUrls from './calculationUrls';
+import ELTStore from './eltStore';
+
+export default {
+ calculationProcess,
+ calculationUrls,
+ ELTStore,
+};
diff --git a/src/client/stores/index.js b/src/client/stores/index.js
index b867cbd..2006f55 100644
--- a/src/client/stores/index.js
+++ b/src/client/stores/index.js
@@ -1,14 +1,9 @@
-import CalculationStore, {
- calculationProcess,
- calculationUrls,
-} from './CalculationStore';
+import CalculationStore from './CalculationStore';
import UserStore from './UserStore';
class RootStore {
constructor() {
this.calculationStore = CalculationStore;
- this.calculationProcess = calculationProcess;
- this.calculationUrls = calculationUrls;
this.userStore = UserStore;
}
}
diff --git a/src/core/constants/urls.js b/src/core/constants/urls.js
index 4c1c384..849907e 100644
--- a/src/core/constants/urls.js
+++ b/src/core/constants/urls.js
@@ -1,3 +1,4 @@
export const CRM_PROXY_URL = '/crmgraphql';
export const CORE_PROXY_URL = '/core';
export const AUTH_PROXY_URL = '/auth-srv';
+export const ELT_PROXY_URL = '/elt';
diff --git a/src/core/services/ELTService/Kasko.js b/src/core/services/ELTService/Kasko.js
new file mode 100644
index 0000000..2a3fea7
--- /dev/null
+++ b/src/core/services/ELTService/Kasko.js
@@ -0,0 +1,23 @@
+import axios from 'axios';
+import { ELT_PROXY_URL } from 'core/constants/urls';
+
+export default class {
+ static getCalculation = payload =>
+ new Promise((resolve, reject) => {
+ axios
+ .post(
+ String.prototype.concat(
+ ELT_PROXY_URL,
+ '/insurance',
+ '/calculateKasko',
+ ),
+ payload,
+ )
+ .then(res => {
+ resolve(res.data);
+ })
+ .catch(err => {
+ reject(err);
+ });
+ });
+}
diff --git a/src/core/services/ELTService/Osago.js b/src/core/services/ELTService/Osago.js
new file mode 100644
index 0000000..7998801
--- /dev/null
+++ b/src/core/services/ELTService/Osago.js
@@ -0,0 +1,24 @@
+import axios from 'axios';
+import { ELT_PROXY_URL } from 'core/constants/urls';
+
+export default class {
+ static getCalculation = payload =>
+ new Promise((resolve, reject) => {
+ axios
+ .post(
+ String.prototype.concat(
+ ELT_PROXY_URL,
+ '/insurance',
+ '/calculateOsago',
+ ),
+ payload,
+ )
+ .then(res => {
+ resolve(res.data);
+ })
+ .catch(err => {
+ reject(err);
+ throw err.response.data;
+ });
+ });
+}
diff --git a/src/core/services/ELTService/index.js b/src/core/services/ELTService/index.js
new file mode 100644
index 0000000..75ca302
--- /dev/null
+++ b/src/core/services/ELTService/index.js
@@ -0,0 +1,4 @@
+import kasko from './Kasko';
+import osago from './Osago';
+
+export default { kasko, osago };
diff --git a/src/core/types/Calculation/Store/effect.ts b/src/core/types/Calculation/Store/effect.ts
index f7b34cc..ce619c7 100644
--- a/src/core/types/Calculation/Store/effect.ts
+++ b/src/core/types/Calculation/Store/effect.ts
@@ -1,4 +1,4 @@
-import { calculationProcess } from 'client/stores/CalculationStore';
+import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess';
import { IReactionOptions, IReactionPublic, Lambda } from 'mobx';
import { ICalculationStore } from './';
@@ -8,8 +8,6 @@ export type TAction = {
[actionName in ActionsNames]?: () => void;
};
-export type TCalculationProcess = typeof calculationProcess;
-
export interface IAutorunEffect {
(CalculationStore: ICalculationStore): () => void;
}
diff --git a/src/core/types/Calculation/Store/elements.ts b/src/core/types/Calculation/Store/elements.ts
index 9600f99..fbc6d7c 100644
--- a/src/core/types/Calculation/Store/elements.ts
+++ b/src/core/types/Calculation/Store/elements.ts
@@ -157,14 +157,23 @@ export type ResultElementsNames =
| 'labelResultDopMPLLeasing'
| 'labelResultBonusDopProd';
+export type CustomComponents = 'componentElt';
+
+export type AllElements =
+ | ElementsNames
+ | ResultElementsNames
+ | LinkElementsNames
+ | CustomComponents;
+
export enum ElementType {
Default,
Computed,
Table,
Action,
Link,
+ Custom,
}
export type TElements = {
- [elementName in ElementsNames | ResultElementsNames | LinkElementsNames]?: T;
+ [elementName in AllElements]?: T;
};
diff --git a/src/core/types/Calculation/Store/index.ts b/src/core/types/Calculation/Store/index.ts
index b3d4db8..084fc86 100644
--- a/src/core/types/Calculation/Store/index.ts
+++ b/src/core/types/Calculation/Store/index.ts
@@ -1,3 +1,6 @@
+import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess';
+import { TCalculationUrls } from 'client/stores/CalculationStore/subStores/calculationUrls';
+import { TELTStore } from 'client/stores/CalculationStore/subStores/eltStore';
import { TCRMEntity } from '../../Entities/crmEntities';
import { CRMEntityNames } from '../../Entities/crmEntityNames';
import { ElementStatus } from '../../statuses';
@@ -11,6 +14,7 @@ import {
StoreTables,
TableNames,
TableProps,
+ TableValuesNames,
TCellCallback,
} from './tables';
import { ResultValuesNames, TValue, TValues, ValuesNames } from './values';
@@ -78,7 +82,12 @@ interface ICalculationTables {
tableName: TableNames,
rowIndex: number,
paramName: ElementParam,
- ) => { values: TableProps };
+ ) => TableProps;
+
+ getTableOptions: (
+ tableName: TableNames,
+ propName: TableValuesNames,
+ ) => (IBaseOption & TCRMEntity)[] | undefined;
replaceTableRows: (
tableName: TableNames,
@@ -108,4 +117,14 @@ interface ICalculationTables {
}) => void;
}
-export type ICalculationStore = ICalculationValues & ICalculationTables;
+interface ICalculationStores {
+ stores: {
+ calculationProcess: TCalculationProcess;
+ calculationUrls: TCalculationUrls;
+ ELTStore: TELTStore;
+ };
+}
+
+export type ICalculationStore = ICalculationValues &
+ ICalculationTables &
+ ICalculationStores;
diff --git a/src/core/types/Calculation/Store/tables.ts b/src/core/types/Calculation/Store/tables.ts
index f9c95e6..26c7e59 100644
--- a/src/core/types/Calculation/Store/tables.ts
+++ b/src/core/types/Calculation/Store/tables.ts
@@ -1,8 +1,9 @@
+import { TCalculationProcess } from 'client/stores/CalculationStore/subStores/calculationProcess';
+import { Component } from 'core/types/Calculation/components';
import { ElementStatus } from '../../statuses';
import { ElementProps } from '../components';
import { ICalculationStore } from './';
import { TCRMEntity } from './../../Entities/crmEntities';
-import { TCalculationProcess } from './effect';
import { TElementFilter } from './filters';
import { IBaseOption } from './options';
@@ -45,7 +46,7 @@ export type TableColumnCallbacks = TableProps;
export type TableColumn = {
name: TableValuesNames;
title: string;
- Component: () => JSX.Element;
+ Component: Component;
props?: ElementProps;
};
diff --git a/src/core/types/Calculation/components.ts b/src/core/types/Calculation/components.ts
index 0617091..8e6a5cb 100644
--- a/src/core/types/Calculation/components.ts
+++ b/src/core/types/Calculation/components.ts
@@ -1,21 +1,13 @@
-import {
- ElementsNames,
- LinkElementsNames,
- ResultElementsNames,
-} from './Store/elements';
+import React from 'react';
+import { AllElements } from './Store/elements';
import { TableNames } from './Store/tables';
export type ElementProps = { [key: string]: any };
-export type Component = () => JSX.Element;
+export type Component = React.FC;
interface IBlock {
title?: string;
- elements: (
- | ElementsNames
- | ResultElementsNames
- | TableNames
- | LinkElementsNames
- )[];
+ elements: (AllElements | TableNames)[];
[key: string]: any;
}
diff --git a/src/core/types/Entities/crmEntities.ts b/src/core/types/Entities/crmEntities.ts
index b8f46e5..ffd3f2a 100644
--- a/src/core/types/Entities/crmEntities.ts
+++ b/src/core/types/Entities/crmEntities.ts
@@ -16,6 +16,7 @@ export interface IAccount {
customerid?: string;
evo_kpp?: string;
evo_address_legalidData?: IEvoAddress;
+ evo_id_elt?: string;
}
export interface IEvoAddress {
diff --git a/src/index.tsx b/src/index.jsx
similarity index 100%
rename from src/index.tsx
rename to src/index.jsx