Error handling Signup page
This commit is contained in:
parent
edf1697255
commit
165cc8f02a
3 changed files with 19 additions and 12 deletions
|
@ -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"};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -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='Login Error'
|
||||||
|
content= {this.state.error.message}
|
||||||
|
/>
|
||||||
<Form.Input
|
<Form.Input
|
||||||
icon='address card outline'
|
icon='address card outline'
|
||||||
iconPosition='left'
|
iconPosition='left'
|
||||||
|
|
Loading…
Reference in a new issue