2021-09-07 14:55:03 -05:00
|
|
|
// Copyright 2018-2021 Signal Messenger, LLC
|
2020-10-30 15:34:04 -05:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-07-09 14:29:13 -07:00
|
|
|
import React from 'react';
|
|
|
|
|
2021-08-26 16:51:55 -04:00
|
|
|
import { Button, ButtonSize, ButtonVariant } from '../Button';
|
2021-09-07 14:55:03 -05:00
|
|
|
import { SystemMessage } from './SystemMessage';
|
2018-07-09 14:29:13 -07:00
|
|
|
import { ContactName } from './ContactName';
|
|
|
|
import { Intl } from '../Intl';
|
2021-10-26 14:15:33 -05:00
|
|
|
import type { LocalizerType } from '../../types/Util';
|
2018-07-09 14:29:13 -07:00
|
|
|
|
2021-01-14 12:07:05 -06:00
|
|
|
export type ContactType = {
|
2019-03-15 15:18:00 -07:00
|
|
|
id: string;
|
2020-07-23 18:35:32 -07:00
|
|
|
title: string;
|
2021-01-14 12:07:05 -06:00
|
|
|
};
|
2018-07-09 14:29:13 -07:00
|
|
|
|
2019-03-20 10:42:28 -07:00
|
|
|
export type PropsData = {
|
2018-07-09 14:29:13 -07:00
|
|
|
isGroup: boolean;
|
2019-03-15 15:18:00 -07:00
|
|
|
contact: ContactType;
|
|
|
|
};
|
|
|
|
|
|
|
|
type PropsHousekeeping = {
|
2019-01-14 13:49:58 -08:00
|
|
|
i18n: LocalizerType;
|
2019-03-15 15:18:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
export type PropsActions = {
|
|
|
|
showIdentity: (id: string) => void;
|
|
|
|
};
|
|
|
|
|
2020-08-26 07:30:31 -07:00
|
|
|
export type Props = PropsData & PropsHousekeeping & PropsActions;
|
2018-07-09 14:29:13 -07:00
|
|
|
|
2020-09-14 12:51:27 -07:00
|
|
|
export const SafetyNumberNotification = ({
|
|
|
|
contact,
|
|
|
|
isGroup,
|
|
|
|
i18n,
|
|
|
|
showIdentity,
|
|
|
|
}: Props): JSX.Element => {
|
|
|
|
const changeKey = isGroup
|
|
|
|
? 'safetyNumberChangedGroup'
|
|
|
|
: 'safetyNumberChanged';
|
2018-07-09 14:29:13 -07:00
|
|
|
|
2020-09-14 12:51:27 -07:00
|
|
|
return (
|
2021-09-07 14:55:03 -05: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 16:51:55 -04:00
|
|
|
<Button
|
|
|
|
onClick={() => {
|
|
|
|
showIdentity(contact.id);
|
|
|
|
}}
|
|
|
|
size={ButtonSize.Small}
|
|
|
|
variant={ButtonVariant.SystemMessage}
|
|
|
|
>
|
|
|
|
{i18n('verifyNewNumber')}
|
|
|
|
</Button>
|
2021-09-07 14:55:03 -05:00
|
|
|
}
|
|
|
|
/>
|
2020-09-14 12:51:27 -07:00
|
|
|
);
|
|
|
|
};
|