Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issue #130, so people can select from browse by agency multiple time #131

Merged
merged 2 commits into from
Feb 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let url = `/browse-projects?agencies=${value}&page=1&size=10&sort=data_quality`

const params = {
page: 1,
size: 10,
sort: 'data_quality',
filters: []
}
if (value === 'all') {
url = '/browse-projects?page=1&size=10&sort=data_quality'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url = url.split(`agencies=${value}&`).join('')

} 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