2022-05-24 11:47:17 +03:00

104 lines
2.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;