| author | salimr <riwad.salim@yahoo.fr> |
| Fri, 31 Aug 2018 15:14:18 +0200 | |
| changeset 151 | 57d63a248f0d |
| parent 143 | cfcbf4bc66f1 |
| child 154 | a28361bda28c |
| 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 |
||
| 151 | 41 |
// const errorMessages = this.props.register.get('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"> |
| 151 | 50 |
<div className="card-header bg-secondary border-0"> |
51 |
<h4 className="text-center card-title">IRI Notes</h4> |
|
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
52 |
<form onSubmit={this.submit}> |
| 151 | 53 |
<div className="form-group" /*validationState={ errorMessages && errorMessages.has('username') ? 'error' : null }*/> |
54 |
<label className="col-form-label text-primary">Nom d'utilisateur</label> |
|
55 |
<input className="form-control bg-danger text-muted" type="text" /*inputRef={ref => { this.username = ref; }}*/ /> |
|
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> |
| 151 | 58 |
<div className="form-group" /*validationState={ errorMessages && errorMessages.has('email') ? 'error' : null }*/> |
59 |
<label className="col-form-label text-primary">Email</label> |
|
60 |
<input className="form-control bg-danger text-muted" type="email" /*inputRef={ref => { this.email = ref; }}*/ /> |
|
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> |
| 151 | 63 |
<div className="form-group" /*validationState={ errorMessages && errorMessages.has('password1') ? 'error' : null }*/> |
64 |
<label className="col-form-label text-primary">Mot de passe</label> |
|
65 |
<input className="form-control bg-danger text-muted" type="password" /*inputRef={ref => { this.password1 = ref; }}*/ /> |
|
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> |
| 151 | 68 |
<div className="form-group" /*validationState={ errorMessages && errorMessages.has('password2') ? 'error' : null }*/> |
69 |
<label className="col-form-label text-primary">Confirmer le mot de passe</label> |
|
70 |
<input className="form-control bg-danger text-muted" type="password" /*inputRef={ref => { this.password2 = ref; }}*/ /> |
|
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> |
| 151 | 73 |
<button type="submit" onClick={this.submit} className="btn btn-primary btn-lg text-secondary">S'inscrire</button> |
|
143
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
74 |
</form> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
75 |
</div> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
76 |
</div> |
| 89 | 77 |
<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
|
78 |
<a className="text-muted" href="/login" onClick={ this.onClickLogin }>Déjà inscrit ? Se connecter.</a> |
| 89 | 79 |
</p> |
|
143
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> |
|
cfcbf4bc66f1
Remove react-bootstrap from components except Modal, Collapse and Dropdown
salimr <riwad.salim@yahoo.fr>
parents:
129
diff
changeset
|
82 |
</div> |
| 89 | 83 |
</div> |
84 |
); |
|
85 |
} |
|
86 |
} |
|
87 |
||
88 |
function mapStateToProps(state, props) { |
|
89 |
return { |
|
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
94
diff
changeset
|
90 |
register: state.get('register') |
| 89 | 91 |
}; |
92 |
} |
|
93 |
||
94 |
function mapDispatchToProps(dispatch) { |
|
95 |
return { |
|
96 |
authActions: bindActionCreators(authActions, dispatch) |
|
97 |
} |
|
98 |
} |
|
99 |
||
100 |
export default connect(mapStateToProps, mapDispatchToProps)(Register); |