| author | ymh <ymh.work@gmail.com> |
| Tue, 06 Nov 2018 16:19:26 +0100 | |
| changeset 170 | 7da1d5137b0b |
| parent 168 | ea92f4fe783d |
| child 191 | 3f71ad81a5a9 |
| 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'; |
|
168
ea92f4fe783d
- move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
151
diff
changeset
|
8 |
import { getCurrentUser } from '../selectors/authSelectors'; |
| 53 | 9 |
|
10 |
class Settings extends Component { |
|
11 |
||
|
168
ea92f4fe783d
- move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
151
diff
changeset
|
12 |
updateSettings = (e) => { |
|
ea92f4fe783d
- move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
151
diff
changeset
|
13 |
e.preventDefault(); |
| 53 | 14 |
const username = this.props.currentUser.username; |
15 |
const firstname = this.firstname.value; |
|
16 |
const lastname = this.lastname.value; |
|
17 |
||
18 |
this.props.userActions.updateSettings(username, firstname, lastname); |
|
19 |
} |
|
20 |
||
21 |
render() { |
|
22 |
||
23 |
const firstname = this.props.currentUser ? this.props.currentUser.first_name : ''; |
|
24 |
const lastname = this.props.currentUser ? this.props.currentUser.last_name : ''; |
|
25 |
||
26 |
return ( |
|
27 |
<div> |
|
28 |
<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
|
29 |
<div className="container-fluid"> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
30 |
<div className="row"> |
| 151 | 31 |
<div className="col-lg-6 offset-md-3"> |
| 53 | 32 |
<form> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
33 |
<div className="form-group"> |
| 151 | 34 |
<label className="col-form-label text-primary">Prénom</label> |
|
170
7da1d5137b0b
Upgrade dependencies and correct theme colors
ymh <ymh.work@gmail.com>
parents:
168
diff
changeset
|
35 |
<input className="form-control bg-irinotes-form text-muted" |
| 53 | 36 |
name="firstname" |
37 |
defaultValue={ firstname } |
|
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
38 |
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
|
39 |
ref={(firstname) => { this.firstname = firstname; }} |
| 53 | 40 |
/> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
41 |
</div> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
42 |
<div className="form-group"> |
| 151 | 43 |
<label className="col-form-label text-primary">Nom</label> |
|
170
7da1d5137b0b
Upgrade dependencies and correct theme colors
ymh <ymh.work@gmail.com>
parents:
168
diff
changeset
|
44 |
<input className="form-control bg-irinotes-form text-muted" |
| 53 | 45 |
name="lastname" |
46 |
defaultValue={ lastname } |
|
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
47 |
placeholder="Entrez un nom" |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
48 |
ref={(lastname) => { this.lastname = lastname; }} |
| 53 | 49 |
/> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
50 |
</div> |
| 53 | 51 |
</form> |
| 151 | 52 |
<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
|
53 |
</div> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
54 |
</div> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
142
diff
changeset
|
55 |
</div> |
| 53 | 56 |
</div> |
57 |
); |
|
58 |
} |
|
59 |
} |
|
60 |
||
61 |
function mapStateToProps(state, props) { |
|
62 |
return { |
|
|
168
ea92f4fe783d
- move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
151
diff
changeset
|
63 |
currentUser: getCurrentUser(state), |
| 53 | 64 |
}; |
65 |
} |
|
66 |
||
67 |
function mapDispatchToProps(dispatch) { |
|
68 |
return { |
|
69 |
userActions: bindActionCreators(userActions, dispatch) |
|
70 |
} |
|
71 |
} |
|
72 |
||
73 |
export default connect(mapStateToProps, mapDispatchToProps)(Settings); |