import React from 'react'; import classNames from 'classnames'; import { Avatar } from '../Avatar'; import { Contact, getName } from '../../types/Contact'; import { Localizer } from '../../types/Util'; interface Props { contact: Contact; hasSignalAccount: boolean; i18n: Localizer; isIncoming: boolean; withContentAbove: boolean; withContentBelow: boolean; onClick?: () => void; } export class EmbeddedContact extends React.Component { public render() { const { contact, i18n, isIncoming, onClick, withContentAbove, withContentBelow, } = this.props; const module = 'embedded-contact'; return (
{renderAvatar({ contact, i18n, size: 48 })}
{renderName({ contact, isIncoming, module })} {renderContactShorthand({ contact, isIncoming, module })}
); } } // Note: putting these below the main component so style guide picks up EmbeddedContact export function renderAvatar({ contact, i18n, size, }: { contact: Contact; i18n: Localizer; size: number; }) { const { avatar } = contact; const avatarPath = avatar && avatar.avatar && avatar.avatar.path; const name = getName(contact) || ''; return ( ); } export function renderName({ contact, isIncoming, module, }: { contact: Contact; isIncoming: boolean; module: string; }) { return (
{getName(contact)}
); } export function renderContactShorthand({ contact, isIncoming, module, }: { contact: Contact; isIncoming: boolean; module: string; }) { const { number: phoneNumber, email } = contact; const firstNumber = phoneNumber && phoneNumber[0] && phoneNumber[0].value; const firstEmail = email && email[0] && email[0].value; return (
{firstNumber || firstEmail}
); }