| 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-- |
| 89 | 1 |
import React, { Component } from 'react'; |
2 |
import { connect } from 'react-redux'; |
|
3 |
import { bindActionCreators } from 'redux'; |
|
4 |
import '../App.css'; |
|
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
5 |
import './Register.css'; |
| 151 | 6 |
// import Navbar from './Navbar'; |
| 89 | 7 |
import * as authActions from '../actions/authActions'; |
8 |
||
9 |
class Register extends Component { |
|
10 |
||
11 |
register = () => { |
|
12 |
const username = this.username.value; |
|
13 |
const email = this.email.value; |
|
14 |
const password1 = this.password1.value; |
|
15 |
const password2 = this.password2.value; |
|
16 |
||
17 |
this.props.authActions.registerSubmit(username, email, password1, password2); |
|
18 |
} |
|
19 |
||
| 94 | 20 |
submit = (e) => { |
21 |
e.preventDefault(); |
|
22 |
||
23 |
this.register(); |
|
24 |
} |
|
25 |
||
| 89 | 26 |
onClickLogin = (e) => { |
27 |
e.preventDefault(); |
|
28 |
this.props.history.push('/login'); |
|
29 |
} |
|
30 |
||
31 |
renderErrorMessage(errorMessages, fieldname) { |
|
32 |
if (errorMessages && errorMessages.has(fieldname)) { |
|
33 |
return errorMessages.get(fieldname).map((message, key) => |
|
| 151 | 34 |
<p className="form-text" key={ key }>{ message }</p> |
| 89 | 35 |
); |
36 |
} |
|
37 |
} |
|
38 |
||
39 |
render() { |
|
40 |
||
|
168
ea92f4fe783d
- move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
161
diff
changeset
|
41 |
// const errorMessages = this.props.register.errorMessages; |
| 89 | 42 |
|
43 |
return ( |
|
44 |
<div> |
|
| 151 | 45 |
{/* <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
|
46 |
<div className="container-fluid"> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
47 |
<div className="row"> |
| 151 | 48 |
<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
|
49 |
<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
|
50 |
<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
|
51 |
<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
|
52 |
<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
|
53 |
<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
|
54 |
<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
|
55 |
<input className="form-control bg-irinotes-form border-0 text-muted" type="text" /*inputRef={ref => { this.username = ref; }}*/ /> |
| 151 | 56 |
{/* { 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
|
57 |
</div> |
|
154
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
58 |
<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
|
59 |
<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
|
60 |
<input className="form-control bg-irinotes-form border-0 text-muted" type="email" /*inputRef={ref => { this.email = ref; }}*/ /> |
| 151 | 61 |
{/* { 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
|
62 |
</div> |
|
154
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
63 |
<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
|
64 |
<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
|
65 |
<input className="form-control bg-irinotes-form border-0 text-muted" type="password" /*inputRef={ref => { this.password1 = ref; }}*/ /> |
| 151 | 66 |
{/* { 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
|
67 |
</div> |
|
154
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
68 |
<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
|
69 |
<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
|
70 |
<input className="form-control bg-irinotes-form border-0 text-muted" type="password" /*inputRef={ref => { this.password2 = ref; }}*/ /> |
| 151 | 71 |
{/* { 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
|
72 |
</div> |
|
154
a28361bda28c
Adapt all css classes with Bootstrap 4 Utilities
salimr <riwad.salim@yahoo.fr>
parents:
151
diff
changeset
|
73 |
<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
|
74 |
<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
|
75 |
</div> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
76 |
</form> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
77 |
</div> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
78 |
</div> |
| 89 | 79 |
<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
|
80 |
<a className="text-muted" href="/login" onClick={ this.onClickLogin }>Déjà inscrit ? Se connecter.</a> |
| 89 | 81 |
</p> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
82 |
</div> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
83 |
</div> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
84 |
</div> |
| 89 | 85 |
</div> |
86 |
); |
|
87 |
} |
|
88 |
} |
|
89 |
||
90 |
function mapStateToProps(state, props) { |
|
91 |
return { |
|
|
168
ea92f4fe783d
- move SlateEditor and dependencies to its own folder
ymh <ymh.work@gmail.com>
parents:
161
diff
changeset
|
92 |
register: state.register |
| 89 | 93 |
}; |
94 |
} |
|
95 |
||
96 |
function mapDispatchToProps(dispatch) { |
|
97 |
return { |
|
98 |
authActions: bindActionCreators(authActions, dispatch) |
|
99 |
} |
|
100 |
} |
|
101 |
||
102 |
export default connect(mapStateToProps, mapDispatchToProps)(Register); |