mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-29 05:00:43 +10:00
Unify function naming
This commit is contained in:
parent
161a0268ab
commit
99ce1f9a01
3 changed files with 17 additions and 15 deletions
|
|
@ -48,20 +48,22 @@ const SearchFiltersComponent = props => {
|
|||
id: 'SearchFilters.featuresLabel',
|
||||
});
|
||||
|
||||
const initialFeatures =
|
||||
urlQueryParams[FEATURES_URL_PARAM] && urlQueryParams[FEATURES_URL_PARAM].split(',');
|
||||
const initialFeatures = !!urlQueryParams[FEATURES_URL_PARAM]
|
||||
? urlQueryParams[FEATURES_URL_PARAM].split(',')
|
||||
: [];
|
||||
|
||||
const initialCategory = urlQueryParams[CATEGORY_URL_PARAM];
|
||||
|
||||
const handleSelectOptions = (urlParam, options) => {
|
||||
const queryParams = options
|
||||
? { ...urlQueryParams, [FEATURES_URL_PARAM]: options.join(',') }
|
||||
: omit(urlQueryParams, FEATURES_URL_PARAM);
|
||||
const queryParams =
|
||||
options && options.length > 0
|
||||
? { ...urlQueryParams, [FEATURES_URL_PARAM]: options.join(',') }
|
||||
: omit(urlQueryParams, FEATURES_URL_PARAM);
|
||||
|
||||
history.push(createResourceLocatorString('SearchPage', routeConfiguration(), {}, queryParams));
|
||||
};
|
||||
|
||||
const onSelectOption = (urlParam, option) => {
|
||||
const handleSelectOption = (urlParam, option) => {
|
||||
// query parameters after selecting the option
|
||||
// if no option is passed, clear the selection for the filter
|
||||
const queryParams = option
|
||||
|
|
@ -75,7 +77,7 @@ const SearchFiltersComponent = props => {
|
|||
<SelectSingleFilter
|
||||
urlParam={CATEGORY_URL_PARAM}
|
||||
label={categoryLabel}
|
||||
onSelect={onSelectOption}
|
||||
onSelect={handleSelectOption}
|
||||
options={categories}
|
||||
initialValue={initialCategory}
|
||||
contentPlacementOffset={FILTER_OFFSET}
|
||||
|
|
@ -86,7 +88,7 @@ const SearchFiltersComponent = props => {
|
|||
<SelectMultipleFilter
|
||||
urlParam={FEATURES_URL_PARAM}
|
||||
label={featuresLabel}
|
||||
onSubmit={handleSelectOptions}
|
||||
onSelect={handleSelectOptions}
|
||||
options={features}
|
||||
initialValues={initialFeatures}
|
||||
contentPlacementOffset={FILTER_OFFSET}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ const AmenitiesFilterComponent = withRouter(props => {
|
|||
<SelectMultipleFilter
|
||||
urlParam={URL_PARAM}
|
||||
label="Amenities"
|
||||
onSubmit={(urlParam, values) => handleSubmit(urlParam, values, history)}
|
||||
onSelect={(urlParam, values) => handleSubmit(urlParam, values, history)}
|
||||
options={options}
|
||||
initialValues={initialValues}
|
||||
contentPlacementOffset={-14}
|
||||
|
|
|
|||
|
|
@ -48,21 +48,21 @@ class SelectMultipleFilter extends Component {
|
|||
}
|
||||
|
||||
handleSubmit(values) {
|
||||
const { onSubmit, urlParam } = this.props;
|
||||
const { onSelect, urlParam } = this.props;
|
||||
const selectedKeys = valuesToKeys(values);
|
||||
this.setState({ isOpen: false });
|
||||
onSubmit(urlParam, selectedKeys);
|
||||
onSelect(urlParam, selectedKeys);
|
||||
}
|
||||
|
||||
handleClear() {
|
||||
this.setState({ isOpen: false });
|
||||
this.props.onSubmit(null);
|
||||
this.props.onSelect(null);
|
||||
}
|
||||
|
||||
handleCancel() {
|
||||
const { onSubmit, initialValues, urlParam } = this.props;
|
||||
const { onSelect, initialValues, urlParam } = this.props;
|
||||
this.setState({ isOpen: false });
|
||||
onSubmit(urlParam, initialValues);
|
||||
onSelect(urlParam, initialValues);
|
||||
}
|
||||
|
||||
handleBlur(event) {
|
||||
|
|
@ -170,7 +170,7 @@ SelectMultipleFilter.propTypes = {
|
|||
className: string,
|
||||
urlParam: string.isRequired,
|
||||
label: string.isRequired,
|
||||
onSubmit: func.isRequired,
|
||||
onSelect: func.isRequired,
|
||||
options: array.isRequired,
|
||||
initialValues: arrayOf(string),
|
||||
contentPlacementOffset: number,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue