2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2018-2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-07-09 21:29:13 +00:00
|
|
|
import React from 'react';
|
|
|
|
// import classNames from 'classnames';
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
import { missingCaseError } from '../../util/missingCaseError';
|
|
|
|
|
2021-01-14 18:07:05 +00:00
|
|
|
type Contact = {
|
2020-07-24 01:35:32 +00:00
|
|
|
phoneNumber?: string;
|
2018-07-09 21:29:13 +00:00
|
|
|
profileName?: string;
|
|
|
|
name?: 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
|
|
|
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
|
|
|
|
|
|
|
export class VerificationNotification extends React.Component<Props> {
|
2020-09-14 19:51:27 +00:00
|
|
|
public getStringId(): string {
|
2018-07-09 21:29:13 +00:00
|
|
|
const { isLocal, type } = this.props;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case 'markVerified':
|
|
|
|
return isLocal
|
|
|
|
? 'youMarkedAsVerified'
|
|
|
|
: 'youMarkedAsVerifiedOtherDevice';
|
|
|
|
case 'markNotVerified':
|
|
|
|
return isLocal
|
|
|
|
? 'youMarkedAsNotVerified'
|
|
|
|
: 'youMarkedAsNotVerifiedOtherDevice';
|
|
|
|
default:
|
|
|
|
throw missingCaseError(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-14 19:51:27 +00:00
|
|
|
public renderContents(): JSX.Element {
|
2018-07-09 21:29:13 +00:00
|
|
|
const { contact, i18n } = this.props;
|
|
|
|
const id = this.getStringId();
|
|
|
|
|
|
|
|
return (
|
2021-08-26 20:51:55 +00:00
|
|
|
<div className="SystemMessage__text">
|
|
|
|
<Intl
|
|
|
|
id={id}
|
|
|
|
components={[
|
|
|
|
<ContactName
|
|
|
|
key="external-1"
|
|
|
|
name={contact.name}
|
|
|
|
profileName={contact.profileName}
|
|
|
|
phoneNumber={contact.phoneNumber}
|
|
|
|
title={contact.title}
|
|
|
|
module="module-verification-notification__contact"
|
|
|
|
i18n={i18n}
|
|
|
|
/>,
|
|
|
|
]}
|
|
|
|
i18n={i18n}
|
|
|
|
/>
|
|
|
|
</div>
|
2018-07-09 21:29:13 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-14 19:51:27 +00:00
|
|
|
public render(): JSX.Element {
|
2018-07-09 21:29:13 +00:00
|
|
|
const { type } = this.props;
|
2021-08-26 20:51:55 +00:00
|
|
|
const suffix = type === 'markVerified' ? 'verified' : 'verified-not';
|
2018-07-09 21:29:13 +00:00
|
|
|
|
|
|
|
return (
|
2021-08-26 20:51:55 +00:00
|
|
|
<div className="SystemMessage">
|
|
|
|
<div className={`SystemMessage__icon SystemMessage__icon--${suffix}`} />
|
2018-07-09 21:29:13 +00:00
|
|
|
{this.renderContents()}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|