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 => { .then(res => {
return res; return res;
}).catch(err => { }).catch(err => {
console.error(err); //console.error(err);
return {status : "Errore"};
}); });
}, },
}; };

View File

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