Merge branch '21-adding-error-handling-signup' into 'dev'

Resolve "Adding Error Handling Signup"

Closes #21

See merge request sa4-2020/the-sanmarinoes/frontend!9
This commit is contained in:
Matteo Omenetti 2020-03-05 08:35:42 +01:00
commit 8074774d8b
3 changed files with 19 additions and 12 deletions

View file

@ -16,7 +16,8 @@ export var call = {
.then(res => {
return res;
}).catch(err => {
console.error(err);
//console.error(err);
return {status : "Errore"};
});
},
};

View file

@ -8,8 +8,8 @@ export default class Login extends Component {
user: "",
password : "",
fireRedirect: false,
error : {state : false,
message: ""},
error : { state : false,
message: ""},
};
}
@ -26,8 +26,8 @@ export default class Login extends Component {
params : params,
}).then(res => {
if (res.status === "Errore") {
this.setState({error: {state: true,
message: "Errore"}});
this.setState({error: { state: true,
message: "Errore"}});
}
}).catch(err => {
console.log(err);

View file

@ -1,5 +1,5 @@
import React, {Component} from 'react';
import {Button, Form, Grid, Header, Image, Icon, Input} from 'semantic-ui-react';
import {Button, Form, Grid, Header, Image, Icon, Input, Message} from 'semantic-ui-react';
import { call } from '../client_server';
@ -12,6 +12,8 @@ export default class Signup extends Component{
username: "",
email: "",
password : "",
error : { state : false,
message: ""},
};
}
@ -26,13 +28,13 @@ export default class Signup extends Component{
call.register(params)
.then(res => {
if (res.data && res.status === 200) {
console.log(res.data);
if (res.status === "Errore") {
this.setState({error: { state: true,
message: "Errore"}});
}
}).catch(err => {
//console.log(err);
});
console.log(this.state);
};
onChangeHandler = (event) => {
@ -47,7 +49,6 @@ export default class Signup extends Component{
<React.Fragment>
<Button
circular
icon="right arrow"
style={{margin: "2em"}}
href="/"
>
@ -58,7 +59,12 @@ export default class Signup extends Component{
<Header as='h2' color='blue' textAlign='center'>
<Image src='img/logo.png'/> Sign-up to SmartHut
</Header>
<Form size='large' style={{marginTop : "2em"}}>
<Form size='large' style={{marginTop : "2em"}} error={this.state.error.state}>
<Message
error
header='Singup Error'
content= {this.state.error.message}
/>
<Form.Input
icon='address card outline'
iconPosition='left'