import React from 'react'
import PropTypes from 'prop-types'
import Isvg from 'react-inlinesvg'
import x from 'icons/x.svg'
import styles from './AddChannel.scss'
const AddChannel = ({
contactsform,
closeContactsForm,
openSubmitChannelForm,
updateContactFormSearchQuery,
updateManualFormSearchQuery,
setNode,
activeChannelPubkeys,
nonActiveChannelPubkeys,
pendingOpenChannelPubkeys,
filteredNetworkNodes,
loadingChannelPubkeys,
showManualForm,
openManualForm
}) => {
const renderRightSide = node => {
if (loadingChannelPubkeys.includes(node.pub_key)) {
return (
)
}
if (activeChannelPubkeys.includes(node.pub_key)) {
return (
Online
)
}
if (nonActiveChannelPubkeys.includes(node.pub_key)) {
return (
Offline
)
}
if (pendingOpenChannelPubkeys.includes(node.pub_key)) {
return (
Pending
)
}
if (!node.addresses.length) {
return Private
}
return (
{
// set the node public key for the submit form
setNode(node)
// open the submit form
openSubmitChannelForm()
}}
>
Connect
)
}
const searchUpdated = search => {
updateContactFormSearchQuery(search)
if (search.includes('@') && search.split('@')[0].length === 66) {
updateManualFormSearchQuery(search)
}
}
return (
{filteredNetworkNodes.map(node => (
-
{node.alias.length > 0 ? (
{node.alias.trim()}
({node.pub_key.substr(0, 10)}...{node.pub_key.substr(
node.pub_key.length - 10
)})
) : (
{node.pub_key}
)}
))}
{showManualForm && (
Hm, looks like we can't see that node from here, wanna try to manually connect?
Connect Manually
)}
)
}
AddChannel.propTypes = {
contactsform: PropTypes.object.isRequired,
closeContactsForm: PropTypes.func.isRequired,
openSubmitChannelForm: PropTypes.func.isRequired,
updateContactFormSearchQuery: PropTypes.func.isRequired,
updateManualFormSearchQuery: PropTypes.func.isRequired,
setNode: PropTypes.func.isRequired,
activeChannelPubkeys: PropTypes.array.isRequired,
nonActiveChannelPubkeys: PropTypes.array.isRequired,
pendingOpenChannelPubkeys: PropTypes.array.isRequired,
filteredNetworkNodes: PropTypes.array.isRequired,
loadingChannelPubkeys: PropTypes.array.isRequired,
showManualForm: PropTypes.bool.isRequired,
openManualForm: PropTypes.func.isRequired
}
export default AddChannel