import React from 'react'; import PropTypes from 'prop-types'; import { useTranslation } from 'react-i18next'; import classNames from 'classnames'; // TODO: This may fail if package is split from PWA build import { useHistory } from 'react-router-dom'; import { NavBar, Svg, Icon, IconButton, Dropdown } from '@ohif/ui'; function Header({ children, menuOptions, isReturnEnabled, isSticky, WhiteLabeling }) { const { t } = useTranslation(); const history = useHistory(); // TODO: this should be passed in as a prop instead and the react-router-dom // dependency should be dropped const onReturnHandler = () => { if (isReturnEnabled) { history.push('/'); } }; const CustomLogo = (React) => { return WhiteLabeling.createLogoComponentFn(React) } return (
{/* // TODO: Should preserve filter/sort // Either injected service? Or context (like react router's `useLocation`?) */}
{isReturnEnabled && }
{WhiteLabeling ? CustomLogo(React) : }
{children}
{t('Header:INVESTIGATIONAL USE ONLY')}
); } Header.propTypes = { menuOptions: PropTypes.arrayOf( PropTypes.shape({ title: PropTypes.string.isRequired, icon: PropTypes.string, onClick: PropTypes.func.isRequired, }) ), children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]), isReturnEnabled: PropTypes.bool, isSticky: PropTypes.bool, WhiteLabeling: PropTypes.element, }; Header.defaultProps = { isReturnEnabled: true, isSticky: false }; export default Header;