--- a/client/src/components/Login.js Thu Jun 15 17:18:22 2017 +0200
+++ b/client/src/components/Login.js Fri Jun 16 18:36:39 2017 +0200
@@ -1,10 +1,10 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
-import { Grid, Row, Col, Panel, FormGroup, ControlLabel, FormControl, Button } from 'react-bootstrap';
+import { Grid, Row, Col, Panel, FormGroup, ControlLabel, FormControl, Button, Alert } from 'react-bootstrap';
import '../App.css';
import Navbar from './Navbar';
-import * as sessionsActions from '../actions/sessionsActions';
+import * as authActions from '../actions/authActions';
class Login extends Component {
@@ -12,8 +12,13 @@
const username = this.username.value;
const password = this.password.value;
- console.log(username, password);
+ this.props.authActions.loginSubmit(username, password);
+ }
+ renderError() {
+ return (
+ <Alert bsStyle="danger">Bad credentials</Alert>
+ )
}
render() {
@@ -33,6 +38,7 @@
<ControlLabel>Password</ControlLabel>
<FormControl componentClass="input" type="password" inputRef={ref => { this.password = ref; }} />
</FormGroup>
+ { this.props.login.error && this.renderError() }
<Button block bsStyle="primary" onClick={this.login}>Login</Button>
</form>
</Panel>
@@ -46,14 +52,14 @@
function mapStateToProps(state, props) {
return {
- currentSession: state.get('currentSession'),
- sessions: state.get('sessions')
+ currentUser: state.get('currentUser'),
+ login: state.get('login')
};
}
function mapDispatchToProps(dispatch) {
return {
- actions: bindActionCreators(sessionsActions, dispatch)
+ authActions: bindActionCreators(authActions, dispatch)
}
}