| author | ymh <ymh.work@gmail.com> |
| Thu, 29 Jul 2021 19:04:01 +0200 | |
| changeset 209 | a01e6a4dc9d2 |
| parent 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 Navbar from './Navbar'; |
|
5 |
import * as userActions from '../actions/userActions'; |
|
|
168
ea92f4fe783d
- move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
151
diff
changeset
|
6 |
import { getCurrentUser } from '../selectors/authSelectors'; |
| 53 | 7 |
|
8 |
class Settings extends Component { |
|
9 |
||
|
168
ea92f4fe783d
- move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
151
diff
changeset
|
10 |
updateSettings = (e) => { |
|
ea92f4fe783d
- move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
151
diff
changeset
|
11 |
e.preventDefault(); |
| 53 | 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> |
|
170
7da1d5137b0b
Upgrade dependencies and correct theme colors
ymh <ymh.work@gmail.com>
parents:
168
diff
changeset
|
33 |
<input className="form-control bg-irinotes-form 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> |
|
170
7da1d5137b0b
Upgrade dependencies and correct theme colors
ymh <ymh.work@gmail.com>
parents:
168
diff
changeset
|
42 |
<input className="form-control bg-irinotes-form 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 { |
|
|
168
ea92f4fe783d
- move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
151
diff
changeset
|
61 |
currentUser: getCurrentUser(state), |
| 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); |