From 89a8951247dd0f4b7807212631e1a701a27444d4 Mon Sep 17 00:00:00 2001 From: apanizo Date: Tue, 4 Sep 2018 16:59:37 +0200 Subject: [PATCH] Refactoring Header component injecting provider details and info as a prop --- src/components/Header/index.jsx | 63 ++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx index e73377ac..13ad649f 100644 --- a/src/components/Header/index.jsx +++ b/src/components/Header/index.jsx @@ -2,7 +2,10 @@ import * as React from 'react' import { connect } from 'react-redux' import { logComponentStack, type Info } from '~/utils/logBoundaries' -import Provider from './component/Provider' +import ProviderInfo from './component/ProviderInfo' +import ProviderDetails from './component/ProviderInfo/UserDetails' +import ProviderDisconnected from './component/ProviderDisconnected' +import ConnectDetails from './component/ProviderDisconnected/ConnectDetails' import Layout from './component/Layout' import actions from './actions' import selector from './selector' @@ -34,36 +37,48 @@ class Header extends React.PureComponent { logComponentStack(error, info) } - reloadWallet = () => { - this.props.fetchProvider() + getProviderInfoBased = (hasError, disconnected) => { + if (hasError) { + // return + } + + if (disconnected) { + return + } + + const { + provider, network, userAddress, connected, + } = this.props + + return + } + + getProviderDetailsBased = (hasError, disconnected) => { + if (hasError) { + // return + } + + if (disconnected) { + return + } + + const { + provider, network, userAddress, connected, + } = this.props + + return } render() { - const { - provider, userAddress, network, connected, - } = this.props + const { connected } = this.props const { hasError } = this.state + const providerDisconnected = !hasError && !connected - // const providerDisconnected = !hasError && !connected - const providerConnected = !hasError && connected + const info = this.getProviderInfoBased(hasError, providerDisconnected) + const details = this.getProviderDetailsBased(hasError, providerDisconnected) - return ( - - {/* hasError && */} - {/* providerDisconnected && */} - { providerConnected && - - } - - ) + return } }