Skip to content

Commit

Permalink
Merge pull request #131 from GSA/130ClearAgencyFilter
Browse files Browse the repository at this point in the history
fixed issue #130, so people can select from browse by agency multiple time
  • Loading branch information
saracope authored Feb 27, 2019
2 parents 5ad3006 + 0249896 commit 298fdcc
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/components/home-banner/home-banner.container.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { connect } from 'react-redux';
import { push } from 'connected-react-router'
import { getConfigValue, normalize } from 'utils/other'
import { getConfigValue, normalize, now } from 'utils/other'
import saveAgencies from 'actions/save-agencies'
import updateBrowseFilters from 'actions/update-browse-filters'
import updateBrowseParams from 'actions/update-browse-params'
import HomeBannerComponent from './home-banner.component'

const mapStateToProps = ({ agencies }) => {
Expand All @@ -24,11 +24,22 @@ const mapDispatchToProps = dispatch => {
onBrowseByEntityChange: event => {
const value = normalize(event.target.value)
if (value !== 'browse by agency') {
let url = '/browse-projects'
if (value !== 'all') {
url += '?agencies=' + value
dispatch(updateBrowseFilters('agencies', value, 'checked'))
let url
const params = {
page: 1,
size: 10,
sort: 'data_quality',
filters: []
}
if (value === 'all') {
url = '/browse-projects?page=1&size=10&sort=data_quality'
} else {
url =`/browse-projects?agencies=${value}&page=1&size=10&sort=data_quality`
params.filters.push({ category: 'agencies', value, modified: now() })
}
// we can't use updateBrowseFilters because of
// https://github.com/GSA/code-gov-front-end/issues/130
dispatch(updateBrowseParams(params))
dispatch(push(url))
}
},
Expand Down

0 comments on commit 298fdcc

Please sign in to comment.