import React, { ReactNode } from 'react'; import PropTypes from 'prop-types'; import { useTranslation } from 'react-i18next'; import classNames from 'classnames'; import NavBar from '../NavBar'; import Svg from '../Svg'; import Icon from '../Icon'; import IconButton from '../IconButton'; import Dropdown from '../Dropdown'; import HeaderPatientInfo from '../HeaderPatientInfo'; import { PatientInfoVisibility } from '../../types/PatientInfoVisibility'; function Header({ children, menuOptions, isReturnEnabled, onClickReturnButton, isSticky, WhiteLabeling, showPatientInfo = PatientInfoVisibility.VISIBLE_COLLAPSED, servicesManager, Secondary, appConfig, ...props }: withAppTypes): ReactNode { const { t } = useTranslation('Header'); // TODO: this should be passed in as a prop instead and the react-router-dom // dependency should be dropped const onClickReturn = () => { if (isReturnEnabled && onClickReturnButton) { onClickReturnButton(); } }; return (
{isReturnEnabled && ( )}
{WhiteLabeling?.createLogoComponentFn?.(React, props) || }
{Secondary}
{children}
{showPatientInfo !== PatientInfoVisibility.DISABLED && ( )}
); } 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, onClickReturnButton: PropTypes.func, WhiteLabeling: PropTypes.object, showPatientInfo: PropTypes.string, servicesManager: PropTypes.object, }; Header.defaultProps = { isReturnEnabled: true, isSticky: false, }; export default Header;