This repository has been archived by the owner on Jan 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
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 #26 from cfpb/agg
Sets up aggregate and disclosure flows
- Loading branch information
Showing
21 changed files
with
1,002 additions
and
345 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
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,119 @@ | ||
import React from 'react' | ||
import Header from '../common/Header.jsx' | ||
|
||
const MSAMDS = [ | ||
{ id: '25420', name: 'Harrisburg-Carlisle, PA' }, | ||
{ id: '25180', name: 'Hagerstown-Martinsburg, MD-WV' }, | ||
{ id: '25060', name: 'Gulfport-Biloxi, MS' }, | ||
{ id: '25020', name: 'Guayama, PR' }, | ||
{ id: '24860', name: 'Greenville, SC' }, | ||
{ id: '24780', name: 'Greenville, NC' }, | ||
{ id: '25500', name: 'Harrisonburg, VA' }, | ||
{ id: '25540', name: 'Hartford-West Hartford-East Hartford, CT' }, | ||
{ id: '25620', name: 'Hattiesburg, MS' }, | ||
{ id: '25860', name: 'Hickory-Lenoir-Morganton, NC' }, | ||
{ id: '25980', name: 'Hinesville-Fort Stewart, GA' }, | ||
{ id: '26100', name: 'Holland-Grand Haven, MI' }, | ||
{ id: '26180', name: 'Honolulu, HI' }, | ||
{ id: '26300', name: 'Hot Springs, AR' }, | ||
{ id: '26380', name: 'Houma-Bayou Cane-Thibodaux, LA' } | ||
] | ||
|
||
class MsaMds extends React.Component { | ||
constructor(props) { | ||
super(props) | ||
|
||
this.state = { | ||
error: null, | ||
isLoaded: false, | ||
msamds: [], | ||
selectValue: '' | ||
} | ||
|
||
this.handleChange = this.handleChange.bind(this) | ||
this.handleSubmit = this.handleSubmit.bind(this) | ||
} | ||
|
||
componentDidMount() { | ||
// TODO: load either MSA/MDs for an institution or for a state | ||
let fetchURL = '' | ||
if (this.props.match.params.institutionId) | ||
fetchURL = `https://ffiec-api.cfpb.gov/public/filers/${ | ||
this.props.match.params.institutionId | ||
}/msamds` | ||
if (this.props.match.params.stateId) | ||
fetchURL = `https://ffiec-api.cfpb.gov/public/msamds?state=${ | ||
this.props.match.params.stateId | ||
}` | ||
|
||
this.setState({ msamds: MSAMDS, isLoaded: true, selectValue: MSAMDS[0].id }) | ||
/* | ||
fetch(fetchURL) | ||
.then(res => res.json()) | ||
.then( | ||
result => { | ||
this.setState({ | ||
isLoaded: true, | ||
msamds: result.msamds | ||
}) | ||
}, | ||
error => { | ||
this.setState({ | ||
isLoaded: true, | ||
error | ||
}) | ||
} | ||
)*/ | ||
} | ||
|
||
handleChange(event) { | ||
this.setState({ selectValue: event.target.value }) | ||
} | ||
|
||
handleSubmit(event) { | ||
this.props.history.push({ | ||
pathname: `${this.props.match.url}/msa-md/${this.state.selectValue}` | ||
}) | ||
event.preventDefault() | ||
} | ||
|
||
render() { | ||
let msaMdsFor = '' | ||
if (this.props.match.params.institutionId) | ||
msaMdsFor = this.props.match.params.institutionId | ||
if (this.props.match.params.stateId) | ||
msaMdsFor = this.props.match.params.stateId | ||
|
||
return ( | ||
<div className="usa-grid msa-mds" id="main-content"> | ||
<Header | ||
type={1} | ||
headingText={`Choose an available MSA/MD for ${msaMdsFor}`} | ||
/> | ||
|
||
<form onSubmit={this.handleSubmit}> | ||
<label htmlFor="states">Select a MSA/MD</label> | ||
|
||
<select | ||
name="msamds" | ||
id="msamds" | ||
value={this.state.selectValue} | ||
onChange={this.handleChange} | ||
> | ||
{this.state.msamds.map((msamd, index) => { | ||
return ( | ||
<option key={index} value={msamd.id}> | ||
{msamd.id} - {msamd.name} | ||
</option> | ||
) | ||
})} | ||
</select> | ||
|
||
<input type="submit" value="Next - Find a Report" /> | ||
</form> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default MsaMds |
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,112 @@ | ||
import React from 'react' | ||
import Header from '../common/Header.jsx' | ||
import FiveDashOne from './disclosure/tables/FiveDashOne.jsx' | ||
|
||
class Report extends React.Component { | ||
constructor(props) { | ||
super(props) | ||
|
||
this.state = { | ||
error: null, | ||
isLoaded: false, | ||
report: null | ||
} | ||
} | ||
|
||
componentDidMount() { | ||
let fetchURL = 'https://s3.amazonaws.com/cfpb-hmda-public/prod/reports' | ||
if (this.props.match.params.institutionId) | ||
fetchURL = `${fetchURL}/disclosure` | ||
if (this.props.match.params.stateId) fetchURL = `${fetchURL}/aggregate` | ||
|
||
fetchURL = `${fetchURL}/2017/${this.props.match.params.msaMdId}/${ | ||
this.props.match.params.reportId | ||
}.txt` | ||
|
||
fetch(fetchURL) | ||
.then(res => res.json()) | ||
.then( | ||
result => { | ||
this.setState({ | ||
isLoaded: true, | ||
report: result | ||
}) | ||
}, | ||
error => { | ||
this.setState({ | ||
isLoaded: true, | ||
error | ||
}) | ||
} | ||
) | ||
} | ||
|
||
render() { | ||
if (this.state.error) { | ||
const { params } = this.props.match | ||
|
||
let alertHeading = 'Report not found' | ||
if (params.stateId) | ||
alertHeading = `Report ${params.reportId} for 2017 -> ${ | ||
params.stateId | ||
} -> ${params.msaMdId} not found` | ||
if (params.institutionId) | ||
alertHeading = `Report ${params.reportId} for 2017 -> ${ | ||
params.institutionId | ||
} -> ${params.msaMdId} not found` | ||
|
||
return ( | ||
<div | ||
className="usa-grid" | ||
id="main-content" | ||
style={{ marginTop: '3em' }} | ||
> | ||
<div className="usa-alert usa-alert-error" role="alert"> | ||
<div className="usa-alert-body"> | ||
<h3 className="usa-alert-heading">{alertHeading}</h3> | ||
<p className="usa-alert-text"> | ||
Sorry, we couldn't find that report. Try to refresh the page. If | ||
the problem persists please contact HMDA Help. | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
if (this.state.report === null) return null | ||
|
||
const report = this.state.report | ||
const headingText = report | ||
? `Table ${report.table}: ${report.description}, ${report.year}` | ||
: null | ||
return ( | ||
<div className="report" id="main-content"> | ||
<Header type={4} headingText={headingText}> | ||
<React.Fragment> | ||
<p style={{ width: '50%', display: 'inline-block' }}> | ||
Institution: {report.respondentId} - {report.institutionName} | ||
</p> | ||
<p | ||
style={{ | ||
width: '50%', | ||
display: 'inline-block', | ||
textAlign: 'right' | ||
}} | ||
> | ||
MSA/MD: {report.msa.id} - {report.msa.name} | ||
</p> | ||
</React.Fragment> | ||
</Header> | ||
|
||
<FiveDashOne report={report} /> | ||
|
||
<p className="usa-text-small report-date"> | ||
Report date: {report.reportDate} | ||
</p> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default Report |
Oops, something went wrong.