1
1
import React , { Component } from 'react'
2
2
import { Link } from 'react-router-dom'
3
+ import { isEqual } from 'lodash'
3
4
import { getItemCSV , getSubsetCSV , getSubsetDetails } from '../api.js'
4
5
import Header from '../common/Header.jsx'
5
- // import LEI_COUNTS from '../constants/leiCounts.js'
6
6
import MSAMD_COUNTS from '../constants/msamdCounts.js'
7
7
import STATE_COUNTS from '../constants/stateCounts.js'
8
8
import { makeSearchFromState , makeStateFromSearch } from '../query.js'
@@ -12,7 +12,6 @@ import './Geography.css'
12
12
import InstitutionSelect from './InstitutionSelect'
13
13
import ItemSelect from './ItemSelect.jsx'
14
14
import { fetchLeis , filterLeis } from './leiUtils'
15
- import { isEqual } from 'lodash'
16
15
import {
17
16
createItemOptions ,
18
17
createVariableOptions ,
@@ -63,7 +62,7 @@ class Geography extends Component {
63
62
leiDetails : {
64
63
loading : true ,
65
64
counts : { } ,
66
- leis : [ ]
65
+ leis : { }
67
66
}
68
67
}
69
68
@@ -76,9 +75,7 @@ class Geography extends Component {
76
75
componentDidMount ( ) {
77
76
this . fetchLeis ( )
78
77
this . filterLeis ( )
79
- this . setState ( {
80
- isLargeFile : this . checkIfLargeFile ( this . state . category , this . state . items )
81
- } )
78
+ this . setState ( { isLargeFile : this . checkIfLargeFile ( this . state . category , this . state . items ) } )
82
79
}
83
80
84
81
componentDidUpdate ( prevProps , prevState ) {
@@ -88,9 +85,7 @@ class Geography extends Component {
88
85
if ( geographyChanged ) this . fetchLeis ( )
89
86
if ( geographyChanged || leisReloaded ) this . filterLeis ( )
90
87
if ( leisReloaded )
91
- this . setState ( {
92
- isLargeFile : this . checkIfLargeFile ( this . state . category , this . state . items )
93
- } )
88
+ this . setState ( { isLargeFile : this . checkIfLargeFile ( this . state . category , this . state . items ) } )
94
89
}
95
90
96
91
updateSearch ( ) {
@@ -167,8 +162,7 @@ class Geography extends Component {
167
162
checkIfLargeCount ( selected , countMap ) {
168
163
const MAX = 1048576
169
164
if ( ! selected ) return countMap > MAX
170
- const count = selected . reduce ( ( acc , curr ) => acc + countMap [ curr ] , 0 )
171
- return count > MAX
165
+ return selected . reduce ( ( acc , curr ) => acc + countMap [ curr ] , 0 ) > MAX
172
166
}
173
167
174
168
onCategoryChange ( catObj ) {
@@ -268,7 +262,8 @@ class Geography extends Component {
268
262
}
269
263
270
264
render ( ) {
271
- const { category, items, leis, isLargeFile, variables, orderedVariables, details, loadingDetails, error } = this . state
265
+ const { category, details, error, isLargeFile, items, leiDetails, leis,
266
+ loadingDetails, orderedVariables, variables } = this . state
272
267
273
268
const nationwide = isNationwide ( category )
274
269
const enabled = nationwide || items . length
@@ -309,10 +304,7 @@ class Geography extends Component {
309
304
< InstitutionSelect
310
305
items = { leis }
311
306
onChange = { this . onInstitutionChange }
312
- options = { this . itemOptions }
313
- geoCategory = { category }
314
- geoItems = { items }
315
- leiDetails = { this . state . leiDetails }
307
+ leiDetails = { leiDetails }
316
308
/>
317
309
< VariableSelect
318
310
options = { this . variableOptions }
0 commit comments