diff --git a/Components/Calculation/Form/Leasing/config.ts b/Components/Calculation/Form/Leasing/config.ts index 0c70117..b07abf4 100644 --- a/Components/Calculation/Form/Leasing/config.ts +++ b/Components/Calculation/Form/Leasing/config.ts @@ -1,14 +1,16 @@ /* eslint-disable object-curly-newline */ -import type { SectionsConfig } from 'Components/Calculation/types/sections'; +import type { FormComponentConfig } from '../../lib/renderFormComponent'; -const config: SectionsConfig = [ - [['selectProduct'], { gridTemplateColumns: '1fr' }], - [['tbxLeaseObjectPrice', 'tbxVATInLeaseObjectPrice', 'tbxLeaseObjectPriceWthtVAT']], - [['selectSupplierCurrency', 'tbxSupplierDiscountRub', 'tbxSupplierDiscountPerc']], - [['tbxFirstPaymentPerc', 'tbxFirstPaymentRub']], - [['tbxLeasingPeriod', 'tbxSaleBonus', 'tbxRedemptionPaymentSum']], - [['selectSubsidy', 'labelSubsidySum']], - [['tbxLastPaymentPerc', 'tbxLastPaymentRub', 'radioLastPaymentRule']], -]; +const config: FormComponentConfig = { + rows: [ + [['selectProduct'], { gridTemplateColumns: '1fr' }], + [['tbxLeaseObjectPrice', 'tbxVATInLeaseObjectPrice', 'tbxLeaseObjectPriceWthtVAT']], + [['selectSupplierCurrency', 'tbxSupplierDiscountRub', 'tbxSupplierDiscountPerc']], + [['tbxFirstPaymentPerc', 'tbxFirstPaymentRub']], + [['tbxLeasingPeriod', 'tbxSaleBonus', 'tbxRedemptionPaymentSum']], + [['selectSubsidy', 'labelSubsidySum']], + [['tbxLastPaymentPerc', 'tbxLastPaymentRub', 'radioLastPaymentRule']], + ], +}; export default config; diff --git a/Components/Calculation/Form/Leasing/index.jsx b/Components/Calculation/Form/Leasing/index.jsx index 62a0fe5..cf19cfc 100644 --- a/Components/Calculation/Form/Leasing/index.jsx +++ b/Components/Calculation/Form/Leasing/index.jsx @@ -1,8 +1,8 @@ -import renderElements from 'Components/Calculation/lib/renderElements'; +import renderFormComponent from 'Components/Calculation/lib/renderFormComponent'; import config from './config'; function Leasing() { - return renderElements(config); + return renderFormComponent(config); } export default Leasing; diff --git a/Components/Calculation/Form/Payments/config.ts b/Components/Calculation/Form/Payments/config.ts index 02871c1..341838b 100644 --- a/Components/Calculation/Form/Payments/config.ts +++ b/Components/Calculation/Form/Payments/config.ts @@ -1,8 +1,7 @@ /* eslint-disable import/prefer-default-export */ +import type { FormComponentConfig } from '../../lib/renderFormComponent'; -import type { SectionsConfig } from 'Components/Calculation/types/sections'; - -export const elements: SectionsConfig[number][0] = [ +export const elements: FormComponentConfig['rows'][number][0] = [ 'radioGraphType', 'selectSeasonType', 'tbxParmentsDecreasePercent', diff --git a/Components/Calculation/Form/Payments/index.jsx b/Components/Calculation/Form/Payments/index.jsx index 72e1913..9400924 100644 --- a/Components/Calculation/Form/Payments/index.jsx +++ b/Components/Calculation/Form/Payments/index.jsx @@ -1,4 +1,3 @@ -/* eslint-disable operator-linebreak */ import { Box, Flex } from 'UIKit/grid'; import elementsRender from '../../config/elements-render'; import { elements } from './config'; @@ -10,6 +9,7 @@ function Payments() { return render(); }); + // eslint-disable-next-line operator-linebreak const [radioGraphType, selectSeasonType, tbxParmentsDecreasePercent, selectHighSeasonStart] = renderedElements; diff --git a/Components/Calculation/lib/renderElements.tsx b/Components/Calculation/lib/renderFormComponent.tsx similarity index 55% rename from Components/Calculation/lib/renderElements.tsx rename to Components/Calculation/lib/renderFormComponent.tsx index 1c2c74c..c43d129 100644 --- a/Components/Calculation/lib/renderElements.tsx +++ b/Components/Calculation/lib/renderFormComponent.tsx @@ -1,9 +1,18 @@ +import type { BoxProps } from 'UIKit/grid'; import { Box } from 'UIKit/grid'; import elementsRender from '../config/elements-render'; -import type { SectionsConfig } from '../types/sections'; +import type { Elements as ActionElements } from '../config/map/actions'; +import type { Elements as ComputedElements } from '../config/map/computed'; +import type { Elements as ValuesElements } from '../config/map/values'; -function renderElements(config: SectionsConfig) { - const rows = config.map(([elements, style], i) => { +export type FormComponentConfig = { + rows: Array< + [elements: (ValuesElements | ComputedElements | ActionElements)[], style?: BoxProps['style']] + >; +}; + +function renderFormComponent(config: FormComponentConfig) { + const rows = config.rows.map(([elements, style], i) => { const renderedElements = elements.map((elementName) => { const render = elementsRender[elementName]?.render; @@ -38,4 +47,4 @@ function renderElements(config: SectionsConfig) { ); } -export default renderElements; +export default renderFormComponent; diff --git a/Components/Calculation/types/sections.ts b/Components/Calculation/types/sections.ts deleted file mode 100644 index 07d8dee..0000000 --- a/Components/Calculation/types/sections.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { BoxProps } from 'rebass/styled-components'; -import type { Elements as ActionElements } from '../config/map/actions'; -import type { Elements as ComputedElements } from '../config/map/computed'; -import type { Elements as ValuesElements } from '../config/map/values'; - -export type SectionsConfig = Array< - [elements: (ValuesElements | ComputedElements | ActionElements)[], style?: BoxProps['style']] ->; diff --git a/UIKit/grid.js b/UIKit/grid.js deleted file mode 100644 index 674afd5..0000000 --- a/UIKit/grid.js +++ /dev/null @@ -1 +0,0 @@ -export { Box, Flex } from 'rebass/styled-components'; diff --git a/UIKit/grid.ts b/UIKit/grid.ts new file mode 100644 index 0000000..3974437 --- /dev/null +++ b/UIKit/grid.ts @@ -0,0 +1,2 @@ +export { Box, Flex } from 'rebass/styled-components'; +export type { BoxProps, FlexProps } from 'rebass/styled-components';