Calculation: add Settings Component

This commit is contained in:
Chika 2022-06-17 18:15:29 +03:00
parent a349a17649
commit 2e9f47d95b
9 changed files with 56 additions and 29 deletions

View File

@ -0,0 +1,20 @@
/* eslint-disable import/prefer-default-export */
/* eslint-disable object-curly-newline */
import type { FormTabRows } from '../lib/render-rows';
const defaultRowStyle = { gridTemplateColumns: '1fr' };
export const rows: FormTabRows = [
{ title: 'Выбор Интереса/ЛС' },
[['selectLead'], defaultRowStyle],
[['selectOpportunity'], defaultRowStyle],
[['cbxRecalcWithRevision'], defaultRowStyle],
[['selectQuote'], defaultRowStyle],
[['btnCalculate'], defaultRowStyle],
{ title: 'Параметры расчета' },
[['labelIrrInfo'], defaultRowStyle],
[['radioCalcType'], defaultRowStyle],
[['tbxIRR_Perc'], defaultRowStyle],
[['tbxTotalPayments'], defaultRowStyle],
];

View File

@ -0,0 +1,7 @@
import Background from 'Elements/layout/Background';
import renderFormRows from '../lib/render-rows';
import { rows } from './config';
export default function Settings() {
return <Background>{renderFormRows(rows)}</Background>;
}

View File

@ -29,7 +29,7 @@ const components: Record<
tbxSaleBonus: InputNumber,
tbxFirstPaymentPerc: InputNumber,
tbxFirstPaymentRub: InputNumber,
radioLastPaymentRule: Segmented,
radioLastPaymentRule: Radio,
tbxLastPaymentPerc: InputNumber,
tbxLastPaymentRub: InputNumber,
tbxRedemptionPaymentSum: InputNumber,
@ -121,7 +121,7 @@ const components: Record<
tbxIRR_Perc: InputNumber,
tbxMileage: InputNumber,
tbxEngineHours: InputNumber,
radioCalcType: Radio,
radioCalcType: Segmented,
tbxTotalPayments: InputNumber,
radioObjectRegistration: Radio,
selectObjectRegionRegistration: Select,

View File

@ -58,6 +58,11 @@ const props: Partial<ElementsProps> = {
precision: 2,
formatter: formatNumber,
},
radioLastPaymentRule: {
spaceProps: {
direction: 'vertical',
},
},
tbxFirstPaymentPerc: {
min: 0,
max: 50,
@ -308,10 +313,6 @@ const props: Partial<ElementsProps> = {
marginBottom: '8px',
},
},
radioCalcType: {
optionType: 'button',
buttonStyle: 'solid',
},
tbxTotalPayments: {
min: 0,
step: 1000,

View File

@ -70,6 +70,11 @@ const renderElements = (Object.keys(map) as (keyof typeof map)[]).reduce((acc, e
return acc;
}, {} as Record<keyof typeof map, RenderProps>);
const defaultLinkProps = {
text: 'Открыть в CRM',
type: 'link',
};
const overrideRenderElements: Partial<Record<keyof typeof map, RenderProps>> = {
selectLead: {
render: () => {
@ -91,7 +96,7 @@ const overrideRenderElements: Partial<Record<keyof typeof map, RenderProps>> = {
return (
<Container>
<Head title={title} addon={<LinkComponent text="Открыть в CRM" />} />
<Head title={title} addon={<LinkComponent {...defaultLinkProps} />} />
<Element {...props} />
</Container>
);
@ -118,7 +123,7 @@ const overrideRenderElements: Partial<Record<keyof typeof map, RenderProps>> = {
return (
<Container>
<Head title={title} addon={<LinkComponent text="Открыть в CRM" />} />
<Head title={title} addon={<LinkComponent {...defaultLinkProps} />} />
<Element {...props} />
</Container>
);
@ -145,7 +150,7 @@ const overrideRenderElements: Partial<Record<keyof typeof map, RenderProps>> = {
return (
<Container>
<Head title={title} addon={<LinkComponent text="Открыть в CRM" />} />
<Head title={title} addon={<LinkComponent {...defaultLinkProps} />} />
<Element {...props} />
</Container>
);

View File

@ -1,5 +1,15 @@
import styled from 'styled-components';
import { Box } from 'UIKit/grid';
import Form from './Form';
import Settings from './Settings';
const Grid = styled(Box)``;
export default function Calculation() {
return <Form />;
return (
<Grid>
<Form />
<Settings />
</Grid>
);
}

View File

@ -23,7 +23,7 @@ export interface ElementsProps {
tbxSaleBonus: InputNumberProps;
tbxFirstPaymentPerc: InputNumberProps;
tbxFirstPaymentRub: InputNumberProps;
radioLastPaymentRule: SegmentedProps;
radioLastPaymentRule: RadioProps;
tbxLastPaymentPerc: InputNumberProps;
tbxLastPaymentRub: InputNumberProps;
tbxRedemptionPaymentSum: InputNumberProps;
@ -115,7 +115,7 @@ export interface ElementsProps {
tbxIRR_Perc: InputNumberProps;
tbxMileage: InputNumberProps;
tbxEngineHours: InputNumberProps;
radioCalcType: RadioProps;
radioCalcType: SegmentedProps;
tbxTotalPayments: InputNumberProps;
radioObjectRegistration: RadioProps;
selectObjectRegionRegistration: SelectProps;

View File

@ -1,27 +1,13 @@
/* eslint-disable react/prop-types */
/* eslint-disable import/no-unresolved */
import styled from 'styled-components';
import { Flex } from 'UIKit/grid';
import { min } from 'UIKit/mq';
import Header from './Header';
const Main = styled.main`
${min('laptop')} {
margin: 3px 8px;
}
${min('desktop')} {
margin: 3px 7%;
}
${min('extra')} {
margin: 3px 15%;
}
`;
export default function Layout({ children }) {
return (
<Flex flexDirection="column">
<Header />
<Main>{children}</Main>
<main>{children}</main>
</Flex>
);
}

View File

@ -1,4 +1,3 @@
import DownloadOutlined from '@ant-design/icons/lib/icons/DownloadOutlined';
import { Button as AntButton } from 'antd';
import type { BaseButtonProps } from 'antd/lib/button/button';
import type { BaseElementProps } from './types';
@ -20,7 +19,6 @@ export default function Link({
href={value}
disabled={status === 'Disabled'}
loading={status === 'Loading'}
icon={<DownloadOutlined />}
{...props}
>
{text}