53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
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;
|