Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
fixup rename searchTerm -> filterText
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Innes committed Mar 4, 2019
1 parent 5c02862 commit 42bbd93
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/app/src/actions/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const makeSidebarGuideTabActive = createAction('MAKE_SIDEBAR_GUIDE_TAB_AC
export const makeSidebarSearchTabActive = createAction('MAKE_SIDEBAR_SEARCH_TAB_ACTIVE');
export const makeSidebarFacilitiesTabActive = createAction('MAKE_SIDEBAR_FACILITIES_TAB_ACTIVE');

export const updateSidebarFacilitiesTabSearch =
createAction('UPDATE_SIDEBAR_FACILITIES_TAB_TEXT_SEARCH');
export const resetSidebarFacilitiesTabSearch =
createAction('RESET_SIDEBAR_FACILITIES_TAB_TEXT_SEARCH');
export const updateSidebarFacilitiesTabTextFilter =
createAction('UPDATE_SIDEBAR_FACILITIES_TAB_TEXT_FILTER');
export const resetSidebarFacilitiesTabTextFilter =
createAction('RESET_SIDEBAR_FACILITIES_TAB_TEXT_FILTER');
29 changes: 15 additions & 14 deletions src/app/src/components/FilterSidebarFacilitiesTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ControlledTextInput from './ControlledTextInput';

import {
makeSidebarSearchTabActive,
updateSidebarFacilitiesTabSearch,
updateSidebarFacilitiesTabTextFilter,
} from '../actions/ui';

import { facilityCollectionPropType } from '../util/propTypes';
Expand Down Expand Up @@ -107,8 +107,8 @@ function FilterSidebarFacilitiesTab({
data,
error,
returnToSearchTab,
searchTerm,
updateSearchTerm,
filterText,
updateFilterText,
}) {
if (fetching) {
return (
Expand Down Expand Up @@ -189,17 +189,17 @@ function FilterSidebarFacilitiesTab({
);
}

const filteredFacilities = searchTerm
const filteredFacilities = filterText
? facilities
.filter(({
properties: {
address,
name,
country_name: countryName,
},
}) => caseInsensitiveIncludes(address, searchTerm)
|| caseInsensitiveIncludes(name, searchTerm)
|| caseInsensitiveIncludes(countryName, searchTerm))
}) => caseInsensitiveIncludes(address, filterText)
|| caseInsensitiveIncludes(name, filterText)
|| caseInsensitiveIncludes(countryName, filterText))
: facilities;

const orderedFacilities =
Expand Down Expand Up @@ -233,8 +233,8 @@ function FilterSidebarFacilitiesTab({
</label>
<ControlledTextInput
id={SEARCH_TERM_INPUT}
value={searchTerm}
onChange={updateSearchTerm}
value={filterText}
onChange={updateFilterText}
placeholder="Search name, address, or country"
/>
</div>
Expand Down Expand Up @@ -292,8 +292,8 @@ FilterSidebarFacilitiesTab.propTypes = {
fetching: bool.isRequired,
error: arrayOf(string),
returnToSearchTab: func.isRequired,
searchTerm: string.isRequired,
updateSearchTerm: func.isRequired,
filterText: string.isRequired,
updateFilterText: func.isRequired,
};

function mapStateToProps({
Expand All @@ -306,22 +306,23 @@ function mapStateToProps({
},
ui: {
facilitiesSidebarTabSearch: {
searchTerm,
filterText,
},
},
}) {
return {
data,
error,
fetching,
searchTerm,
filterText,
};
}

function mapDispatchToProps(dispatch) {
return {
returnToSearchTab: () => dispatch(makeSidebarSearchTabActive()),
updateSearchTerm: e => dispatch((updateSidebarFacilitiesTabSearch(getValueFromEvent(e)))),
updateFilterText: e =>
dispatch((updateSidebarFacilitiesTabTextFilter(getValueFromEvent(e)))),
};
}

Expand Down
16 changes: 8 additions & 8 deletions src/app/src/reducers/UIReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
makeSidebarGuideTabActive,
makeSidebarSearchTabActive,
makeSidebarFacilitiesTabActive,
updateSidebarFacilitiesTabSearch,
resetSidebarFacilitiesTabSearch,
updateSidebarFacilitiesTabTextFilter,
resetSidebarFacilitiesTabTextFilter,
} from '../actions/ui';

import { completeFetchFacilities } from '../actions/facilities';
Expand All @@ -16,7 +16,7 @@ import { filterSidebarTabsEnum } from '../util/constants';
const initialState = Object.freeze({
activeFilterSidebarTab: filterSidebarTabsEnum.search,
facilitiesSidebarTabSearch: Object.freeze({
searchTerm: '',
filterText: '',
}),
});

Expand Down Expand Up @@ -51,17 +51,17 @@ export default createReducer({
},
},
}),
[updateSidebarFacilitiesTabSearch]: (state, payload) => update(state, {
[updateSidebarFacilitiesTabTextFilter]: (state, payload) => update(state, {
facilitiesSidebarTabSearch: {
searchTerm: {
filterText: {
$set: payload,
},
},
}),
[resetSidebarFacilitiesTabSearch]: state => update(state, {
[resetSidebarFacilitiesTabTextFilter]: state => update(state, {
facilitiesSidebarTabSearch: {
searchTerm: {
$set: initialState.facilitiesSidebarTabSearch.searchTerm,
filterText: {
$set: initialState.facilitiesSidebarTabSearch.filterText,
},
},
}),
Expand Down

0 comments on commit 42bbd93

Please sign in to comment.