Merge branch '20-error-handling-login-page' into 'dev'

Added Error handling on Login Page

Closes #20

See merge request sa4-2020/the-sanmarinoes/frontend!7
This commit is contained in:
Matteo Omenetti 2020-03-04 19:03:43 +01:00
commit edf1697255
3 changed files with 16 additions and 11 deletions

View file

@ -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"};
});
};

View file

@ -8,7 +8,7 @@ export var call = {
.then(res => {
return res;
}).catch(err => {
console.error(err);
return err;
});
},
register: function(data, headers) {

View file

@ -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'