mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 14:35:45 +01:00
Implemented login & added tests
This commit is contained in:
@@ -2,15 +2,22 @@ import React, { Component } from "react";
|
||||
import Navigation from "./Navigation";
|
||||
import Main from "./Main";
|
||||
import Login from "./Login";
|
||||
import { getIsAuthenticated } from "../modules/login";
|
||||
import { connect } from "react-redux";
|
||||
import { withRouter } from "react-router-dom";
|
||||
|
||||
type Props = {
|
||||
login: boolean
|
||||
login: boolean,
|
||||
username: string,
|
||||
getAuthState: any
|
||||
};
|
||||
|
||||
class App extends Component {
|
||||
componentWillMount() {
|
||||
this.props.getAuthState();
|
||||
}
|
||||
render() {
|
||||
const { login } = this.props;
|
||||
const { login, username } = this.props.login;
|
||||
|
||||
if (!login) {
|
||||
return (
|
||||
@@ -21,6 +28,7 @@ class App extends Component {
|
||||
} else {
|
||||
return (
|
||||
<div className="App">
|
||||
<h2>Welcome, {username}!</h2>
|
||||
<Navigation />
|
||||
<Main />
|
||||
</div>
|
||||
@@ -29,4 +37,19 @@ class App extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export default withRouter(App);
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
getAuthState: () => dispatch(getIsAuthenticated())
|
||||
};
|
||||
};
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return { login: state.login };
|
||||
};
|
||||
|
||||
export default withRouter(
|
||||
connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(App)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user