Added Error handling on Login Page
This commit is contained in:
parent
dfe403d608
commit
55c01035fe
3 changed files with 16 additions and 11 deletions
|
@ -73,9 +73,11 @@ class App extends React.Component {
|
|||
this.setState({
|
||||
error: res.data.message
|
||||
});
|
||||
return this.state.error;
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
return {status : "Errore"};
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ export var call = {
|
|||
.then(res => {
|
||||
return res;
|
||||
}).catch(err => {
|
||||
console.error(err);
|
||||
return err;
|
||||
});
|
||||
},
|
||||
register: function(data, headers) {
|
||||
|
|
|
@ -8,6 +8,8 @@ export default class Login extends Component {
|
|||
user: "",
|
||||
password : "",
|
||||
fireRedirect: false,
|
||||
error : {state : false,
|
||||
message: ""},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -23,10 +25,9 @@ export default class Login extends Component {
|
|||
user: this.state.user,
|
||||
params : params,
|
||||
}).then(res => {
|
||||
if (res === '400') {
|
||||
console.log('error');
|
||||
} else {
|
||||
console.log("SUCCESS");
|
||||
if (res.status === "Errore") {
|
||||
this.setState({error: {state: true,
|
||||
message: "Errore"}});
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
|
@ -51,13 +52,19 @@ export default class Login extends Component {
|
|||
href="/"
|
||||
>
|
||||
<Icon name='arrow alternate circle left'/>
|
||||
Go Home </Button>
|
||||
Go Home
|
||||
</Button>
|
||||
<Grid textAlign='center' style={{height: '70vh'}} verticalAlign='middle'>
|
||||
<Grid.Column style={{maxWidth: 450}}>
|
||||
<Header as='h2' color='blue' textAlign='center'>
|
||||
<Image src='img/logo.png'/> Log-in to SmartHut
|
||||
</Header>
|
||||
<Form size='large' style={{marginTop : "2em"}}>
|
||||
<Form size='large' style={{marginTop : "2em"}} error={this.state.error.state}>
|
||||
<Message
|
||||
error
|
||||
header='Login Error'
|
||||
content= {this.state.error.message}
|
||||
/>
|
||||
<Form.Input
|
||||
control={Input}
|
||||
type="text"
|
||||
|
@ -66,10 +73,6 @@ export default class Login extends Component {
|
|||
iconPosition='left'
|
||||
placeholder='Username or E-mail'
|
||||
onChange={this.onChangeHandler}
|
||||
/*error={{
|
||||
content: 'Please enter a valid email address',
|
||||
pointing: 'below',
|
||||
}}*/
|
||||
/>
|
||||
<Form.Input
|
||||
icon='lock'
|
||||
|
|
Loading…
Reference in a new issue