2021-01-14 18:07:05 +00:00
|
|
|
// Copyright 2018-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-05-18 23:57:26 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
2020-07-24 01:35:32 +00:00
|
|
|
import { LocalizerType } from '../../types/Util';
|
2020-07-29 23:20:05 +00:00
|
|
|
import { Emojify } from './Emojify';
|
2018-05-18 23:57:26 +00:00
|
|
|
|
2021-01-14 18:07:05 +00:00
|
|
|
export type PropsType = {
|
2021-03-03 20:09:58 +00:00
|
|
|
firstName?: string;
|
2020-07-29 23:20:05 +00:00
|
|
|
i18n: LocalizerType;
|
|
|
|
module?: string;
|
2018-05-18 23:57:26 +00:00
|
|
|
name?: string;
|
2020-07-29 23:20:05 +00:00
|
|
|
phoneNumber?: string;
|
2021-03-03 20:09:58 +00:00
|
|
|
preferFirstName?: boolean;
|
2018-05-18 23:57:26 +00:00
|
|
|
profileName?: string;
|
2021-03-03 20:09:58 +00:00
|
|
|
title: string;
|
2021-01-14 18:07:05 +00:00
|
|
|
};
|
2018-05-18 23:57:26 +00:00
|
|
|
|
2021-03-03 20:09:58 +00:00
|
|
|
export const ContactName = ({
|
|
|
|
firstName,
|
|
|
|
module,
|
|
|
|
preferFirstName,
|
|
|
|
title,
|
|
|
|
}: PropsType): JSX.Element => {
|
2020-09-14 19:51:27 +00:00
|
|
|
const prefix = module || 'module-contact-name';
|
2018-05-18 23:57:26 +00:00
|
|
|
|
2021-03-03 20:09:58 +00:00
|
|
|
let text: string;
|
|
|
|
if (preferFirstName) {
|
|
|
|
text = firstName || title || '';
|
|
|
|
} else {
|
|
|
|
text = title || '';
|
|
|
|
}
|
|
|
|
|
2020-09-14 19:51:27 +00:00
|
|
|
return (
|
|
|
|
<span className={prefix} dir="auto">
|
2021-03-03 20:09:58 +00:00
|
|
|
<Emojify text={text} />
|
2020-09-14 19:51:27 +00:00
|
|
|
</span>
|
|
|
|
);
|
|
|
|
};
|