merge feature/link-sub-component

This commit is contained in:
Chika 2021-07-29 13:28:00 +03:00
parent 21f5b3cb50
commit 18bd2d562f
8 changed files with 75 additions and 16 deletions

View File

@ -1,5 +1,7 @@
import DownloadOutlined from '@ant-design/icons/lib/icons/DownloadOutlined';
import InsuranceTag from 'client/Components/Calculation/InsuranceTag';
import Link from 'client/Elements/Link';
import { withLink } from 'client/hocs/Calculation';
import { MAX_FRANCHISE } from 'core/constants/stores/Calculation/limits';
import { currentYear } from 'core/tools/date';
import { formatMoney, formatNumber } from 'core/tools/format';
@ -322,12 +324,36 @@ const elementsProps: TElements<ElementProps> = {
},
selectLead: {
showSearch: true,
sub: {
Component: withLink(Link)({
name: 'leadUrl',
text: 'Открыть в CRM',
urlName: 'leadUrl',
type: 'link',
}),
},
},
selectOpportunity: {
showSearch: true,
sub: {
Component: withLink(Link)({
name: 'leadUrl',
text: 'Открыть в CRM',
urlName: 'opportunityUrl',
type: 'link',
}),
},
},
selectQuote: {
showSearch: true,
sub: {
Component: withLink(Link)({
name: 'leadUrl',
text: 'Открыть в CRM',
urlName: 'quoteUrl',
type: 'link',
}),
},
},
btnCalculate: {
text: 'Рассчитать график',
@ -401,7 +427,7 @@ const elementsProps: TElements<ElementProps> = {
// },
},
tableInsurance: {
tag: {
sub: {
Component: InsuranceTag,
},
},

View File

@ -19,6 +19,7 @@ const query = gql`
}
}
evo_inn
link
}
selectOpportunity: opportunities(
statecode: $statecode
@ -37,6 +38,7 @@ const query = gql`
evo_city_fias_id
}
}
link
}
}
`;

View File

@ -22,28 +22,32 @@ const ElementTitle = styled.h5`
white-space: nowrap;
`;
const Head = ({ sub, elementTitle }) => {
if (sub?.Component) {
return (
<Flex
flexDirection={['column', 'row']}
justifyContent={[undefined, 'space-between']}
alignItems={[undefined, 'center']}
>
<ElementTitle>{elementTitle}</ElementTitle>
<sub.Component />
</Flex>
);
}
return <ElementTitle>{elementTitle}</ElementTitle>;
};
const renderElements = ({ elements }) => {
return elements.map((elementName, ie) => {
const elementTitle = elementsTitles[elementName];
const { tooltip, tag, ...elementProps } = elementsProps[elementName] || {};
let TagComponent = () => null;
if (tag && tag.Component) {
TagComponent = tag.Component;
}
const { tooltip, sub, ...elementProps } = elementsProps[elementName] || {};
const Component = buildElement(elementName, elementProps);
return (
<Tooltip {...tooltip}>
<Flex flexDirection="column" key={ie}>
<Flex
flexDirection={['column', 'row']}
justifyContent={[undefined, 'space-between']}
alignItems={[undefined, 'center']}
>
<ElementTitle>{elementTitle}</ElementTitle>
<TagComponent />
</Flex>
<Head sub={sub} elementTitle={elementTitle} />
<Component />
</Flex>
</Tooltip>

View File

@ -17,4 +17,5 @@ offerprintformapi
evo_regionid
evo_legal_regionid
evo_legal_townid
link
`;

View File

@ -1,6 +1,7 @@
import eltReactions from './eltReactions';
import gibddReactions from './gibddReactions';
import insuranceReactions from './insuranceReactions';
import linkReactions from './linkReactions';
import loadKpReaction from './loadKpReaction';
import otherReactions from './otherReactions';
import priceReactions from './priceReactions';
@ -19,5 +20,6 @@ export default [
...gibddReactions,
...eltReactions,
...insuranceReactions,
...linkReactions,
loadKpReaction,
];

View File

@ -0,0 +1,21 @@
import { IReactionEffect } from 'core/types/Calculation/Store/effect';
import { ElementsNames } from 'core/types/Calculation/Store/elements';
import { LinksNames } from 'core/types/Calculation/Store/links';
export default ([
{ elementName: 'selectLead', urlName: 'leadUrl' },
{ elementName: 'selectOpportunity', urlName: 'opportunityUrl' },
{ elementName: 'selectQuote', urlName: 'quoteUrl' },
] as {
elementName: ElementsNames;
urlName: LinksNames;
}[]).map(({ elementName, urlName }) => calculationStore => ({
expression: () => {
return calculationStore.getOption(elementName);
},
effect: targetEntity => {
const { calculationUrls } = calculationStore.stores;
const link = targetEntity?.link ?? undefined;
calculationUrls.setUrl({ name: urlName, url: link });
},
})) as IReactionEffect[];

View File

@ -1 +1 @@
export type LinksNames = 'kpUrl';
export type LinksNames = 'kpUrl' | 'leadUrl' | 'opportunityUrl' | 'quoteUrl';

View File

@ -40,6 +40,7 @@ export interface ILead {
accountidData?: IAccount;
owner_domainname?: string;
evo_inn?: string;
link?: string;
}
export interface IOpportunity {
@ -52,6 +53,7 @@ export interface IOpportunity {
accountidData?: IAccount;
parentaccountid?: string;
evo_addproduct_types?: IEvoAddproductType[];
link?: string;
}
export interface IQuote {
@ -95,6 +97,7 @@ export interface IQuote {
evo_franchise?: string;
evo_id_elt_osago?: string;
evo_object_registration?: number;
link?: string;
}
export interface IEvoGraph {