import React, { Component } from 'react'
import PropTypes from 'prop-types'
import CanvasNetworkGraph from 'components/Network/CanvasNetworkGraph'
import PeersList from 'components/Network/PeersList'
import ChannelsList from 'components/Network/ChannelsList'
import TransactionForm from 'components/Network/TransactionForm'
import styles from './Network.scss'
class Network extends Component {
componentWillMount() {
const { fetchDescribeNetwork, fetchPeers, fetchChannels } = this.props
fetchPeers()
fetchChannels()
fetchDescribeNetwork()
}
componentDidUpdate(prevProps) {
const { payReqIsLn, network: { pay_req }, fetchInvoiceAndQueryRoutes, clearQueryRoutes } = this.props
// If LN go retrieve invoice details
if ((prevProps.network.pay_req !== pay_req) && payReqIsLn) {
fetchInvoiceAndQueryRoutes(pay_req)
}
if (prevProps.payReqIsLn && !payReqIsLn) {
clearQueryRoutes()
}
}
componentWillUnmount() {
const { clearQueryRoutes, resetPayReq, clearSelectedChannels, clearSelectedPeers } = this.props
clearQueryRoutes()
resetPayReq()
clearSelectedChannels()
clearSelectedPeers()
}
render() {
const {
setCurrentTab,
updateSelectedPeers,
setCurrentRoute,
network,
selectedPeerPubkeys,
currentRouteChanIds,
peers: { peers },
activeChannels,
selectedChannelIds,
updateSelectedChannels,
updatePayReq,
identity_pubkey
} = this.props
const renderContent = () => {
switch (network.currentTab) {
case 1:
return