mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-27 19:42:11 +10:00
Change SelectSingleFilterMobile props
Pass initialValue instead of all query params.
This commit is contained in:
parent
31e85eab46
commit
01c8136d65
2 changed files with 9 additions and 9 deletions
|
|
@ -131,13 +131,15 @@ class SearchFiltersMobileComponent extends Component {
|
|||
const categoryLabel = intl.formatMessage({
|
||||
id: 'SearchFiltersMobile.categoryLabel',
|
||||
});
|
||||
const initialCategory = urlQueryParams[CATEGORY_URL_PARAM];
|
||||
|
||||
const categoryFilter = categories ? (
|
||||
<SelectSingleFilterMobile
|
||||
urlQueryParams={urlQueryParams}
|
||||
urlParam={CATEGORY_URL_PARAM}
|
||||
paramLabel={categoryLabel}
|
||||
onSelect={this.onSelectSingle}
|
||||
options={categories}
|
||||
initialValue={initialCategory}
|
||||
intl={intl}
|
||||
/>
|
||||
) : null;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { Component } from 'react';
|
||||
import { object, string, func, arrayOf, shape } from 'prop-types';
|
||||
import { string, func, arrayOf, shape } from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
|
|
@ -28,12 +28,9 @@ class SelectSingleFilterMobile extends Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { rootClassName, className, urlQueryParams, urlParam, paramLabel, options } = this.props;
|
||||
const { rootClassName, className, paramLabel, options, initialValue } = this.props;
|
||||
|
||||
// current value of this custom attribute filter
|
||||
const currentValue = urlQueryParams[urlParam];
|
||||
|
||||
const labelClass = currentValue ? css.filterLabelSelected : css.filterLabel;
|
||||
const labelClass = initialValue ? css.filterLabelSelected : css.filterLabel;
|
||||
|
||||
const optionsContainerClass = this.state.isOpen
|
||||
? css.optionsContainerOpen
|
||||
|
|
@ -54,7 +51,7 @@ class SelectSingleFilterMobile extends Component {
|
|||
<div className={optionsContainerClass}>
|
||||
{options.map(option => {
|
||||
// check if this option is selected
|
||||
const selected = currentValue === option.key;
|
||||
const selected = initialValue === option.key;
|
||||
// menu item border class
|
||||
const optionBorderClass = selected ? css.optionBorderSelected : css.optionBorder;
|
||||
return (
|
||||
|
|
@ -77,12 +74,12 @@ class SelectSingleFilterMobile extends Component {
|
|||
SelectSingleFilterMobile.defaultProps = {
|
||||
rootClassName: null,
|
||||
className: null,
|
||||
initialValue: null,
|
||||
};
|
||||
|
||||
SelectSingleFilterMobile.propTypes = {
|
||||
rootClassName: string,
|
||||
className: string,
|
||||
urlQueryParams: object.isRequired,
|
||||
urlParam: string.isRequired,
|
||||
paramLabel: string.isRequired,
|
||||
onSelect: func.isRequired,
|
||||
|
|
@ -93,6 +90,7 @@ SelectSingleFilterMobile.propTypes = {
|
|||
label: string.isRequired,
|
||||
})
|
||||
).isRequired,
|
||||
initialValue: string,
|
||||
};
|
||||
|
||||
export default SelectSingleFilterMobile;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue