basic version of search implemented
This commit is contained in:
52
front-ui/app/components/search/searchResultsPage.js
Normal file
52
front-ui/app/components/search/searchResultsPage.js
Normal file
@@ -0,0 +1,52 @@
|
||||
var React = require('react'),
|
||||
NavigationActions = require('../../actions/navigationActions'),
|
||||
Globals = require('../../globals')
|
||||
Router = require("react-router"),
|
||||
Link = Router.Link;
|
||||
|
||||
var SearchStore = require('../../stores/searchStore');
|
||||
var SearchActions = require('../../actions/searchActions');
|
||||
|
||||
var ItemList = require('../items/itemList');
|
||||
var SearchResultsPage = React.createClass({
|
||||
mixins: [Router.State],
|
||||
getInitialState: function() {
|
||||
return SearchStore.getSearchResultsState();
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
<div>
|
||||
<h1>Resultati pretrage za {this.state.q}</h1>
|
||||
|
||||
|
||||
<ItemList items={this.state.items} />
|
||||
</div>
|
||||
|
||||
);
|
||||
|
||||
},
|
||||
componentWillReceiveProps: function() {
|
||||
this.update();
|
||||
},
|
||||
update: function(){
|
||||
var query = this.getQuery();
|
||||
SearchActions.getSearchResults(query.q);
|
||||
},
|
||||
componentDidMount: function() {
|
||||
SearchStore.addChangeListener(this._onChange);
|
||||
this.update();
|
||||
|
||||
//CartActions.load();
|
||||
},
|
||||
componentWillUnmount: function () {
|
||||
SearchStore.removeChangeListener(this._onChange);
|
||||
},
|
||||
_onChange: function() {
|
||||
if(this.isMounted()) {
|
||||
this.setState(SearchStore.getSearchResultsState());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
module.exports = SearchResultsPage;
|
||||
Reference in New Issue
Block a user