diff --git a/src/client/containers/MapApp.js b/src/client/containers/MapApp.js index 7c987fb60f40286c480c243c7ebc63f61b2fc3c3..3bc292a8dc24b42c4efb40b9124792638d129fa3 100644 --- a/src/client/containers/MapApp.js +++ b/src/client/containers/MapApp.js @@ -23,7 +23,10 @@ import ExpansionPanel from '@material-ui/core/ExpansionPanel'; import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary'; import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; -import { getVisibleResults } from '../selectors'; +import { + getVisibleResults, + getVisibleValues +} from '../selectors'; import { updateQuery, @@ -133,7 +136,7 @@ let MapApp = (props) => { const { classes, error, theme, drawerIsOpen, mapReady } = props; const anchor = 'left'; - //console.log(props.results); + console.log(props.resultValues); let resultsView = ''; if (props.results.length > 0) { @@ -265,6 +268,7 @@ let MapApp = (props) => { const mapStateToProps = (state) => ({ search: state.search, results: getVisibleResults(state), + resultValues: getVisibleValues(state), drawerIsOpen: state.options.drawerIsOpen, mapReady: state.options.mapReady, error: state.error, @@ -309,6 +313,7 @@ MapApp.propTypes = { updateResultFormat: PropTypes.func.isRequired, resultFormat: PropTypes.string.isRequired, results: PropTypes.array, + resultValues: PropTypes.object }; MapApp = connect( diff --git a/src/client/selectors/index.js b/src/client/selectors/index.js index f45def96c8cd0e32f786bbe6882dcc12b059b156..1420c1a1df38726d959a76d9ccb3234f8d5d37e2 100644 --- a/src/client/selectors/index.js +++ b/src/client/selectors/index.js @@ -16,3 +16,22 @@ export const getVisibleResults = createSelector( } } ); + +export const getVisibleValues = createSelector( + [ getVisibleResults ], + (visibleResults) => { + let typeLabels = []; + let broaderAreaLabels = []; + let sources = []; + for (const result of visibleResults) { + typeLabels.push(result.typeLabel); + broaderAreaLabels.push(result.broaderAreaLabel); + sources.push(result.source); + } + return { + typeLabels: Array.from(new Set(typeLabels)), + broaderAreaLabels: Array.from(new Set(broaderAreaLabels)), + sources: Array.from(new Set(sources)), + }; + } +);