2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2018 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-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';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { LocalizerType } from '../../types/Util';
|
2018-07-09 21:29:13 +00:00
|
|
|
|
|
|
|
import { missingCaseError } from '../../util/missingCaseError';
|
|
|
|
|
2021-09-16 16:15:43 +00:00
|
|
|
type Contact = { title: string };
|
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
|
|
|
type: 'markVerified' | 'markNotVerified';
|
|
|
|
isLocal: boolean;
|
|
|
|
contact: Contact;
|
2019-03-20 17:42:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
type PropsHousekeeping = {
|
2019-01-14 21:49:58 +00:00
|
|
|
i18n: LocalizerType;
|
2019-03-20 17:42:28 +00:00
|
|
|
};
|
|
|
|
|
2020-08-26 18:40:23 +00:00
|
|
|
export type Props = PropsData & PropsHousekeeping;
|
2018-07-09 21:29:13 +00:00
|
|
|
|
2023-04-12 23:17:56 +00:00
|
|
|
function VerificationNotificationContents({
|
|
|
|
contact,
|
|
|
|
isLocal,
|
|
|
|
type,
|
|
|
|
i18n,
|
|
|
|
}: Props) {
|
|
|
|
const name = (
|
|
|
|
<ContactName
|
|
|
|
key="external-1"
|
|
|
|
title={contact.title}
|
|
|
|
module="module-verification-notification__contact"
|
|
|
|
/>
|
|
|
|
);
|
2023-03-29 17:15:54 +00:00
|
|
|
|
2023-04-12 23:17:56 +00:00
|
|
|
switch (type) {
|
|
|
|
case 'markVerified':
|
|
|
|
return isLocal ? (
|
|
|
|
<Intl id="icu:youMarkedAsVerified" components={{ name }} i18n={i18n} />
|
|
|
|
) : (
|
|
|
|
<Intl
|
|
|
|
id="icu:youMarkedAsVerifiedOtherDevice"
|
|
|
|
components={{ name }}
|
|
|
|
i18n={i18n}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
case 'markNotVerified':
|
|
|
|
return isLocal ? (
|
|
|
|
<Intl
|
|
|
|
id="icu:youMarkedAsNotVerified"
|
|
|
|
components={{ name }}
|
|
|
|
i18n={i18n}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<Intl
|
|
|
|
id="icu:youMarkedAsNotVerifiedOtherDevice"
|
|
|
|
components={{ name }}
|
|
|
|
i18n={i18n}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
default:
|
|
|
|
throw missingCaseError(type);
|
2018-07-09 21:29:13 +00:00
|
|
|
}
|
2023-04-12 23:17:56 +00:00
|
|
|
}
|
2018-07-09 21:29:13 +00:00
|
|
|
|
2023-04-12 23:17:56 +00:00
|
|
|
export function VerificationNotification(props: Props): JSX.Element {
|
|
|
|
const { type } = props;
|
|
|
|
return (
|
|
|
|
<SystemMessage
|
|
|
|
icon={type === 'markVerified' ? 'verified' : 'verified-not'}
|
|
|
|
contents={<VerificationNotificationContents {...props} />}
|
|
|
|
/>
|
|
|
|
);
|
2018-07-09 21:29:13 +00:00
|
|
|
}
|