Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | 2x 2x | import PropTypes from "prop-types";
import { NavLinkContainer, NavLinkInline, NavLinkDrawer } from "../Links";
import AnimationGroup from "../AnimationGroup/AnimationGroup";
import { PracticeDetails, IndividualDetails } from "../Details";
import SanitizedContent from "../../SanitizedContent";
import * as SvgComponents from "../../../lib/SvgComponents.jsx";
import CmsSwitchLink from "../Links/CmsSwitchLink";
const DynamicContent = ({
contentItems,
className,
recursionId,
config,
isExpandedState,
expand,
}) => {
const { openDrawersByDefault, linkActiveFunc, linkCallback } = config;
let linkClass = isExpandedState ? "link-inline" : "link-collapsed";
const containerRecursionId = recursionId ? recursionId : 0;
const getDynamicIcon = (icon) => {
const Component = SvgComponents[icon];
return Component ? <Component /> : null;
};
const hasDarkerBackground = (darkerBackground) => {
return darkerBackground ? "hr-smaller-vertical-spacing" : "";
};
const itemsMarkup = (contentItems || []).map((item, index) => {
const key = `${JSON.stringify(item)}-${index}-${containerRecursionId}`;
return (
{
divider: (
<AnimationGroup
display={isExpandedState}
key={key}
darkerBackground={item.darkerBackground}
>
<hr className={`${hasDarkerBackground(item.darkerBackground)}`} />
</AnimationGroup>
),
container: (
<DynamicContent
contentItems={item.items}
className={item.className}
recursionId={containerRecursionId + 1}
config={config}
isExpandedState={isExpandedState}
/>
),
linkBack: (
<AnimationGroup display={isExpandedState} key={key}>
<NavLinkInline
className="link-back"
icon={getDynamicIcon("ChevronLeft")}
url={item.url}
label={item.label}
linkCallback={linkCallback}
showLabel={true}
/>
</AnimationGroup>
),
linkHome: (
<AnimationGroup display={isExpandedState} key={key}>
<NavLinkInline
className="account-home-link"
icon={getDynamicIcon(item?.icon)}
url={item.url}
label={item.label}
linkCallback={linkCallback}
showLabel={true}
/>
</AnimationGroup>
),
practiceDetails: (
<AnimationGroup
display={isExpandedState}
className={"details"}
key={key}
>
<PracticeDetails
practiceName={item.practiceName}
{...(!item.practiceTin ? {} : { practiceTin: item.practiceTin })}
{...(!item.apmEntityId ? {} : { apmEntityId: item.apmEntityId })}
{...(!item.vgId ? {} : { vgId: item.vgId })}
{...(!item.cpcPlusId ? {} : { cpcPlusId: item.cpcPlusId })}
{...(!item.pcfId ? {} : { pcfId: item.pcfId })}
{...(!item.subgroupId ? {} : { subgroupId: item.subgroupId })}
/>
</AnimationGroup>
),
individualDetails: (
<AnimationGroup display={isExpandedState} key={key}>
<IndividualDetails
individualName={item.individualName}
individualNpi={item.individualNpi}
/>
</AnimationGroup>
),
linkDrawer: (
<NavLinkDrawer
key={key}
isExpanded={isExpandedState}
isAlwaysOpen={item.isAlwaysOpen}
openByDefault={openDrawersByDefault}
rightIcon="chevron-down"
leftIcon={getDynamicIcon(item?.icon)}
className={linkClass}
label={item.label}
linkActiveFunc={linkActiveFunc}
linkCallback={linkCallback}
listOfLinks={item.items}
url={item.url}
sidebarExpand={expand}
isHighlighted={item.isHighlighted}
darkerBackground={item.darkerBackground}
leftBorderHighlightDisabled={item.leftBorderHighlightDisabled}
hideLabelSection={item.hideLabelSection}
largerDrawerBottomPadding={item.largerDrawerBottomPadding}
/>
),
custom: (
<AnimationGroup display={isExpandedState} key={key}>
<SanitizedContent
html={item.content}
customClassName={item.customClassName}
/>
</AnimationGroup>
),
switchLink: (
<AnimationGroup display={isExpandedState} key={key}>
<CmsSwitchLink
linkCallback={linkCallback}
label={item.label}
url={item.url}
/>
</AnimationGroup>
),
}[item.type] || (
<NavLinkInline
key={key}
icon={getDynamicIcon(item?.icon)}
className={item.className ? item.className : linkClass}
url={item.url}
label={item.label}
linkCallback={linkCallback}
showLabel={isExpandedState}
disabled={item.disabled}
target={item.target}
/>
)
);
});
if (className === "link-container") {
return (
<div className="animation-flat" key={`nav-link-container-${recursionId}`}>
<NavLinkContainer
listOfLinks={itemsMarkup}
linkActiveFunc={linkActiveFunc}
/>
</div>
);
} else {
return <div className={className}>{itemsMarkup}</div>;
}
};
export default DynamicContent;
DynamicContent.propTypes = {
config: PropTypes.object,
isExpandedState: PropTypes.bool,
contentItems: PropTypes.array,
className: PropTypes.string,
recursionId: PropTypes.number,
expand: PropTypes.func,
};
|