/* @flow */ import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import styled from 'styled-components'; import { getOldWalletUrl } from 'utils/url'; import { FormattedMessage } from 'react-intl'; import { Link, Button, Icon, P, H5, colors, icons } from 'trezor-ui-components'; import type { TrezorDevice } from 'flowtype'; import l10nCommonMessages from 'views/common.messages'; import l10nMessages from './index.messages'; import type { Props as BaseProps } from '../../Container'; type Props = { device: TrezorDevice, account: $ElementType<$ElementType, 'account'>, showAddress: $ElementType<$ElementType, 'showAddress'>, showUnverifiedAddress: $ElementType< $ElementType, 'showUnverifiedAddress' >, onCancel: $ElementType<$ElementType, 'onCancel'>, }; const StyledLink = styled(Link)` position: absolute; right: 15px; top: 15px; `; const Wrapper = styled.div` max-width: 370px; padding: 30px 0px; `; const Content = styled.div` padding: 0px 48px; `; const StyledP = styled(P)` && { padding-bottom: 20px; } `; const Divider = styled.div` width: 100%; height: 1px; background: ${colors.DIVIDER}; margin: 20px 0px; `; const Row = styled.div` display: flex; flex-direction: column; button + button { margin-top: 10px; } `; const BackupButton = styled(Button)` width: 100%; `; class ConfirmUnverifiedAddress extends PureComponent { componentDidMount(): void { this.keyboardHandler = this.keyboardHandler.bind(this); window.addEventListener('keydown', this.keyboardHandler, false); } componentWillUnmount(): void { window.removeEventListener('keydown', this.keyboardHandler, false); } keyboardHandler: (event: KeyboardEvent) => void; keyboardHandler(event: KeyboardEvent): void { if (event.keyCode === 13) { event.preventDefault(); this.verifyAddress(); } } verifyAddress() { const { account, onCancel, showAddress } = this.props; if (!account) return; onCancel(); showAddress(account.accountPath); } showUnverifiedAddress() { const { onCancel, showUnverifiedAddress } = this.props; onCancel(); showUnverifiedAddress(); } render() { const { device, account, onCancel } = this.props; let deviceStatus; let claim; if (!device.connected) { deviceStatus = ( ); claim = ; } else { // corner-case where device is connected but it is unavailable because it was created with different "passphrase_protection" settings const enable: boolean = !!(device.features && device.features.passphrase_protection); deviceStatus = ( ); claim = enable ? ( ) : ( ); } const needsBackup = device.features && device.features.needs_backup; return (
{deviceStatus}
{needsBackup && } {needsBackup && ( <>
)}
); } } ConfirmUnverifiedAddress.propTypes = { device: PropTypes.object.isRequired, account: PropTypes.object.isRequired, showAddress: PropTypes.func.isRequired, showUnverifiedAddress: PropTypes.func.isRequired, onCancel: PropTypes.func.isRequired, }; export default ConfirmUnverifiedAddress;