import React from 'react' import PropTypes from 'prop-types' import styles from './ConnectManually.scss' class ConnectManually extends React.Component { render() { const { manualSearchQuery, manualFormIsValid, updateManualFormErrors, openSubmitChannelForm, updateManualFormSearchQuery, setNode, showErrors } = this.props const formSubmitted = () => { if (!manualFormIsValid.isValid) { updateManualFormErrors(manualFormIsValid.errors) return } // clear any existing errors updateManualFormErrors({ manualInput: null }) const [pub_key, addr] = manualSearchQuery && manualSearchQuery.split('@') // the SubmitChannel component is expecting a node object that looks like the following // { // pub_key: 'some_string', // addresses: [ // { // addr: 'some_host_address' // } // ] // } // knowing this we will set the node object with the known format and plug in the pubkey + host accordingly setNode({ pub_key, addresses: [{ addr }] }) // now we close the ConnectManually form and open the SubmitChannel form by chaning the channelFormType openSubmitChannelForm() } return (

Connect Manually

Please enter the peer's pubkey@host

updateManualFormSearchQuery(event.target.value)} />
{showErrors.manualInput && ( {manualFormIsValid && manualFormIsValid.errors.manualInput} )}
Submit
) } } ConnectManually.propTypes = { manualSearchQuery: PropTypes.string.isRequired, manualFormIsValid: PropTypes.object.isRequired, updateManualFormErrors: PropTypes.func.isRequired, openSubmitChannelForm: PropTypes.func.isRequired, updateManualFormSearchQuery: PropTypes.func.isRequired, setNode: PropTypes.func.isRequired, showErrors: PropTypes.object.isRequired } export default ConnectManually