signal-desktop/ts/components/conversation/SafetyNumberNotification.tsx

79 lines
1.8 KiB
TypeScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2018-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import { ContactName } from './ContactName';
import { Intl } from '../Intl';
2019-01-14 21:49:58 +00:00
import { LocalizerType } from '../../types/Util';
export type ContactType = {
id: string;
2020-07-24 01:35:32 +00:00
phoneNumber?: string;
profileName?: string;
2020-07-24 01:35:32 +00:00
title: string;
name?: string;
};
export type PropsData = {
isGroup: boolean;
contact: ContactType;
};
type PropsHousekeeping = {
2019-01-14 21:49:58 +00:00
i18n: LocalizerType;
};
export type PropsActions = {
showIdentity: (id: string) => void;
};
export type Props = PropsData & PropsHousekeeping & PropsActions;
2020-09-14 19:51:27 +00:00
export const SafetyNumberNotification = ({
contact,
isGroup,
i18n,
showIdentity,
}: Props): JSX.Element => {
const changeKey = isGroup
? 'safetyNumberChangedGroup'
: 'safetyNumberChanged';
2020-09-14 19:51:27 +00:00
return (
<div className="module-safety-number-notification">
<div className="module-safety-number-notification__icon" />
<div className="module-safety-number-notification__text">
<Intl
id={changeKey}
components={[
<span
key="external-1"
className="module-safety-number-notification__contact"
>
<ContactName
name={contact.name}
profileName={contact.profileName}
phoneNumber={contact.phoneNumber}
title={contact.title}
module="module-safety-number-notification__contact"
i18n={i18n}
/>
</span>,
]}
i18n={i18n}
/>
</div>
2020-09-14 19:51:27 +00:00
<button
type="button"
onClick={() => {
showIdentity(contact.id);
}}
className="module-safety-number-notification__button"
>
{i18n('verifyNewNumber')}
</button>
</div>
);
};