|
@@ -26,86 +26,88 @@ class Login extends React.Component {
|
26
|
26
|
handleChangePassword = e => this.setState({inputPassword: e.target.value})
|
27
|
27
|
handleChangeRememberMe = () => this.setState(prev => ({inputRememberMe: !prev.inputRememberMe}))
|
28
|
28
|
|
29
|
|
- handleClickSubmit = () => {
|
|
29
|
+ handleClickSubmit = async () => {
|
30
|
30
|
const { history, dispatch } = this.props
|
31
|
31
|
const { inputLogin, inputPassword, inputRememberMe } = this.state
|
32
|
32
|
|
33
|
|
- dispatch(userLogin(inputLogin, inputPassword, inputRememberMe))
|
34
|
|
- .then(() => history.push('/'))
|
|
33
|
+ await dispatch(userLogin(inputLogin, inputPassword, inputRememberMe))
|
|
34
|
+ history.push('/')
|
35
|
35
|
}
|
36
|
36
|
|
37
|
37
|
render () {
|
38
|
38
|
if (this.props.user.isLoggedIn) return <Redirect to={{pathname: '/'}} />
|
39
|
|
- else return (
|
40
|
|
- <section className='loginpage'>
|
41
|
|
- <div className='container-fluid'>
|
42
|
|
-
|
43
|
|
- <LoginLogo customClass='loginpage__logo' logoSrc={LoginLogoImg} />
|
44
|
|
-
|
45
|
|
- <div className='row justify-content-center'>
|
46
|
|
- <div className='col-12 col-sm-11 col-md-8 col-lg-6 col-xl-5'>
|
47
|
|
-
|
48
|
|
- <Card customClass='loginpage__connection'>
|
49
|
|
- <CardHeader customClass='connection__header text-center'>{'Connexion'}</CardHeader>
|
50
|
|
-
|
51
|
|
- <CardBody formClass='connection__form'>
|
52
|
|
- <InputGroupText
|
53
|
|
- parentClassName='connection__form__groupemail'
|
54
|
|
- customClass='mb-3 mt-4'
|
55
|
|
- icon='fa-envelope-open-o'
|
56
|
|
- type='email'
|
57
|
|
- placeHolder='Adresse Email'
|
58
|
|
- invalidMsg='Email invalide.'
|
59
|
|
- value={this.state.inputLogin}
|
60
|
|
- onChange={this.handleChangeLogin}
|
61
|
|
- />
|
62
|
|
-
|
63
|
|
- <InputGroupText
|
64
|
|
- parentClassName='connection__form__groupepw'
|
65
|
|
- customClass=''
|
66
|
|
- icon='fa-lock'
|
67
|
|
- type='password'
|
68
|
|
- placeHolder='Mot de passe'
|
69
|
|
- invalidMsg='Mot de passe invalide.'
|
70
|
|
- value={this.state.inputPassword}
|
71
|
|
- onChange={this.handleChangePassword}
|
72
|
|
- />
|
73
|
|
-
|
74
|
|
- <div className='row mt-4 mb-4'>
|
75
|
|
- <div className='col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6'>
|
76
|
|
- <InputCheckbox
|
77
|
|
- parentClassName='connection__form__rememberme'
|
78
|
|
- customClass=''
|
79
|
|
- label='Se souvenir de moi'
|
80
|
|
- checked={this.state.inputRememberMe}
|
81
|
|
- onChange={this.handleChangeRememberMe}
|
82
|
|
- />
|
|
39
|
+ else {
|
|
40
|
+ return (
|
|
41
|
+ <section className='loginpage'>
|
|
42
|
+ <div className='container-fluid'>
|
|
43
|
+
|
|
44
|
+ <LoginLogo customClass='loginpage__logo' logoSrc={LoginLogoImg} />
|
|
45
|
+
|
|
46
|
+ <div className='row justify-content-center'>
|
|
47
|
+ <div className='col-12 col-sm-11 col-md-8 col-lg-6 col-xl-5'>
|
|
48
|
+
|
|
49
|
+ <Card customClass='loginpage__connection'>
|
|
50
|
+ <CardHeader customClass='connection__header text-center'>{'Connexion'}</CardHeader>
|
|
51
|
+
|
|
52
|
+ <CardBody formClass='connection__form'>
|
|
53
|
+ <InputGroupText
|
|
54
|
+ parentClassName='connection__form__groupemail'
|
|
55
|
+ customClass='mb-3 mt-4'
|
|
56
|
+ icon='fa-envelope-open-o'
|
|
57
|
+ type='email'
|
|
58
|
+ placeHolder='Adresse Email'
|
|
59
|
+ invalidMsg='Email invalide.'
|
|
60
|
+ value={this.state.inputLogin}
|
|
61
|
+ onChange={this.handleChangeLogin}
|
|
62
|
+ />
|
|
63
|
+
|
|
64
|
+ <InputGroupText
|
|
65
|
+ parentClassName='connection__form__groupepw'
|
|
66
|
+ customClass=''
|
|
67
|
+ icon='fa-lock'
|
|
68
|
+ type='password'
|
|
69
|
+ placeHolder='Mot de passe'
|
|
70
|
+ invalidMsg='Mot de passe invalide.'
|
|
71
|
+ value={this.state.inputPassword}
|
|
72
|
+ onChange={this.handleChangePassword}
|
|
73
|
+ />
|
|
74
|
+
|
|
75
|
+ <div className='row mt-4 mb-4'>
|
|
76
|
+ <div className='col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6'>
|
|
77
|
+ <InputCheckbox
|
|
78
|
+ parentClassName='connection__form__rememberme'
|
|
79
|
+ customClass=''
|
|
80
|
+ label='Se souvenir de moi'
|
|
81
|
+ checked={this.state.inputRememberMe}
|
|
82
|
+ onChange={this.handleChangeRememberMe}
|
|
83
|
+ />
|
|
84
|
+ </div>
|
|
85
|
+
|
|
86
|
+ <div className='col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6 text-sm-right'>
|
|
87
|
+ <LoginBtnForgotPw
|
|
88
|
+ customClass='connection__form__pwforgot'
|
|
89
|
+ label='Mot de passe oublié ?'
|
|
90
|
+ />
|
|
91
|
+ </div>
|
83
|
92
|
</div>
|
84
|
93
|
|
85
|
|
- <div className='col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6 text-sm-right'>
|
86
|
|
- <LoginBtnForgotPw
|
87
|
|
- customClass='connection__form__pwforgot'
|
88
|
|
- label='Mot de passe oublié ?'
|
89
|
|
- />
|
90
|
|
- </div>
|
91
|
|
- </div>
|
92
|
|
-
|
93
|
|
- <Button
|
94
|
|
- htmlType='button'
|
95
|
|
- bootstrapType='primary'
|
96
|
|
- customClass='connection__form__btnsubmit'
|
97
|
|
- label='Connexion'
|
98
|
|
- onClick={this.handleClickSubmit}
|
99
|
|
- />
|
100
|
|
- </CardBody>
|
101
|
|
- </Card>
|
102
|
|
-
|
|
94
|
+ <Button
|
|
95
|
+ htmlType='button'
|
|
96
|
+ bootstrapType='primary'
|
|
97
|
+ customClass='connection__form__btnsubmit'
|
|
98
|
+ label='Connexion'
|
|
99
|
+ onClick={this.handleClickSubmit}
|
|
100
|
+ />
|
|
101
|
+ </CardBody>
|
|
102
|
+ </Card>
|
|
103
|
+
|
|
104
|
+ </div>
|
103
|
105
|
</div>
|
104
|
|
- </div>
|
105
|
106
|
|
106
|
|
- </div>
|
107
|
|
- </section>
|
108
|
|
- )
|
|
107
|
+ </div>
|
|
108
|
+ </section>
|
|
109
|
+ )
|
|
110
|
+ }
|
109
|
111
|
}
|
110
|
112
|
}
|
111
|
113
|
|