diff --git a/src/components/SearchFilters/SearchFilters.js b/src/components/SearchFilters/SearchFilters.js index 345794ee..e2fa8d35 100644 --- a/src/components/SearchFilters/SearchFilters.js +++ b/src/components/SearchFilters/SearchFilters.js @@ -9,6 +9,7 @@ import { omit } from 'lodash'; import { SelectSingleFilter, SelectMultipleFilter } from '../../components'; import routeConfiguration from '../../routeConfiguration'; import { createResourceLocatorString } from '../../util/routes'; +import { propTypes } from '../../util/types'; import css from './SearchFilters.css'; // Dropdown container can have a positional offset (in pixels) @@ -166,8 +167,8 @@ SearchFiltersComponent.propTypes = { resultsCount: number, searchingInProgress: bool, onManageDisableScrolling: func.isRequired, - categoriesFilter: object, - amenitiesFilter: object, + categoriesFilter: propTypes.filterConfig, + amenitiesFilter: propTypes.filterConfig, isSearchFiltersPanelOpen: bool, toggleSearchFiltersPanel: func, searchFiltersPanelSelectedCount: number, diff --git a/src/components/SearchFiltersMobile/SearchFiltersMobile.js b/src/components/SearchFiltersMobile/SearchFiltersMobile.js index b2f7baec..97e6886b 100644 --- a/src/components/SearchFiltersMobile/SearchFiltersMobile.js +++ b/src/components/SearchFiltersMobile/SearchFiltersMobile.js @@ -14,6 +14,7 @@ import { SelectSingleFilterPlain, SelectMultipleFilterPlain, } from '../../components'; +import { propTypes } from '../../util/types'; import css from './SearchFiltersMobile.css'; class SearchFiltersMobileComponent extends Component { @@ -248,8 +249,8 @@ SearchFiltersMobileComponent.propTypes = { onCloseModal: func.isRequired, selectedFiltersCount: number, filterParamNames: array, - categoriesFilter: object, - amenitiesFilter: object, + categoriesFilter: propTypes.filterConfig, + amenitiesFilter: propTypes.filterConfig, // from injectIntl intl: intlShape.isRequired, diff --git a/src/containers/SearchPage/MainPanel.js b/src/containers/SearchPage/MainPanel.js index 4b4f79ce..bd985270 100644 --- a/src/containers/SearchPage/MainPanel.js +++ b/src/containers/SearchPage/MainPanel.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { array, bool, func, number, object, objectOf, shape, string } from 'prop-types'; +import { array, bool, func, number, object, objectOf, string } from 'prop-types'; import { FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import { merge } from 'lodash'; @@ -166,18 +166,8 @@ MainPanel.propTypes = { pagination: propTypes.pagination, searchParamsForPagination: object, showAsModalMaxWidth: number.isRequired, - primaryFilters: objectOf( - shape({ - paramName: string.isRequired, - options: array.isRequired, - }) - ), - secondaryFilters: objectOf( - shape({ - paramName: string.isRequired, - options: array.isRequired, - }) - ), + primaryFilters: objectOf(propTypes.filterConfig), + secondaryFilters: objectOf(propTypes.filterConfig), }; export default MainPanel; diff --git a/src/util/types.js b/src/util/types.js index a7de323d..68c48168 100644 --- a/src/util/types.js +++ b/src/util/types.js @@ -409,6 +409,17 @@ propTypes.pagination = shape({ totalPages: number.isRequired, }); +// Search filter definition +propTypes.filterConfig = shape({ + paramName: string.isRequired, + options: arrayOf( + shape({ + key: oneOfType([string, bool, number]).isRequired, + label: string.isRequired, + }) + ).isRequired, +}); + export const ERROR_CODE_TRANSACTION_LISTING_NOT_FOUND = 'transaction-listing-not-found'; export const ERROR_CODE_TRANSACTION_INVALID_TRANSITION = 'transaction-invalid-transition'; export const ERROR_CODE_TRANSACTION_ALREADY_REVIEWED_BY_CUSTOMER =