diff --git a/src/components/Layout.js b/src/components/Layout.js
index 1e5c02c..b32fe32 100644
--- a/src/components/Layout.js
+++ b/src/components/Layout.js
@@ -36,7 +36,6 @@ class Dashboard extends React.Component {
this.getCategoryColor = this.getCategoryColor.bind(this)
this.findEventIdx = this.findEventIdx.bind(this)
this.onKeyDown = this.onKeyDown.bind(this)
- this.updateSearchQuery = this.updateSearchQuery.bind(this)
}
componentDidMount () {
@@ -72,7 +71,6 @@ class Dashboard extends React.Component {
}
handleSelect (selected, axis) {
- console.log(selected)
const matchedEvents = []
const TIMELINE_AXIS = 0
if (axis === TIMELINE_AXIS) {
@@ -230,10 +228,6 @@ class Dashboard extends React.Component {
}
}
- updateSearchQuery (e) {
- let queryString = e.target.value
- this.props.actions.updateSearchQuery(queryString)
- }
render () {
const { actions, app, domain, ui, features } = this.props
@@ -323,7 +317,6 @@ class Dashboard extends React.Component {
diff --git a/src/components/Search.jsx b/src/components/Search.jsx
index b8a5f6d..5a2d91d 100644
--- a/src/components/Search.jsx
+++ b/src/components/Search.jsx
@@ -1,5 +1,9 @@
import React from 'react'
+import { bindActionCreators } from 'redux'
+import { connect } from 'react-redux'
+import * as actions from '../actions'
+
import '../scss/search.scss'
import SearchRow from './SearchRow.jsx'
@@ -7,19 +11,12 @@ import SearchRow from './SearchRow.jsx'
class Search extends React.Component {
constructor (props) {
super(props)
+
this.state = {
- isFolded: true,
- searchResults: [],
- queryString: ''
+ isFolded: true
}
this.onButtonClick = this.onButtonClick.bind(this)
- this.updateSearchQueryResults = this.updateSearchQueryResults.bind(this)
- }
-
- componentDidUpdate (prevProps, prevState) {
- if (prevProps.queryString !== this.props.queryString) {
- this.updateSearchQueryResults(this.props.queryString)
- }
+ this.updateSearchQuery = this.updateSearchQuery.bind(this)
}
onButtonClick () {
@@ -28,21 +25,24 @@ class Search extends React.Component {
})
}
- updateSearchQueryResults (queryString) {
- let searchResults
- if (queryString === '') {
- searchResults = []
- } else {
- searchResults = this.props.events.filter(event =>
- event.description.toLowerCase().includes(queryString.toLowerCase()) || event.location.toLowerCase().includes(queryString.toLowerCase()) || event.category.toLowerCase().includes(queryString.toLowerCase()) || event.date.includes(queryString)
- )
- }
- this.setState({
- searchResults: searchResults
- })
+ updateSearchQuery (e) {
+ let queryString = e.target.value
+ this.props.actions.updateSearchQuery(queryString)
}
render () {
+ let searchResults
+
+ const searchAttributes = ['description', 'location', 'category', 'date']
+
+ if (!this.props.queryString) {
+ searchResults = []
+ } else {
+ searchResults = this.props.events.filter(event =>
+ searchAttributes.map(attribute => { event[attribute].toLowerCase().includes(this.props.queryString.toLowerCase()) })
+ )
+ }
+
return (
@@ -50,11 +50,11 @@ class Search extends React.Component {