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