47 | {this.renderNavBar()}
48 |
Users
49 |
50 |
64 |
65 |
66 |
67 | );
68 | }
69 | }
70 |
71 | function mapStateToProps(state) {
72 | return {
73 | loggedIn : authSelectors.getLoginDetails(state).loggedIn,
74 | users : userSelectors.getUsers(state).users
75 | }
76 | }
77 |
78 | export default withRouter(connect(mapStateToProps)(Home));
79 |
--------------------------------------------------------------------------------
/src/main/frontend/src/components/Login.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import * as authSelectors from '../store/auth/reducer'
3 | import * as authActiokns from '../store/auth/actions'
4 | import { withRouter, Redirect } from "react-router";
5 | import connect from "react-redux/es/connect/connect";
6 | import './css/Login.css'
7 |
8 | class Login extends React.Component {
9 |
10 | constructor(props) {
11 | super(props);
12 | this.state = {
13 | username: '',
14 | password: '',
15 | submitted: false
16 | };
17 | this.usernameChange = this.usernameChange.bind(this);
18 | this.passwordChange = this.passwordChange.bind(this);
19 | this.handleSubmit = this.handleSubmit.bind(this);
20 | }
21 |
22 | usernameChange(event) {
23 | const { name, value } = event.target;
24 | this.setState( {username: value});
25 | this.setState( {submitted: false});
26 | }
27 |
28 | passwordChange(event) {
29 | const { name, value } = event.target;
30 | this.setState( {password: value});
31 | this.setState( {submitted: false});
32 | }
33 |
34 | handleSubmit(event) {
35 | event.preventDefault();
36 | this.setState( {submitted: true});
37 | const { username, password } = this.state;
38 | this.props.dispatch(authActiokns.authenticate(username, password));
39 | }
40 |
41 | render() {
42 | if (this.props.loggedIn === true) {
43 | return