Files
Iris/src/js/components/SearchForm.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-11-03 08:57:16 +13:00
import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { Link, browserHistory } from 'react-router'
import { createStore, bindActionCreators } from 'redux'
import FontAwesome from 'react-fontawesome'
import * as uiActions from '../services/ui/actions'
import * as spotifyActions from '../services/spotify/actions'
class SearchForm extends React.Component{
constructor(props) {
super(props);
this.state = {
query: ''
}
}
handleSubmit(e){
e.preventDefault();
2016-12-21 15:24:07 +13:00
browserHistory.push(global.baseURL+'search/'+this.state.query);
2016-11-03 08:57:16 +13:00
return false
}
render(){
return (
<form className={this.props.context+' search-form'} onSubmit={ e => this.handleSubmit(e) }>
<input
type="text"
placeholder="Search"
onChange={ e => this.setState({ query: e.target.value }) }
value={ this.state.query } />
</form>
)
}
}
const mapStateToProps = (state, ownProps) => {
return state;
}
const mapDispatchToProps = (dispatch) => {
return {
uiActions: bindActionCreators(uiActions, dispatch),
spotifyActions: bindActionCreators(spotifyActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(SearchForm)