Commit 06e14a25 authored by Matija Obreza's avatar Matija Obreza
Browse files

Suggestions page redirect updated

parent e3ca6469
......@@ -39,10 +39,6 @@ function editDataset(uuid: string) {
};
}
export const applyDatasetFilters = (filters?: any) => (dispatch) => {
dispatch(listDatasetsRequest(undefined, undefined, undefined, filters));
};
function listMyDatasets(page?, results?, sortBy?, filter?: string | IDatasetFilter, order?) {
return (dispatch, getState) => {
const token = getState().login.access_token;
......
......@@ -7,7 +7,7 @@ import { withStyles } from 'material-ui/styles';
import { parse } from 'query-string';
import { navigateTo } from 'actions/navigation';
import { datasetSuggestions } from 'actions/search';
import { applyDatasetFilters } from 'actions/dataset';
import { promiselistDatasets } from 'actions/dataset';
import { IDatasetFilter } from 'model/dataset.model';
// import {Page} from 'model/common.model';
......@@ -28,7 +28,7 @@ interface ISuggestionsPageProps extends React.ClassAttributes<any> {
loading: boolean;
navigateTo: (page, query?) => any;
datasetSuggestions: (searchQuery, filter?: IDatasetFilter) => any;
applyDatasetFilters: any;
promiselistDatasets: any;
suggestions: any;
}
......@@ -61,7 +61,7 @@ class SuggestionsPage extends React.Component<ISuggestionsPageProps, any> {
}
public componentWillReceiveProps(nextProps) {
const { datasetSuggestions, navigateTo, filterCode, filters } = this.props;
const { datasetSuggestions, filterCode, filters } = this.props;
console.log(`Should I be querying for ${nextProps.search} when I have ${this.props.search}?`);
console.log(nextProps, this.props);
......@@ -69,10 +69,6 @@ class SuggestionsPage extends React.Component<ISuggestionsPageProps, any> {
console.log(`Querying for ${nextProps.search}`, filters);
datasetSuggestions(nextProps.search, filters[filterCode]);
}
if (nextProps.filterCode !== this.props.filterCode) {
navigateTo(`/datasets`, { filter: nextProps.filterCode });
}
}
protected search = (e) => {
......@@ -95,8 +91,11 @@ class SuggestionsPage extends React.Component<ISuggestionsPageProps, any> {
protected applyFilters = (newFilters) => {
console.log(`Applying filters`, newFilters);
const { applyDatasetFilters } = this.props;
applyDatasetFilters(newFilters);
const { promiselistDatasets, navigateTo } = this.props;
promiselistDatasets(undefined, undefined, undefined, newFilters)
.then((data) => {
navigateTo(`/datasets`, { filter: data.filterCode });
});
}
public render() {
......@@ -137,7 +136,7 @@ const mapStateToProps = (state, ownProps) => ({
const mapDispatchToProps = (dispatch) => bindActionCreators({
navigateTo,
datasetSuggestions,
applyDatasetFilters,
promiselistDatasets,
}, dispatch);
export default connect(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment