| author | ymh <ymh.work@gmail.com> |
| Tue, 04 Dec 2018 18:56:31 +0100 | |
| changeset 192 | e4c2c1919c20 |
| parent 191 | 3f71ad81a5a9 |
| child 199 | c78d579f4b55 |
| permissions | -rw-r--r-- |
| 89 | 1 |
import React, { Component } from 'react'; |
2 |
import { connect } from 'react-redux'; |
|
3 |
import { bindActionCreators } from 'redux'; |
|
4 |
import * as authActions from '../actions/authActions'; |
|
5 |
||
6 |
class Register extends Component { |
|
7 |
||
8 |
register = () => { |
|
9 |
const username = this.username.value; |
|
10 |
const email = this.email.value; |
|
11 |
const password1 = this.password1.value; |
|
12 |
const password2 = this.password2.value; |
|
13 |
||
14 |
this.props.authActions.registerSubmit(username, email, password1, password2); |
|
15 |
} |
|
16 |
||
| 94 | 17 |
submit = (e) => { |
18 |
e.preventDefault(); |
|
19 |
||
20 |
this.register(); |
|
21 |
} |
|
22 |
||
| 89 | 23 |
onClickLogin = (e) => { |
24 |
e.preventDefault(); |
|
25 |
this.props.history.push('/login'); |
|
26 |
} |
|
27 |
||
28 |
renderErrorMessage(errorMessages, fieldname) { |
|
29 |
if (errorMessages && errorMessages.has(fieldname)) { |
|
30 |
return errorMessages.get(fieldname).map((message, key) => |
|
| 151 | 31 |
<p className="form-text" key={ key }>{ message }</p> |
| 89 | 32 |
); |
33 |
} |
|
34 |
} |
|
35 |
||
36 |
render() { |
|
37 |
||
|
168
ea92f4fe783d
- move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
161
diff
changeset
|
38 |
// const errorMessages = this.props.register.errorMessages; |
| 89 | 39 |
|
40 |
return ( |
|
41 |
<div> |
|
| 151 | 42 |
{/* <Navbar history={this.props.history} /> */} |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
43 |
<div className="container-fluid"> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
44 |
<div className="row"> |
| 151 | 45 |
<div className="col-lg-6 offset-md-3"> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
46 |
<div className="panel-login panel panel-default"> |
|
154
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
47 |
<div className="card-header bg-secondary border-0 mt-5 pt-5"> |
|
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
48 |
<h4 className="text-center card-title font-weight-bold text-lg" onClick={this.onClickHome}>IRI Notes</h4> |
|
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
49 |
<form className="pt-3 ml-5 pl-5" onSubmit={this.submit}> |
|
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
50 |
<div className="form-group mb-2 ml-3 w-75" /*validationState={ errorMessages && errorMessages.has('username') ? 'error' : null }*/> |
|
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
51 |
<label className="col-form-label text-primary font-weight-bold mt-2">Nom d'utilisateur</label> |
|
170
7da1d5137b0b
Upgrade dependencies and correct theme colors
ymh <ymh.work@gmail.com>
parents:
168
diff
changeset
|
52 |
<input className="form-control bg-irinotes-form border-0 text-muted" type="text" /*inputRef={ref => { this.username = ref; }}*/ /> |
| 151 | 53 |
{/* { this.renderErrorMessage(errorMessages, 'username') } */} |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
54 |
</div> |
|
154
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
55 |
<div className="form-group mb-2 ml-3 w-75" /*validationState={ errorMessages && errorMessages.has('email') ? 'error' : null }*/> |
|
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
56 |
<label className="col-form-label text-primary font-weight-bold mt-2">Email</label> |
|
170
7da1d5137b0b
Upgrade dependencies and correct theme colors
ymh <ymh.work@gmail.com>
parents:
168
diff
changeset
|
57 |
<input className="form-control bg-irinotes-form border-0 text-muted" type="email" /*inputRef={ref => { this.email = ref; }}*/ /> |
| 151 | 58 |
{/* { this.renderErrorMessage(errorMessages, 'email') } */} |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
59 |
</div> |
|
154
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
60 |
<div className="form-group mb-2 ml-3 w-75" /*validationState={ errorMessages && errorMessages.has('password1') ? 'error' : null }*/> |
|
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
61 |
<label className="col-form-label text-primary font-weight-bold mt-2">Mot de passe</label> |
|
170
7da1d5137b0b
Upgrade dependencies and correct theme colors
ymh <ymh.work@gmail.com>
parents:
168
diff
changeset
|
62 |
<input className="form-control bg-irinotes-form border-0 text-muted" type="password" /*inputRef={ref => { this.password1 = ref; }}*/ /> |
| 151 | 63 |
{/* { this.renderErrorMessage(errorMessages, 'password1') } */} |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
64 |
</div> |
|
154
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
65 |
<div className="form-group mb-2 ml-3 w-75" /*validationState={ errorMessages && errorMessages.has('password2') ? 'error' : null }*/> |
|
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
66 |
<label className="col-form-label text-primary font-weight-bold mt-2">Confirmer le mot de passe</label> |
|
170
7da1d5137b0b
Upgrade dependencies and correct theme colors
ymh <ymh.work@gmail.com>
parents:
168
diff
changeset
|
67 |
<input className="form-control bg-irinotes-form border-0 text-muted" type="password" /*inputRef={ref => { this.password2 = ref; }}*/ /> |
| 151 | 68 |
{/* { this.renderErrorMessage(errorMessages, 'password2') } */} |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
69 |
</div> |
|
154
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
70 |
<div className="text-center mr-5 pr-5"> |
|
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
71 |
<button type="submit" onClick={this.submit} className="btn btn-primary btn-lg text-secondary font-weight-bold mt-3">S'inscrire</button> |
|
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
72 |
</div> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
73 |
</form> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
74 |
</div> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
75 |
</div> |
| 89 | 76 |
<p className="text-center"> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
77 |
<a className="text-muted" href="/login" onClick={ this.onClickLogin }>Déjà inscrit ? Se connecter.</a> |
| 89 | 78 |
</p> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
79 |
</div> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
80 |
</div> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
81 |
</div> |
| 89 | 82 |
</div> |
83 |
); |
|
84 |
} |
|
85 |
} |
|
86 |
||
87 |
function mapStateToProps(state, props) { |
|
88 |
return { |
|
|
168
ea92f4fe783d
- move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
161
diff
changeset
|
89 |
register: state.register |
| 89 | 90 |
}; |
91 |
} |
|
92 |
||
93 |
function mapDispatchToProps(dispatch) { |
|
94 |
return { |
|
95 |
authActions: bindActionCreators(authActions, dispatch) |
|
96 |
} |
|
97 |
} |
|
98 |
||
99 |
export default connect(mapStateToProps, mapDispatchToProps)(Register); |