2021-02-09 10:37:48 -05:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import classNames from 'classnames'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import Icon from '../../../shared/components/icon'
|
2024-09-04 03:52:08 -04:00
|
|
|
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
|
|
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
|
|
import OLBadge from '@/features/ui/components/ol/ol-badge'
|
2021-02-09 10:37:48 -05:00
|
|
|
|
|
|
|
function ChatToggleButton({ chatIsOpen, unreadMessageCount, onClick }) {
|
|
|
|
const { t } = useTranslation()
|
2024-09-06 08:36:15 -04:00
|
|
|
const classes = classNames('btn', 'btn-full-height', { active: chatIsOpen })
|
2021-02-09 10:37:48 -05:00
|
|
|
|
|
|
|
const hasUnreadMessages = unreadMessageCount > 0
|
|
|
|
|
|
|
|
return (
|
2021-11-15 11:33:57 -05:00
|
|
|
<div className="toolbar-item">
|
2024-09-04 03:52:08 -04:00
|
|
|
<button type="button" className={classes} onClick={onClick}>
|
|
|
|
<BootstrapVersionSwitcher
|
|
|
|
bs3={
|
|
|
|
<Icon
|
|
|
|
type="comment"
|
|
|
|
fw
|
|
|
|
className={classNames({ bounce: hasUnreadMessages })}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
bs5={
|
|
|
|
<MaterialIcon
|
|
|
|
type="chat"
|
|
|
|
className={classNames('align-middle', {
|
|
|
|
bounce: hasUnreadMessages,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
{hasUnreadMessages && <OLBadge bg="info">{unreadMessageCount}</OLBadge>}
|
2021-11-15 11:33:57 -05:00
|
|
|
<p className="toolbar-label">{t('chat')}</p>
|
|
|
|
</button>
|
|
|
|
</div>
|
2021-02-09 10:37:48 -05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
ChatToggleButton.propTypes = {
|
|
|
|
chatIsOpen: PropTypes.bool,
|
|
|
|
unreadMessageCount: PropTypes.number.isRequired,
|
2021-04-27 03:52:58 -04:00
|
|
|
onClick: PropTypes.func.isRequired,
|
2021-02-09 10:37:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ChatToggleButton
|