-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #745 from 18F/bjs-get-agency-info
incorporate more agency info to explorer page
- Loading branch information
Showing
17 changed files
with
213 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { AGENCY_FETCHING, AGENCY_RECEIVED } from './constants' | ||
import api from '../util/api' | ||
|
||
export const fetchingAgency = () => ({ | ||
type: AGENCY_FETCHING, | ||
}) | ||
|
||
export const receivedAgency = agency => ({ | ||
type: AGENCY_RECEIVED, | ||
agency, | ||
}) | ||
|
||
export const fetchAgency = params => dispatch => { | ||
dispatch(fetchingAgency()) | ||
|
||
return api.getAgency(params.place).then(data => { | ||
dispatch(receivedAgency(data)) | ||
}) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import startCase from 'lodash.startcase' | ||
import React from 'react' | ||
|
||
const getTitle = ({ agency, crime, place, placeType }) => { | ||
const info = agency[place] | ||
|
||
if (placeType !== 'agency') return `${startCase(place)}, ${startCase(crime)}` | ||
if (agency.loading || !info) return 'Agency loading...' | ||
return `${info.agency_name} Police Department, ${startCase(crime)}` | ||
} | ||
|
||
const ExplorerHeader = params => ( | ||
<div className="items-baseline my4 border-bottom border-blue-lighter"> | ||
<h1 className="flex-auto mt0 mb1 fs-22 sm-fs-32">{getTitle(params)}</h1> | ||
</div> | ||
) | ||
|
||
export default ExplorerHeader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react' | ||
|
||
import { nationalKey } from '../util/usa' | ||
|
||
const Sparklines = ({ place, summaries }) => { | ||
const { data, loading } = summaries | ||
const state = place.slice(0, 2) | ||
|
||
if (loading || !data) return null | ||
|
||
return ( | ||
<div className="mb4"> | ||
<h3>State and national crime rates</h3> | ||
<div className="clearfix mxn1 fs-10"> | ||
<div className="sm-col sm-col-6 px1"> | ||
<div className="p2 bg-white"> | ||
<pre>{JSON.stringify(data[state], null, 2)}</pre> | ||
</div> | ||
</div> | ||
<div className="sm-col sm-col-6 px1"> | ||
<div className="p2 bg-white"> | ||
<pre>{JSON.stringify(data[nationalKey], null, 2)}</pre> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Sparklines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { AGENCY_FETCHING, AGENCY_RECEIVED } from '../actions/constants' | ||
|
||
const initialState = { | ||
loading: false, | ||
} | ||
|
||
export default (state = initialState, action) => { | ||
switch (action.type) { | ||
case AGENCY_FETCHING: | ||
return { | ||
...state, | ||
loading: true, | ||
} | ||
case AGENCY_RECEIVED: | ||
return { | ||
...state, | ||
...action.agency, | ||
loading: false, | ||
} | ||
default: | ||
return state | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.