104 lines
2.4 KiB
TypeScript
104 lines
2.4 KiB
TypeScript
import Link from 'Elements/Link';
|
||
import Tooltip from 'Elements/Tooltip';
|
||
import type { FC, ReactNode } from 'react';
|
||
import { Flex } from 'UIKit/grid';
|
||
import buildReadonly from '../builders/build-readonly';
|
||
import type { Elements } from './map-values';
|
||
|
||
function Head({ children }: { children: ReactNode }) {
|
||
return (
|
||
<Flex
|
||
flexDirection={['column', 'row']}
|
||
justifyContent={['', 'space-between']}
|
||
alignItems={['', 'center']}
|
||
>
|
||
{children}
|
||
</Flex>
|
||
);
|
||
}
|
||
|
||
type RenderProps = { render: (Title: FC, Element: FC) => JSX.Element };
|
||
|
||
const render: Partial<Record<Elements, RenderProps>> = {
|
||
selectLead: {
|
||
render: (Title, Element) => {
|
||
const LinkComponent = buildReadonly(Link, {
|
||
elementName: 'linkLeadUrl',
|
||
valueName: 'leadUrl',
|
||
});
|
||
|
||
return (
|
||
<Flex flexDirection="column">
|
||
<Head>
|
||
<Title />
|
||
<LinkComponent text="Открыть в CRM" />
|
||
</Head>
|
||
<Element />
|
||
</Flex>
|
||
);
|
||
},
|
||
},
|
||
|
||
selectOpportunity: {
|
||
render: (Title, Element) => {
|
||
const LinkComponent = buildReadonly(Link, {
|
||
elementName: 'linkOpportunityUrl',
|
||
valueName: 'opportunityUrl',
|
||
});
|
||
|
||
return (
|
||
<Flex flexDirection="column">
|
||
<Head>
|
||
<Title />
|
||
<LinkComponent text="Открыть в CRM" />
|
||
</Head>
|
||
<Element />
|
||
</Flex>
|
||
);
|
||
},
|
||
},
|
||
|
||
selectQuote: {
|
||
render: (Title, Element) => {
|
||
const LinkComponent = buildReadonly(Link, {
|
||
elementName: 'linkQuoteUrl',
|
||
valueName: 'quoteUrl',
|
||
});
|
||
|
||
return (
|
||
<Flex flexDirection="column">
|
||
<Head>
|
||
<Title />
|
||
<LinkComponent text="Открыть в CRM" />
|
||
</Head>
|
||
<Element />
|
||
</Flex>
|
||
);
|
||
},
|
||
},
|
||
|
||
tbxVehicleTaxInYear: {
|
||
render: (Title, Component) => (
|
||
<Tooltip title="Без учета налога на роскошь" placement="topLeft">
|
||
<Flex flexDirection="column">
|
||
<Title />
|
||
<Component />
|
||
</Flex>
|
||
</Tooltip>
|
||
),
|
||
},
|
||
|
||
selectHighSeasonStart: {
|
||
render: (Title, Component) => (
|
||
<Tooltip title="С какого платежа начинается полный высокий сезон" placement="topLeft">
|
||
<Flex flexDirection="column">
|
||
<Title />
|
||
<Component />
|
||
</Flex>
|
||
</Tooltip>
|
||
),
|
||
},
|
||
};
|
||
|
||
export default render;
|