SearchPage: fix undefined origin

This commit is contained in:
Vesa Luusua 2018-03-08 23:00:21 +02:00
parent 1650a87370
commit 4cb1a6f80b
2 changed files with 5 additions and 8 deletions

View file

@ -86,9 +86,10 @@ const validURLParamsForExtendedData = params => {
// extract search parameters, including a custom attribute named category
const pickSearchParamsOnly = params => {
const { address, origin, bounds, country, ...rest } = params || {};
const originMaybe = config.sortSearchByDistance ? { origin } : {};
const boundsMaybe = bounds ? { bounds } : {};
const originMaybe = config.sortSearchByDistance && origin ? { origin } : {};
return {
bounds,
...boundsMaybe,
...originMaybe,
...validURLParamForExtendedData(CATEGORY_URL_PARAM, rest),
...validURLParamForExtendedData(AMENITIES_URL_PARAM, rest),
@ -552,7 +553,7 @@ SearchPage.loadData = (params, search) => {
latlngBounds: ['bounds'],
});
const { page = 1, address, country, origin, ...rest } = queryParams;
const originMaybe = config.sortSearchByDistance ? { origin } : {};
const originMaybe = config.sortSearchByDistance && origin ? { origin } : {};
return searchListings({
...rest,
...originMaybe,

View file

@ -19,11 +19,7 @@ exports[`SearchPageComponent matches snapshot 1`] = `
>
<withRouter(Connect(TopbarContainerComponent))
currentPage="SearchPage"
currentSearchParams={
Object {
"bounds": undefined,
}
}
currentSearchParams={Object {}}
/>
<div>
<div>