diff -r 96f8a4a59bd9 -r d8588379529e client/src/components/Settings.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/components/Settings.js Mon Jun 19 17:56:41 2017 +0200 @@ -0,0 +1,71 @@ +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; +import { Grid, Row, Col, Button, FormGroup, ControlLabel, FormControl } from 'react-bootstrap'; +import '../App.css'; +import Navbar from './Navbar'; +import * as userActions from '../actions/userActions'; + +class Settings extends Component { + + updateSettings = () => { + const username = this.props.currentUser.username; + const firstname = this.firstname.value; + const lastname = this.lastname.value; + + this.props.userActions.updateSettings(username, firstname, lastname); + } + + render() { + + const firstname = this.props.currentUser ? this.props.currentUser.first_name : ''; + const lastname = this.props.currentUser ? this.props.currentUser.last_name : ''; + + return ( +
+ + + + +
+ + First name + { this.firstname = ref; } } + /> + + + Last name + { this.lastname = ref; } } + /> + +
+ + +
+
+
+ ); + } +} + +function mapStateToProps(state, props) { + return { + currentUser: state.get('currentUser'), + }; +} + +function mapDispatchToProps(dispatch) { + return { + userActions: bindActionCreators(userActions, dispatch) + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(Settings);