summaryrefslogtreecommitdiff
path: root/src/pages/App.js
blob: a2a1050b2e7458c3d0035950b0b19e55495eb0b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import PropTypes from "prop-types";
import React from 'react';
import {connect} from "react-redux";
import {openSimulationSucceeded} from "../actions/simulations";
import {fetchAuthorizationsOfCurrentUser} from "../actions/users";
import MapStage from "../components/map/MapStage";
import Navbar from "../components/navigation/Navbar";
import Login from "../containers/auth/Login";

class AppContainer extends React.Component {
    static propTypes = {
        simulationId: PropTypes.number.isRequired,
    };

    componentDidMount() {
        this.props.storeSimulationId(this.props.simulationId);
        this.props.fetchAuthorizationsOfCurrentUser();
    }

    render() {
        return (
            <div className="full-height">
                <Navbar/>
                <div className="full-height">
                    <MapStage/>
                </div>
                <Login visible={false}/>
            </div>
        );
    }
}

const mapDispatchToProps = dispatch => {
    return {
        storeSimulationId: id => dispatch(openSimulationSucceeded(id)),
        fetchAuthorizationsOfCurrentUser: () => dispatch(fetchAuthorizationsOfCurrentUser()),
    };
};

const App = connect(
    undefined,
    mapDispatchToProps
)(AppContainer);

export default App;