Merge pull request #736 from sharetribe/keep-filters-when-editing-topbar-location

Keep other filter values when submitting another location in the search page
This commit is contained in:
Kimmo Puputti 2018-03-07 08:58:07 +02:00 committed by GitHub
commit d1b768dfd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 6 deletions

View file

@ -222,10 +222,12 @@ class TopbarComponent extends Component {
}
handleSubmit(values) {
const { currentPage, location } = this.props;
const { search, selectedPlace } = values.location;
const { history } = this.props;
const { origin, bounds, country } = selectedPlace;
const searchParams = { address: search, origin, bounds, country };
const restParams = currentPage === 'SearchPage' ? parse(location.search) : {};
const searchParams = { ...restParams, address: search, origin, bounds, country };
history.push(createResourceLocatorString('SearchPage', routeConfiguration(), {}, searchParams));
}

View file

@ -399,7 +399,7 @@ export class SearchPageComponent extends Component {
mainEntity: [schemaMainEntity],
}}
>
<TopbarContainer className={topbarClasses} />
<TopbarContainer className={topbarClasses} currentPage="SearchPage" />
<div className={css.container}>
<div className={css.searchResultContainer}>
<SearchFilters

View file

@ -17,7 +17,9 @@ exports[`SearchPageComponent matches snapshot 1`] = `
scrollingDisabled={false}
title="SearchPage.schemaTitle"
>
<withRouter(Connect(TopbarContainerComponent)) />
<withRouter(Connect(TopbarContainerComponent))
currentPage="SearchPage"
/>
<div>
<div>
<withRouter(InjectIntl(SearchFiltersComponent))

View file

@ -1,5 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import { bool, func, number, object, shape, string } from 'prop-types';
import { compose } from 'redux';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
@ -12,6 +12,7 @@ import { Topbar } from '../../components';
export const TopbarContainerComponent = props => {
const {
authInProgress,
currentPage,
currentUser,
currentUserHasListings,
currentUserHasOrders,
@ -31,6 +32,7 @@ export const TopbarContainerComponent = props => {
return (
<Topbar
authInProgress={authInProgress}
currentPage={currentPage}
currentUser={currentUser}
currentUserHasListings={currentUserHasListings}
currentUserHasOrders={currentUserHasOrders}
@ -50,16 +52,16 @@ export const TopbarContainerComponent = props => {
};
TopbarContainerComponent.defaultProps = {
currentPage: null,
currentUser: null,
currentUserHasOrders: null,
notificationCount: 0,
sendVerificationEmailError: null,
};
const { bool, func, number, object, shape } = PropTypes;
TopbarContainerComponent.propTypes = {
authInProgress: bool.isRequired,
currentPage: string,
currentUser: propTypes.currentUser,
currentUserHasListings: bool.isRequired,
currentUserHasOrders: bool,