import * as React from 'react' import * as cx from 'classnames' import InlineSVG from 'svg-inline-react' import { get, isArray } from 'lodash' import { IConversationPanelComponentProps } from './interfaces' import { APP_URL } from '../../../utils/ResourceConstants' import Avatar from '../../Avatar' import { humanizeDate } from '../../../utils/humanize' import './styles.styl' const convo = require('!svg-inline-loader?removeSVGTagAttrs=false&removeTags=false!../../../../img/svg/reply-icon.svg') class ConversationPanel extends React.Component { constructor(props: IConversationPanelComponentProps) { super(props) this.state = { hover: false, } } hover = (hoverState: boolean) => { this.setState({ hover: hoverState }) } render() { const { conversation, avatarUrl, avatarStatus, profile, compact, endUser, endUsersLoading, unreadMessagesByConversationId } = this.props if (endUsersLoading) { return null } const company = get(profile, 'attributes.employmentName', '') const displayName = get(profile, 'attributes.displayName', '') const displayHeader = company || displayName || get(endUser, 'email') || 'Site Visitor' const messagesForConversationId = unreadMessagesByConversationId const hasUnreadMessages = isArray(messagesForConversationId) ? messagesForConversationId.length : get(conversation, 'unreadMessageCount', 0) return (
this.hover(true)} onMouseLeave={() => this.hover(false)} >
{ !!hasUnreadMessages &&
unread
} {humanizeDate(conversation.latestActivity)}
{this.state.hover ?
window.open(`${APP_URL}/inboxes/${conversation.inboxId}/conversations/${conversation.id}`, '_blank')}> Reply
: 15 })}>{displayHeader}}
) } } export default ConversationPanel