import React from 'react'; const NBSP = String.fromCharCode(160); const CorrespondentLinks = ({ correspondents, activeCorrespondentIdSet, onCorrespondentClick, }) => { if (!Array.isArray(correspondents) || correspondents.length === 0) { return null; } const activeSet = activeCorrespondentIdSet || new Set(); const handleClick = (event, correspondent) => { if (!onCorrespondentClick || correspondent.id == null) { return; } event.stopPropagation(); onCorrespondentClick(correspondent.id); }; return correspondents.map((correspondent, index) => { const isActive = correspondent.id != null && activeSet.has(correspondent.id); const hasHandler = Boolean(onCorrespondentClick) && correspondent.id != null; const classNames = ['doc-correspondent-link']; if (isActive) classNames.push('is-active'); if (!hasHandler) classNames.push('is-static'); const isLast = index === correspondents.length - 1; const label = isLast ? `${correspondent.name}:${NBSP}` : correspondent.name; return ( {isLast ? null : , } ); }); }; export default CorrespondentLinks;