Calculation/Form: organize exports & naming
This commit is contained in:
parent
362ecff603
commit
2bd4190a2d
@ -1,15 +1,12 @@
|
||||
import type { FormComponentConfig } from '../../lib/renderFormComponent';
|
||||
import type { FormTabRows } from '../../lib/render-rows';
|
||||
|
||||
const config: FormComponentConfig = {
|
||||
id: 'insurance',
|
||||
title: 'Страхование',
|
||||
rows: [
|
||||
[['tbxLeaseObjectYear', 'selectLeaseObjectUseFor', 'selectLegalClientRegion']],
|
||||
[['selectEngineType', 'tbxInsFranchise', 'selectLegalClientTown']],
|
||||
[['selectLeaseObjectCategory', 'tbxMileage', 'tbxINNForCalc']],
|
||||
[['tbxLeaseObjectMotorPower', 'cbxWithTrailer', 'selectGPSBrand']],
|
||||
[['tbxEngineVolume', 'cbxInsDecentral', 'selectGPSModel']],
|
||||
],
|
||||
};
|
||||
export const id = 'insurance';
|
||||
export const title = 'Страхование';
|
||||
|
||||
export default config;
|
||||
export const rows: FormTabRows = [
|
||||
[['tbxLeaseObjectYear', 'selectLeaseObjectUseFor', 'selectLegalClientRegion']],
|
||||
[['selectEngineType', 'tbxInsFranchise', 'selectLegalClientTown']],
|
||||
[['selectLeaseObjectCategory', 'tbxMileage', 'tbxINNForCalc']],
|
||||
[['tbxLeaseObjectMotorPower', 'cbxWithTrailer', 'selectGPSBrand']],
|
||||
[['tbxEngineVolume', 'cbxInsDecentral', 'selectGPSModel']],
|
||||
];
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import renderFormComponent from 'Components/Calculation/lib/renderFormComponent';
|
||||
import renderFormRows from 'Components/Calculation/lib/render-rows';
|
||||
import { Flex } from 'UIKit/grid';
|
||||
import config from './config';
|
||||
import { id, rows, title } from './config';
|
||||
|
||||
function Insurance() {
|
||||
const rows = renderFormComponent(config);
|
||||
const renderedRows = renderFormRows(rows);
|
||||
|
||||
return (
|
||||
<Flex flexDirection="column">
|
||||
{rows}
|
||||
{renderedRows}
|
||||
{/* TODO: add Insurance Table */}
|
||||
{/* TODO: add FinGAP Table */}
|
||||
</Flex>
|
||||
@ -15,7 +15,7 @@ function Insurance() {
|
||||
}
|
||||
|
||||
export default {
|
||||
id: config.id,
|
||||
title: config.title,
|
||||
id,
|
||||
title,
|
||||
Component: Insurance,
|
||||
};
|
||||
|
||||
@ -1,18 +1,15 @@
|
||||
/* eslint-disable object-curly-newline */
|
||||
import type { FormComponentConfig } from '../../lib/renderFormComponent';
|
||||
import type { FormTabRows } from '../../lib/render-rows';
|
||||
|
||||
const config: FormComponentConfig = {
|
||||
id: 'leasing',
|
||||
title: 'Лизинг',
|
||||
rows: [
|
||||
[['selectProduct'], { gridTemplateColumns: '1fr' }],
|
||||
[['tbxLeaseObjectPrice', 'tbxVATInLeaseObjectPrice', 'tbxLeaseObjectPriceWthtVAT']],
|
||||
[['selectSupplierCurrency', 'tbxSupplierDiscountRub', 'tbxSupplierDiscountPerc']],
|
||||
[['tbxFirstPaymentPerc', 'tbxFirstPaymentRub']],
|
||||
[['tbxLeasingPeriod', 'tbxSaleBonus', 'tbxRedemptionPaymentSum']],
|
||||
[['selectSubsidy', 'labelSubsidySum']],
|
||||
[['tbxLastPaymentPerc', 'tbxLastPaymentRub', 'radioLastPaymentRule']],
|
||||
],
|
||||
};
|
||||
export const id = 'leasing';
|
||||
export const title = 'Лизинг';
|
||||
|
||||
export default config;
|
||||
export const rows: FormTabRows = [
|
||||
[['selectProduct'], { gridTemplateColumns: '1fr' }],
|
||||
[['tbxLeaseObjectPrice', 'tbxVATInLeaseObjectPrice', 'tbxLeaseObjectPriceWthtVAT']],
|
||||
[['selectSupplierCurrency', 'tbxSupplierDiscountRub', 'tbxSupplierDiscountPerc']],
|
||||
[['tbxFirstPaymentPerc', 'tbxFirstPaymentRub']],
|
||||
[['tbxLeasingPeriod', 'tbxSaleBonus', 'tbxRedemptionPaymentSum']],
|
||||
[['selectSubsidy', 'labelSubsidySum']],
|
||||
[['tbxLastPaymentPerc', 'tbxLastPaymentRub', 'radioLastPaymentRule']],
|
||||
];
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import renderFormComponent from 'Components/Calculation/lib/renderFormComponent';
|
||||
import config from './config';
|
||||
import renderFormRows from 'Components/Calculation/lib/render-rows';
|
||||
import { id, rows, title } from './config';
|
||||
|
||||
function Leasing() {
|
||||
return renderFormComponent(config);
|
||||
return renderFormRows(rows);
|
||||
}
|
||||
|
||||
export default {
|
||||
id: config.id,
|
||||
title: config.title,
|
||||
id,
|
||||
title,
|
||||
Component: Leasing,
|
||||
};
|
||||
|
||||
@ -1,26 +1,23 @@
|
||||
/* eslint-disable object-curly-newline */
|
||||
import type { FormComponentConfig } from '../../lib/renderFormComponent';
|
||||
import type { FormTabRows } from '../../lib/render-rows';
|
||||
|
||||
const config: FormComponentConfig = {
|
||||
id: 'leasing-object',
|
||||
title: 'ПЛ',
|
||||
rows: [
|
||||
[
|
||||
['selectLeaseObjectType', 'labelDepreciationGroup'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '2fr 1fr'] },
|
||||
],
|
||||
[['selectBrand', 'cbxLeaseObjectUsed'], { gridTemplateColumns: ['1fr', '1fr', '2fr 1fr'] }],
|
||||
[['selectModel', 'cbxWithTrailer'], { gridTemplateColumns: ['1fr', '1fr', '2fr 1fr'] }],
|
||||
[
|
||||
['selectConfiguration', 'radioDeliveryTime'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '2fr 1fr'] },
|
||||
],
|
||||
[['selectLeaseObjectUseFor'], { gridTemplateColumns: '1fr' }],
|
||||
[['tbxLeaseObjectCount', 'selectEngineType', 'tbxMaxSpeed']],
|
||||
[['tbxLeaseObjectYear', 'tbxLeaseObjectMotorPower', 'tbxCountSeats']],
|
||||
[['selectLeaseObjectCategory', 'tbxEngineVolume', 'tbxMileage']],
|
||||
[['tbxMaxMass', 'tbxEngineHours']],
|
||||
export const id = 'leasing-object';
|
||||
export const title = 'ПЛ';
|
||||
|
||||
export const rows: FormTabRows = [
|
||||
[
|
||||
['selectLeaseObjectType', 'labelDepreciationGroup'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '2fr 1fr'] },
|
||||
],
|
||||
};
|
||||
|
||||
export default config;
|
||||
[['selectBrand', 'cbxLeaseObjectUsed'], { gridTemplateColumns: ['1fr', '1fr', '2fr 1fr'] }],
|
||||
[['selectModel', 'cbxWithTrailer'], { gridTemplateColumns: ['1fr', '1fr', '2fr 1fr'] }],
|
||||
[
|
||||
['selectConfiguration', 'radioDeliveryTime'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '2fr 1fr'] },
|
||||
],
|
||||
[['selectLeaseObjectUseFor'], { gridTemplateColumns: '1fr' }],
|
||||
[['tbxLeaseObjectCount', 'selectEngineType', 'tbxMaxSpeed']],
|
||||
[['tbxLeaseObjectYear', 'tbxLeaseObjectMotorPower', 'tbxCountSeats']],
|
||||
[['selectLeaseObjectCategory', 'tbxEngineVolume', 'tbxMileage']],
|
||||
[['tbxMaxMass', 'tbxEngineHours']],
|
||||
];
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import renderFormComponent from '../../lib/renderFormComponent';
|
||||
import config from './config';
|
||||
import renderFormRows from '../../lib/render-rows';
|
||||
import { id, rows, title } from './config';
|
||||
|
||||
function LeasingObject() {
|
||||
return renderFormComponent(config);
|
||||
return renderFormRows(rows);
|
||||
}
|
||||
|
||||
export default {
|
||||
id: config.id,
|
||||
title: config.title,
|
||||
id,
|
||||
title,
|
||||
Component: LeasingObject,
|
||||
};
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import type { ElementsRow } from '../../lib/renderFormComponent';
|
||||
import type { ElementsRow } from '../../lib/render-rows';
|
||||
|
||||
export const id = 'payments';
|
||||
export const title = 'Платежи';
|
||||
|
||||
@ -1,51 +1,45 @@
|
||||
/* eslint-disable object-curly-newline */
|
||||
import type { FormComponentConfig } from '../../lib/renderFormComponent';
|
||||
import type { FormTabRows } from '../../lib/render-rows';
|
||||
|
||||
const config: FormComponentConfig = {
|
||||
id: 'supplier-agent',
|
||||
title: 'Поставщик/агент',
|
||||
rows: [
|
||||
{ title: 'Поставщик предмета лизинга' },
|
||||
[['selectDealer'], { gridTemplateColumns: '1fr' }],
|
||||
[
|
||||
['selectDealerPerson', 'selectDealerBroker'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
[
|
||||
['selectDealerRewardCondition', 'selectDealerBrokerRewardCondition'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
[
|
||||
['tbxDealerRewardSumm', 'tbxDealerBrokerRewardSumm'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
export const id = 'supplier-agent';
|
||||
export const title = 'Поставщик/агент';
|
||||
|
||||
{ title: 'Агент, передавший контакт' },
|
||||
[
|
||||
['selectIndAgent', 'selectCalcDoubleAgent'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
[
|
||||
['selectIndAgentRewardCondition', 'selectCalcDoubleAgentRewardCondition'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
[
|
||||
['tbxIndAgentRewardSumm', 'tbxCalcDoubleAgentRewardSumm'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
[
|
||||
['selectCalcBroker', 'selectCalcFinDepartment'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
[
|
||||
['selectCalcBrokerRewardCondition', 'selectFinDepartmentRewardCondtion'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
[
|
||||
['tbxCalcBrokerRewardSum', 'tbxFinDepartmentRewardSumm'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
export const rows: FormTabRows = [
|
||||
{ title: 'Поставщик предмета лизинга' },
|
||||
[['selectDealer'], { gridTemplateColumns: '1fr' }],
|
||||
[
|
||||
['selectDealerPerson', 'selectDealerBroker'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
[
|
||||
['selectDealerRewardCondition', 'selectDealerBrokerRewardCondition'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
[
|
||||
['tbxDealerRewardSumm', 'tbxDealerBrokerRewardSumm'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
};
|
||||
|
||||
export default config;
|
||||
{ title: 'Агент, передавший контакт' },
|
||||
[['selectIndAgent', 'selectCalcDoubleAgent'], { gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] }],
|
||||
[
|
||||
['selectIndAgentRewardCondition', 'selectCalcDoubleAgentRewardCondition'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
[
|
||||
['tbxIndAgentRewardSumm', 'tbxCalcDoubleAgentRewardSumm'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
[
|
||||
['selectCalcBroker', 'selectCalcFinDepartment'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
[
|
||||
['selectCalcBrokerRewardCondition', 'selectFinDepartmentRewardCondtion'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
[
|
||||
['tbxCalcBrokerRewardSum', 'tbxFinDepartmentRewardSumm'],
|
||||
{ gridTemplateColumns: ['1fr', '1fr', '1fr 1fr'] },
|
||||
],
|
||||
];
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import renderFormComponent from '../../lib/renderFormComponent';
|
||||
import config from './config';
|
||||
import renderFormRows from '../../lib/render-rows';
|
||||
import { id, rows, title } from './config';
|
||||
|
||||
function Leasing() {
|
||||
return renderFormComponent(config);
|
||||
return renderFormRows(rows);
|
||||
}
|
||||
|
||||
export default {
|
||||
id: config.id,
|
||||
title: config.title,
|
||||
id,
|
||||
title,
|
||||
Component: Leasing,
|
||||
};
|
||||
|
||||
@ -12,14 +12,10 @@ export type ElementsRow = [
|
||||
];
|
||||
type DividerRow = { title: string };
|
||||
|
||||
export type FormComponentConfig = {
|
||||
id: string;
|
||||
title: string;
|
||||
rows: Array<ElementsRow | DividerRow>;
|
||||
};
|
||||
export type FormTabRows = Array<ElementsRow | DividerRow>;
|
||||
|
||||
function renderFormComponent(config: FormComponentConfig) {
|
||||
const rows = config.rows.map((row, i) => {
|
||||
function renderFormRows(rowsConfig: FormTabRows) {
|
||||
const rows = rowsConfig.map((row, i) => {
|
||||
if (Array.isArray(row)) {
|
||||
const [elements, style] = row;
|
||||
const renderedElements = elements.map((elementName) => {
|
||||
@ -61,4 +57,4 @@ function renderFormComponent(config: FormComponentConfig) {
|
||||
);
|
||||
}
|
||||
|
||||
export default renderFormComponent;
|
||||
export default renderFormRows;
|
||||
Loading…
x
Reference in New Issue
Block a user