Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Commit

Permalink
show By State ads in filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy B. Merrill committed Oct 16, 2018
1 parent 55d21ef commit 7e06414
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 7 additions & 3 deletions backend/server/public/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,13 @@ export const getAdsByState = (url = `${URL_ROOT}/fbpac-api/ads/by_state`) => {
let state = getState();

let params = new URLSearchParams();
url = `${URL_ROOT}/fbpac-api/ads/by_state`;

if (state.pagination && state.pagination.page) {
params.set("page", state.pagination.page);
}

let query = params.toString().length > 0 ? `?${params.toString()}` : "";
let new_url = `${location.pathname}${query}`;
let new_url = `${"/facebook-ads/admin/by_state/" + state.by_state}${query}`;
if (location.search !== query) {
// this history.push is just for when the state got changed via dropdowns/searches
// and then we got ads back
Expand Down Expand Up @@ -414,7 +413,12 @@ export const getAds = (url = `${URL_ROOT}/fbpac-api/ads`) => {
let path = `${url}?${params.toString()}`;

let query = params.toString().length > 0 ? `?${params.toString()}` : "";
let new_url = `${location.pathname}${query}`;
let new_url = `${
/* in admin, fix the URL if we've gotten somewhere weird */
location.pathname.indexOf("/admin/")
? "/facebook-ads/admin/"
: location.pathname
}${query}`;
if (location.search !== query) {
// this history.push is just for when the state got changed via dropdowns/searches
// and then we got ads back
Expand Down
11 changes: 9 additions & 2 deletions backend/server/public/src/components/admin/ads.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ export class AdsUnconnected extends React.Component {
</strong>
</span>
) : null}
{this.props.by_state ? (
<span>
State Ads: <strong>{this.props.by_state} </strong>
</span>
) : null}
<a href="#" onClick={this.props.clearAllFilters}>
Clear All
</a>
Expand Down Expand Up @@ -190,7 +195,8 @@ export const AdsUnrouted = connect(
entities,
advertisers,
no_listfund,
yougov_only
yougov_only,
by_state
}) => ({
ads: ads.filter(ad => !ad.suppressed),
search,
Expand All @@ -204,7 +210,8 @@ export const AdsUnrouted = connect(
entities: (entities || []).filter(it => it.active),
advertisers: (advertisers || []).filter(it => it.active),
no_listfund,
yougov_only
yougov_only,
by_state
}),
dispatch => ({
deserialize: () => {
Expand Down

0 comments on commit 7e06414

Please sign in to comment.