2018-05-18 16:57:26 -07:00
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import { Emojify } from './Emojify';
|
|
|
|
|
|
|
|
interface Props {
|
2020-01-29 13:58:50 -08:00
|
|
|
phoneNumber?: string;
|
2018-05-18 16:57:26 -07:00
|
|
|
name?: string;
|
|
|
|
profileName?: string;
|
2018-07-09 14:29:13 -07:00
|
|
|
module?: string;
|
2018-05-18 16:57:26 -07:00
|
|
|
}
|
|
|
|
|
2018-05-22 12:31:43 -07:00
|
|
|
export class ContactName extends React.Component<Props> {
|
2018-05-18 16:57:26 -07:00
|
|
|
public render() {
|
2020-02-05 17:28:54 -05:00
|
|
|
const { phoneNumber, name, profileName, module } = this.props;
|
2018-07-09 14:29:13 -07:00
|
|
|
const prefix = module ? module : 'module-contact-name';
|
2018-05-18 16:57:26 -07:00
|
|
|
|
|
|
|
const title = name ? name : phoneNumber;
|
2018-07-09 14:29:13 -07:00
|
|
|
const shouldShowProfile = Boolean(profileName && !name);
|
|
|
|
const profileElement = shouldShowProfile ? (
|
|
|
|
<span className={`${prefix}__profile-name`}>
|
2019-06-27 16:35:21 -04:00
|
|
|
~<Emojify text={profileName || ''} />
|
2018-07-09 14:29:13 -07:00
|
|
|
</span>
|
|
|
|
) : null;
|
2018-05-18 16:57:26 -07:00
|
|
|
|
2020-02-05 17:28:54 -05:00
|
|
|
return (
|
|
|
|
<span className={prefix} dir="auto">
|
2019-06-27 16:35:21 -04:00
|
|
|
<Emojify text={title} />
|
2018-07-09 14:29:13 -07:00
|
|
|
{shouldShowProfile ? ' ' : null}
|
|
|
|
{profileElement}
|
2018-05-18 16:57:26 -07:00
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|