You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-wallet/src/components/notifications/Context/components/Account/index.js

46 lines
1.5 KiB

6 years ago
/* @flow */
import * as React from 'react';
import { Notification } from 'trezor-ui-components';
import l10nMessages from './index.messages';
6 years ago
import type { Props } from '../../index';
// There could be only one account notification
export default (props: Props) => {
const { network, notification } = props.selectedAccount;
if (!network || !notification) return null;
const blockchain = props.blockchain.find(b => b.shortcut === network.shortcut);
if (notification.type === 'backend') {
// special case: backend is down
// TODO: this is a different component with "auto resolve" button
const inProgress = blockchain && blockchain.connecting;
const status = inProgress
? l10nMessages.TR_RECONNECTING
: l10nMessages.TR_CONNECT_TO_BACKEND;
6 years ago
return (
<Notification
variant="error"
6 years ago
title={notification.title}
message={notification.message}
isActionInProgress={inProgress}
5 years ago
actions={[
{
label: props.intl.formatMessage(status),
callback: async () => {
if (!inProgress) props.blockchainReconnect(network.shortcut);
},
5 years ago
},
]}
6 years ago
/>
);
6 years ago
}
return (
<Notification
variant={notification.variant}
title={notification.title}
message={notification.message}
/>
);
5 years ago
};