diff --git a/src/containers/SearchPage/SearchPage.helpers.js b/src/containers/SearchPage/SearchPage.helpers.js index d3bec239..0002724a 100644 --- a/src/containers/SearchPage/SearchPage.helpers.js +++ b/src/containers/SearchPage/SearchPage.helpers.js @@ -21,10 +21,19 @@ export const validURLParamForExtendedData = (paramName, paramValue, filters) => const valueArray = paramValue ? paramValue.split(',') : []; if (filterConfig && valueArray.length > 0) { - const allowedValues = filterConfig.options.map(o => o.key); + const { min, max } = filterConfig.config || {}; - const validValues = intersection(valueArray, allowedValues).join(','); - return validValues.length > 0 ? { [paramName]: validValues } : {}; + if (filterConfig.options) { + const allowedValues = filterConfig.options.map(o => o.key); + + const validValues = intersection(valueArray, allowedValues).join(','); + return validValues.length > 0 ? { [paramName]: validValues } : {}; + } else if (filterConfig.config && min != null && max != null) { + const validValues = valueArray.map(v => { + return v < min ? min : v > max ? max : v; + }); + return validValues.length === 2 ? { [paramName]: validValues.join(',') } : {}; + } } return {}; }; diff --git a/src/containers/SearchPage/SearchPage.js b/src/containers/SearchPage/SearchPage.js index e90604f5..fe6c1a89 100644 --- a/src/containers/SearchPage/SearchPage.js +++ b/src/containers/SearchPage/SearchPage.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; +import { array, bool, func, number, oneOf, object, shape, string } from 'prop-types'; import { injectIntl, intlShape } from 'react-intl'; import { connect } from 'react-redux'; import { compose } from 'redux'; @@ -52,7 +52,7 @@ export class SearchPageComponent extends Component { } filters() { - const { categories, amenities } = this.props; + const { categories, amenities, priceFilterConfig } = this.props; return { categoryFilter: { @@ -63,6 +63,10 @@ export class SearchPageComponent extends Component { paramName: 'pub_amenities', options: amenities, }, + priceFilter: { + paramName: 'price', + config: priceFilterConfig, + }, }; } @@ -205,6 +209,7 @@ export class SearchPageComponent extends Component { primaryFilters={{ categoryFilter: filters.categoryFilter, amenitiesFilter: filters.amenitiesFilter, + priceFilter: filters.priceFilter, }} />