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

84 lines
2 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';
2021-08-26 20:51:55 +00:00
import { Button, ButtonSize, ButtonVariant } from '../Button';
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 (
2021-08-26 20:51:55 +00:00
<div className="SystemMessage SystemMessage--multiline">
<div className="SystemMessage__line">
<div className="SystemMessage__icon SystemMessage__icon--safety-number" />
<span>
<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}
/>
</span>
</div>
<div className="SystemMessage__line">
<Button
onClick={() => {
showIdentity(contact.id);
}}
size={ButtonSize.Small}
variant={ButtonVariant.SystemMessage}
>
{i18n('verifyNewNumber')}
</Button>
</div>
2020-09-14 19:51:27 +00:00
</div>
);
};