diff --git a/package.json b/package.json index ae71ff9..3e5c5ad 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "evocalculator.client", "private": true, "dependencies": { + "@ant-design/icons": "^4.3.0", "@apollo/client": "^3.3.4", "@babel/code-frame": "^7.10.4", "@babel/helper-split-export-declaration": "^7.11.0", diff --git a/src/client/Containers/Calculation/Sections/sectionsList.ts b/src/client/Containers/Calculation/Sections/sectionsList.ts index 3b2c3fe..1bec17e 100644 --- a/src/client/Containers/Calculation/Sections/sectionsList.ts +++ b/src/client/Containers/Calculation/Sections/sectionsList.ts @@ -357,6 +357,9 @@ const sections: ISection[] = [ { elements: ['btnCreateKP'], }, + { + elements: ['linkDownloadKp'], + }, ], }, ], diff --git a/src/client/Containers/Calculation/lib/buildElement.js b/src/client/Containers/Calculation/lib/buildElement.js index 985100c..7c95410 100644 --- a/src/client/Containers/Calculation/lib/buildElement.js +++ b/src/client/Containers/Calculation/lib/buildElement.js @@ -1,6 +1,7 @@ import { withButton, withComputedValue, + withLink, withTable, withValue, } from 'client/hocs/Calculation'; @@ -13,6 +14,7 @@ import elementsProps from './elements/elementsProps'; import elementsTypes from './elements/types'; import elementsValues from './elements/values'; import tables from './elements/tables'; +import elementsUrls from './elements/urls'; export function buildElement(elementName) { const elementType = elementsTypes[elementName]; @@ -40,6 +42,13 @@ export function buildElement(elementName) { ...elementProps, }); } + case ElementType.Link: { + return withLink(Component)({ + name: elementName, + urlName: elementsUrls[elementName], + ...elementProps, + }); + } 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 758fb8b..806a123 100644 --- a/src/client/Containers/Calculation/lib/elements/components.ts +++ b/src/client/Containers/Calculation/lib/elements/components.ts @@ -9,6 +9,7 @@ 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 Download from 'client/Elements/Download'; import { Component } from 'core/types/Calculation/components'; import { TElements } from 'core/types/Calculation/Store/elements'; @@ -155,6 +156,7 @@ const elementsComponents: TElements = { labelResultBonusMPL: Label, labelResultDopMPLLeasing: Label, labelResultBonusDopProd: Label, + linkDownloadKp: Download, }; const tablesComponents: StoreTables = { diff --git a/src/client/Containers/Calculation/lib/elements/elementsProps.ts b/src/client/Containers/Calculation/lib/elements/elementsProps.ts index 1acd808..9104760 100644 --- a/src/client/Containers/Calculation/lib/elements/elementsProps.ts +++ b/src/client/Containers/Calculation/lib/elements/elementsProps.ts @@ -12,6 +12,8 @@ import { validatePhone, } from 'client/tools/validate'; +import { DownloadOutlined } from '@ant-design/icons'; + const elementsProps: TElements = { selectChannel: { showSearch: true, @@ -70,7 +72,6 @@ const elementsProps: TElements = { }, btnCreateLead: { type: 'primary', - size: 'large', text: 'Создать интерес', }, tbxLeaseObjectPrice: { @@ -277,7 +278,6 @@ const elementsProps: TElements = { }, btnCreateKP: { type: 'primary', - size: 'large', text: 'Создать КП', }, tbxCreditRate: { @@ -318,6 +318,11 @@ const elementsProps: TElements = { max: '500.0000', step: '0.0001', }, + linkDownloadKp: { + type: 'primary', + text: 'Скачать КП', + icon: DownloadOutlined, + }, }; const resultElementsProps: TElements = [ diff --git a/src/client/Containers/Calculation/lib/elements/types.ts b/src/client/Containers/Calculation/lib/elements/types.ts index 5e25c34..b8bf630 100644 --- a/src/client/Containers/Calculation/lib/elements/types.ts +++ b/src/client/Containers/Calculation/lib/elements/types.ts @@ -10,6 +10,7 @@ const elementsTypes: TElements = { btnCreateKP: ElementType.Action, btnCalculate: ElementType.Action, labelIrrInfo: ElementType.Computed, + linkDownloadKp: ElementType.Link, }; const tablesTypes: StoreTables = { diff --git a/src/client/Containers/Calculation/lib/elements/urls.ts b/src/client/Containers/Calculation/lib/elements/urls.ts new file mode 100644 index 0000000..517d474 --- /dev/null +++ b/src/client/Containers/Calculation/lib/elements/urls.ts @@ -0,0 +1,8 @@ +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/Elements/Download.jsx b/src/client/Elements/Download.jsx new file mode 100644 index 0000000..b603919 --- /dev/null +++ b/src/client/Elements/Download.jsx @@ -0,0 +1,20 @@ +import { Button as AntButton } from 'antd'; +import { ElementStatus } from 'core/types/statuses'; +import React from 'react'; + +const Download = ({ status, url, text, icon: Icon, ...props }) => { + return ( + } + > + {text} + + ); +}; + +export default Download; diff --git a/src/client/hocs/Calculation/index.js b/src/client/hocs/Calculation/index.js index b2e4420..6002198 100644 --- a/src/client/hocs/Calculation/index.js +++ b/src/client/hocs/Calculation/index.js @@ -1,7 +1,15 @@ import withButton from './withButton'; +import withLink from './withLink'; import withComputedValue from './withComputedValue'; import withModal from './withModal'; import withTable from './withTable'; import withValue from './withValue'; -export { withButton, withValue, withComputedValue, withModal, withTable }; +export { + withButton, + withLink, + withValue, + withComputedValue, + withModal, + withTable, +}; diff --git a/src/client/hocs/Calculation/withLink.jsx b/src/client/hocs/Calculation/withLink.jsx new file mode 100644 index 0000000..7a1425c --- /dev/null +++ b/src/client/hocs/Calculation/withLink.jsx @@ -0,0 +1,12 @@ +import { useStatus } from 'client/hooks/Calculation/useStatus'; +import { useUrl } from 'client/hooks/Calculation/useUrl'; +import { observer } from 'mobx-react-lite'; +import React from 'react'; + +export default Button => ({ name, urlName, ...props }) => + observer(() => { + const { status } = useStatus(name); + const { url } = useUrl({ urlName }); + + return