import React, { Component } from 'react' import PropTypes from 'prop-types' import { MdSearch } from 'react-icons/lib/md' import styles from './StepOne.scss' class StepOne extends Component { constructor(props) { super(props); this.state = { peers: props.peers, searchQuery: '' } this.onSearchQuery = this.onSearchQuery.bind(this) this.peerClicked = this.peerClicked.bind(this) } onSearchQuery(searchQuery) { const peers = this.props.peers.filter(peer => peer.pub_key.includes(searchQuery)) this.setState({ peers, searchQuery }) } peerClicked(peer) { const { setNodeKey, changeStep } = this.props setNodeKey(peer.pub_key) changeStep(2) } render() { const { peers, searchQuery } = this.state return (
this.onSearchQuery(event.target.value)} className={`${styles.text} ${styles.input}`} placeholder='Search your peers by their public key' type='text' id='peersSearch' />
) } } StepOne.propTypes = { peers: PropTypes.array.isRequired, setNodeKey: PropTypes.func.isRequired, changeStep: PropTypes.func.isRequired } export default StepOne