Skip to content

Commit 15ef5d1

Browse files
author
Carolina Gonzalez
committed
changed default to cd
1 parent 96aae06 commit 15ef5d1

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

competitiveness/src/App.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppContainer extends Component {
1414
//do some checks so we're not calling backend 5 times a load
1515
static getDerivedStateFromProps(nextProps, prevState) {
1616

17-
let parentDistrictType = (typeof(nextProps.match.params.parentDistrictType) === 'undefined') ? 'AD' : nextProps.match.params.parentDistrictType
17+
let parentDistrictType = (typeof(nextProps.match.params.parentDistrictType) === 'undefined') ? 'CD' : nextProps.match.params.parentDistrictType
1818
let selectedDistrict = (typeof(nextProps.match.params.selectedDistrict) === 'undefined') ? 0 : nextProps.match.params.selectedDistrict
1919
let params = queryString.parse(nextProps.location.search)
2020
let election = params.election

competitiveness/src/components/ParentHeader.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const React = require('react');
55

66
const ParentHeaderContainer = withRouter(({districtType, changeDistrict, history}) => (
77
<h1>New York City Competitiveness - <Dropdown options={
8-
[{text: 'State Assembly District', value: 'AD'},
8+
[{text: 'Congressional District', value: 'CD'},
99
{text: 'State Senate District', value: 'SD'},
10-
{text: 'Congressional District', value: 'CD'},
10+
{text: 'State Assembly District', value: 'AD'},
1111
]}
1212
defaultValue={districtType}
1313
onChange={(e, d) => changeDistrict(e, d, history)}

competitiveness/src/components/edDetails/TopDetails.jsx

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { connect } from 'react-redux'
3-
import { Grid } from 'semantic-ui-react'
3+
import { Grid, Loader } from 'semantic-ui-react'
44

55
const toPercent = (val) => {
66
if (!val) {
@@ -24,8 +24,13 @@ const humanReadable = (el) => {
2424
// election should be dropdown with curr elec selected
2525
const TopDetailsContainer = ({election, margin, winningParty,
2626
mrTurnout, winningCandidate, totalPop,
27-
dbdo, pctRegistered}) => (
28-
<Grid>
27+
dbdo, pctRegistered, isLoading}) => {
28+
let content;
29+
if (isLoading) {
30+
content = <Loader active />
31+
}
32+
else {
33+
content = (
2934
<Grid.Row centered divided className='top-details'>
3035
<Grid.Column width={3} className='top-label'>
3136
<strong>{humanReadable(election)} winner:</strong> {winningCandidate} ({winningParty.split('').slice(0,3).join('')}) -- {margin}%
@@ -42,9 +47,14 @@ const TopDetailsContainer = ({election, margin, winningParty,
4247
<Grid.Column width={3} className='top-label'>
4348
<strong>Registered:</strong> {pctRegistered}
4449
</Grid.Column>
45-
</Grid.Row>
50+
</Grid.Row>)
51+
}
52+
return (
53+
<Grid>
54+
{ content }
4655
</Grid>
47-
)
56+
)
57+
}
4858

4959
const mapStateToProps = (state) => (
5060
{election: state.selectedElection,
@@ -54,7 +64,8 @@ const mapStateToProps = (state) => (
5464
mrTurnout: toPercent(state.highlightedEdData.turnout.turnout_17) || '',
5565
totalPop: state.highlightedEdData.edMetrics.total,
5666
dbdo: toPercent(1 - state.highlightedEdData.edMetrics[`dbdo_${state.selectedElection.toLowerCase()}`]) || '',
57-
pctRegistered: toPercent(state.highlightedEdData.edMetrics.registered_pct) || ''
67+
pctRegistered: toPercent(state.highlightedEdData.edMetrics.registered_pct) || '',
68+
isLoading: state.isLoading
5869
})
5970

6071
const TopDetails = connect(mapStateToProps)(TopDetailsContainer)

competitiveness/src/reducers/reducers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function sidebarDimensionsReducer(state=[200,200], action) {
3434
}
3535
}
3636

37-
export function districtTypeReducer(state='AD', action) {
37+
export function districtTypeReducer(state='CD', action) {
3838
switch (action.type) {
3939
case 'CHANGE_DISTRICT_TYPE':
4040
return action.payload.main

0 commit comments

Comments
 (0)