2021-09-07 19:55:03 +00:00
|
|
|
// Copyright 2018-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-07-09 21:29:13 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
2021-08-26 20:51:55 +00:00
|
|
|
import { Button, ButtonSize, ButtonVariant } from '../Button';
|
2021-09-07 19:55:03 +00:00
|
|
|
import { SystemMessage } from './SystemMessage';
|
2018-07-09 21:29:13 +00:00
|
|
|
import { ContactName } from './ContactName';
|
|
|
|
import { Intl } from '../Intl';
|
2019-01-14 21:49:58 +00:00
|
|
|
import { LocalizerType } from '../../types/Util';
|
2018-07-09 21:29:13 +00:00
|
|
|
|
2021-01-14 18:07:05 +00:00
|
|
|
export type ContactType = {
|
2019-03-15 22:18:00 +00:00
|
|
|
id: string;
|
2020-07-24 01:35:32 +00:00
|
|
|
title: string;
|
2021-01-14 18:07:05 +00:00
|
|
|
};
|
2018-07-09 21:29:13 +00:00
|
|
|
|
2019-03-20 17:42:28 +00:00
|
|
|
export type PropsData = {
|
2018-07-09 21:29:13 +00:00
|
|
|
isGroup: boolean;
|
2019-03-15 22:18:00 +00:00
|
|
|
contact: ContactType;
|
|
|
|
};
|
|
|
|
|
|
|
|
type PropsHousekeeping = {
|
2019-01-14 21:49:58 +00:00
|
|
|
i18n: LocalizerType;
|
2019-03-15 22:18:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export type PropsActions = {
|
|
|
|
showIdentity: (id: string) => void;
|
|
|
|
};
|
|
|
|
|
2020-08-26 14:30:31 +00:00
|
|
|
export type Props = PropsData & PropsHousekeeping & PropsActions;
|
2018-07-09 21:29:13 +00:00
|
|
|
|
2020-09-14 19:51:27 +00:00
|
|
|
export const SafetyNumberNotification = ({
|
|
|
|
contact,
|
|
|
|
isGroup,
|
|
|
|
i18n,
|
|
|
|
showIdentity,
|
|
|
|
}: Props): JSX.Element => {
|
|
|
|
const changeKey = isGroup
|
|
|
|
? 'safetyNumberChangedGroup'
|
|
|
|
: 'safetyNumberChanged';
|
2018-07-09 21:29:13 +00:00
|
|
|
|
2020-09-14 19:51:27 +00:00
|
|
|
return (
|
2021-09-07 19:55:03 +00:00
|
|
|
<SystemMessage
|
|
|
|
icon="safety-number"
|
|
|
|
contents={
|
|
|
|
<Intl
|
|
|
|
id={changeKey}
|
|
|
|
components={[
|
|
|
|
<span
|
|
|
|
key="external-1"
|
|
|
|
className="module-safety-number-notification__contact"
|
|
|
|
>
|
|
|
|
<ContactName
|
|
|
|
title={contact.title}
|
|
|
|
module="module-safety-number-notification__contact"
|
|
|
|
/>
|
|
|
|
</span>,
|
|
|
|
]}
|
|
|
|
i18n={i18n}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
button={
|
2021-08-26 20:51:55 +00:00
|
|
|
<Button
|
|
|
|
onClick={() => {
|
|
|
|
showIdentity(contact.id);
|
|
|
|
}}
|
|
|
|
size={ButtonSize.Small}
|
|
|
|
variant={ButtonVariant.SystemMessage}
|
|
|
|
>
|
|
|
|
{i18n('verifyNewNumber')}
|
|
|
|
</Button>
|
2021-09-07 19:55:03 +00:00
|
|
|
}
|
|
|
|
/>
|
2020-09-14 19:51:27 +00:00
|
|
|
);
|
|
|
|
};
|