| author | salimr <riwad.salim@yahoo.fr> |
| Mon, 08 Oct 2018 04:09:19 +0200 | |
| changeset 161 | a642639dbc07 |
| parent 151 | 57d63a248f0d |
| child 168 | ea92f4fe783d |
| permissions | -rw-r--r-- |
| 53 | 1 |
import React, { Component } from 'react'; |
2 |
import { connect } from 'react-redux'; |
|
3 |
import { bindActionCreators } from 'redux'; |
|
4 |
import '../App.css'; |
|
5 |
import Navbar from './Navbar'; |
|
6 |
import * as userActions from '../actions/userActions'; |
|
| 151 | 7 |
import './Settings.css'; |
| 53 | 8 |
|
9 |
class Settings extends Component { |
|
10 |
||
11 |
updateSettings = () => { |
|
12 |
const username = this.props.currentUser.username; |
|
13 |
const firstname = this.firstname.value; |
|
14 |
const lastname = this.lastname.value; |
|
15 |
||
16 |
this.props.userActions.updateSettings(username, firstname, lastname); |
|
17 |
} |
|
18 |
||
19 |
render() { |
|
20 |
||
21 |
const firstname = this.props.currentUser ? this.props.currentUser.first_name : ''; |
|
22 |
const lastname = this.props.currentUser ? this.props.currentUser.last_name : ''; |
|
23 |
||
24 |
return ( |
|
25 |
<div> |
|
26 |
<Navbar history={this.props.history} /> |
|
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
27 |
<div className="container-fluid"> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
28 |
<div className="row"> |
| 151 | 29 |
<div className="col-lg-6 offset-md-3"> |
| 53 | 30 |
<form> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
31 |
<div className="form-group"> |
| 151 | 32 |
<label className="col-form-label text-primary">Prénom</label> |
33 |
<input className="form-control bg-danger text-muted" |
|
| 53 | 34 |
name="firstname" |
35 |
defaultValue={ firstname } |
|
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
36 |
placeholder="Entrez un prénom" |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
37 |
ref={(firstname) => { this.firstname = firstname; }} |
| 53 | 38 |
/> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
39 |
</div> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
40 |
<div className="form-group"> |
| 151 | 41 |
<label className="col-form-label text-primary">Nom</label> |
42 |
<input className="form-control bg-danger text-muted" |
|
| 53 | 43 |
name="lastname" |
44 |
defaultValue={ lastname } |
|
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
45 |
placeholder="Entrez un nom" |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
46 |
ref={(lastname) => { this.lastname = lastname; }} |
| 53 | 47 |
/> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
48 |
</div> |
| 53 | 49 |
</form> |
| 151 | 50 |
<button type="submit" className="btn btn-primary btn-lg text-secondary" onClick={this.updateSettings}>Enregistrer</button> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
51 |
</div> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
52 |
</div> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
53 |
</div> |
| 53 | 54 |
</div> |
55 |
); |
|
56 |
} |
|
57 |
} |
|
58 |
||
59 |
function mapStateToProps(state, props) { |
|
60 |
return { |
|
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
61 |
currentUser: state.getIn(['authStatus', 'currentUser']), |
| 53 | 62 |
}; |
63 |
} |
|
64 |
||
65 |
function mapDispatchToProps(dispatch) { |
|
66 |
return { |
|
67 |
userActions: bindActionCreators(userActions, dispatch) |
|
68 |
} |
|
69 |
} |
|
70 |
||
71 |
export default connect(mapStateToProps, mapDispatchToProps)(Settings); |