Newer
Older
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu';
import VirtualizedTable from '../components/VirtualizedTable';
import LeafletMap from '../components/map/LeafletMap';
import {
getVisibleResults,
getVisibleValues
} from '../selectors';
import {
updateQuery,
fetchSuggestions,
clearSuggestions,
fetchResults,
} from '../actions';
const styles = theme => ({
root: {
flexGrow: 1,
height: '100%',
},
},
menuButton: {
marginRight: 20,
},
mainContainer: {
marginTop: 64,
height: 'calc(100% - 64px)'
});
let MapApp = (props) => {
return (
<div className={classes.root}>
<div className={classes.appFrame}>
<AppBar position="absolute">
<Toolbar>
<IconButton className={classes.menuButton} color="inherit" aria-label="Menu">
<MenuIcon />
</IconButton>
<Typography variant="title" color="inherit" className={classes.flex}>
</Typography>
</Toolbar>
</AppBar>
<Grid container className={classes.mainContainer}>
<VirtualizedTable
list={Immutable.List(props.results)}
resultValues={props.resultValues}
search={props.search}
sortResults={props.sortResults}
toggleDataset={props.toggleDataset}
updateResultsFilter={props.updateResultsFilter}
updateQuery={props.updateQuery}
fetchResults={props.fetchResults}
clearResults={props.clearResults}
fetchSuggestions={props.fetchSuggestions}
clearSuggestions={props.clearSuggestions}
updateResultFormat={props.updateResultFormat}
analysisView={props.analysisView}
/>
<LeafletMap
sliderValue={100}
results={props.results}
geoJSON={props.geoJSON}
geoJSONKey={props.geoJSONKey}
getGeoJSON={props.getGeoJSON}
analysisView={props.analysisView}
<Pie data={props.results} groupBy={props.search.groupBy} query={props.search.query} />
</div>
</div>
);
};
const mapStateToProps = (state) => {
return {
search: state.search,
results: getVisibleResults(state.search),
resultValues: getVisibleValues(state.search),
error: state.error,
geoJSON: state.map.geoJSON,
geoJSONKey: state.map.geoJSONKey,
resultFormat: state.options.resultFormat
};
};
const mapDispatchToProps = ({
fetchSuggestions,
clearSuggestions,
fetchResults,
updateResultFormat,
updateResultsFilter
});
MapApp.propTypes = {
classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
search: PropTypes.object.isRequired,
error: PropTypes.object.isRequired,
openAnalysisView: PropTypes.func.isRequired,
closeAnalysisView: PropTypes.func.isRequired,
updateQuery: PropTypes.func.isRequired,
fetchSuggestions: PropTypes.func.isRequired,
clearSuggestions: PropTypes.func.isRequired,
fetchResults: PropTypes.func.isRequired,
clearResults: PropTypes.func.isRequired,
updateResultFormat: PropTypes.func.isRequired,
resultFormat: PropTypes.string.isRequired,
results: PropTypes.array,
resultValues: PropTypes.object,
updateResultsFilter: PropTypes.func.isRequired
};
MapApp = connect(
mapStateToProps,
mapDispatchToProps
)(withStyles(styles, {withTheme: true})(MapApp));
export default MapApp;