import React from 'react'
import PropTypes from 'prop-types'
import Isvg from 'react-inlinesvg'
import x from 'icons/x.svg'
import { FormattedMessage } from 'react-intl'
import messages from './messages'
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 (
)
}
if (nonActiveChannelPubkeys.includes(node.pub_key)) {
return (
)
}
if (pendingOpenChannelPubkeys.includes(node.pub_key)) {
return (
)
}
if (!node.addresses.length) {
return (
)
}
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.length > 0 && (
{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 && (
)}
)
}
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