import React, { Component } from 'react' import PropTypes from 'prop-types' import QRCode from 'qrcode.react' import copy from 'copy-to-clipboard' import Isvg from 'react-inlinesvg' import zapLogo from 'icons/zap_logo.svg' import { showNotification } from 'notifications' import styles from './Syncing.scss' class Syncing extends Component { componentWillMount() { const { fetchBlockHeight, blockHeight } = this.props // If we don't already know the target block height, fetch it now. if (!blockHeight) { fetchBlockHeight() } } render() { const { hasSynced, syncPercentage, address, blockHeight, lndBlockHeight } = this.props const copyClicked = () => { copy(address) showNotification('Noice', 'Successfully copied to clipboard') } if (typeof hasSynced === 'undefined') { return null } return (
{hasSynced === true && (

Welcome back to your Zap wallet!

Please wait a while whilst we fetch all of your latest data from the blockchain.

)} {hasSynced === false && (

Fund your Zap wallet

Might as well fund your wallet while you're waiting to sync.

{address && address.length ? (
{address} copy
) : (
)}
)}

Syncing to the blockchain...

{typeof syncPercentage === 'undefined' && 'Preparing...'} {Boolean(syncPercentage >= 0 && syncPercentage < 99) && `${syncPercentage}%`} {Boolean(syncPercentage >= 99) && 'Finalizing...'}

{Boolean(syncPercentage >= 0 && syncPercentage < 99) && ( {Boolean(!blockHeight || !lndBlockHeight) && 'starting...'} {Boolean(blockHeight && lndBlockHeight) && `${lndBlockHeight.toLocaleString()} of ${blockHeight.toLocaleString()}`} )}
) } } Syncing.propTypes = { fetchBlockHeight: PropTypes.func.isRequired, address: PropTypes.string.isRequired, hasSynced: PropTypes.bool, syncPercentage: PropTypes.number, blockHeight: PropTypes.number, lndBlockHeight: PropTypes.number } export default Syncing