@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
4
4
import { APIConsumer } from '../data/api' ;
5
5
import { UserConsumer } from '../data/user' ;
6
6
7
+ import { Row , Button , Form } from 'react-bootstrap' ;
8
+
7
9
class Login extends React . Component {
8
10
constructor ( props ) {
9
11
super ( props ) ;
@@ -46,9 +48,16 @@ class Login extends React.Component {
46
48
return done ( { email : this . state . email } ) ;
47
49
}
48
50
51
+ // should not happen
49
52
alert ( 'Bad email / password.' ) ;
50
- } , ( err ) => {
51
- alert ( err . errorMessages ) ;
53
+ } , ( err , resp ) => {
54
+ console . error ( err . response ) ;
55
+
56
+ const errMessage = ( resp . errors && resp . errors . problems )
57
+ ? resp . errors . problems . join ( '\n' )
58
+ : resp . errorMessages . join ( '\n' ) ;
59
+
60
+ alert ( errMessage ) ;
52
61
} ) ;
53
62
54
63
return false ;
@@ -79,10 +88,9 @@ class Login extends React.Component {
79
88
< APIConsumer >
80
89
{
81
90
( api ) => (
82
-
83
- < form onSubmit = { ( e ) => this . handleLogin ( e , api , userContext . login ) } className = "col-3" >
91
+ < Form onSubmit = { ( e ) => this . handleLogin ( e , api , userContext . login ) } className = "col-3" >
84
92
< h3 className = "row" > Login</ h3 >
85
- < div className = "row pb-2" >
93
+ < Row className = "pb-2" >
86
94
< input
87
95
type = "email"
88
96
className = "form-control"
@@ -92,8 +100,8 @@ class Login extends React.Component {
92
100
onChange = { this . handleEmail }
93
101
autoFocus = { ! this . state . autoFocusPassword }
94
102
/>
95
- </ div >
96
- < div className = "row pb-4" >
103
+ </ Row >
104
+ < Row className = "pb-4" >
97
105
< input
98
106
type = "password"
99
107
className = "form-control"
@@ -103,8 +111,8 @@ class Login extends React.Component {
103
111
onChange = { this . handlePassword }
104
112
autoFocus = { this . state . autoFocusPassword }
105
113
/>
106
- </ div >
107
- < div className = "row pb-4 form-check" >
114
+ </ Row >
115
+ < Row className = "pb-4 form-check" >
108
116
< input
109
117
type = "checkbox"
110
118
className = "form-check-input"
@@ -113,11 +121,11 @@ class Login extends React.Component {
113
121
onChange = { ( ) => userContext . setRememberMe ( ! userContext . isRememberMeOn ) }
114
122
/>
115
123
< label htmlFor = "rememberMe" > Remember Me</ label >
116
- </ div >
117
- < div className = "row" >
118
- < button type = "submit" className = "btn btn- primary"> Login</ button >
119
- </ div >
120
- </ form >
124
+ </ Row >
125
+ < Row >
126
+ < Button type = "submit" variant = " primary"> Login</ Button >
127
+ </ Row >
128
+ </ Form >
121
129
)
122
130
}
123
131
</ APIConsumer >
@@ -131,9 +139,7 @@ class Login extends React.Component {
131
139
}
132
140
}
133
141
134
- Login . propTypes = {
135
- // userLogin: PropTypes.func.isRequired
136
- } ;
142
+ Login . propTypes = { } ;
137
143
138
144
Login . defaultProps = { } ;
139
145
0 commit comments