import React from 'react'; import classNames from 'classnames'; import { Emojify } from './conversation/Emojify'; import { Localizer } from '../types/Util'; interface Props { phoneNumber: string; isMe?: boolean; name?: string; color?: string; verified: boolean; profileName?: string; avatarPath?: string; i18n: Localizer; onClick?: () => void; } function getInitial(name: string): string { return name.trim()[0] || '#'; } export class ContactListItem extends React.Component { public renderAvatar({ displayName }: { displayName: string }) { const { avatarPath, i18n, color, name } = this.props; if (avatarPath) { return (
{i18n('contactAvatarAlt',
); } const title = name ? getInitial(name) : '#'; return (
{title}
); } public render() { const { i18n, name, onClick, isMe, phoneNumber, profileName, verified, } = this.props; const title = name ? name : phoneNumber; const displayName = isMe ? i18n('me') : title; const profileElement = !isMe && profileName && !name ? ( ~ ) : null; const showNumber = isMe || name; const showVerified = !isMe && verified; return (
{this.renderAvatar({ displayName })}
{profileElement}
{showVerified ? (
) : null} {showVerified ? ` ${i18n('verified')}` : null} {showVerified && showNumber ? ' ∙ ' : null} {showNumber ? phoneNumber : null}
); } }