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:
commit
8074774d8b
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"};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,7 @@ export default class Login extends Component {
|
||||||
user: "",
|
user: "",
|
||||||
password : "",
|
password : "",
|
||||||
fireRedirect: false,
|
fireRedirect: false,
|
||||||
error : {state : false,
|
error : { state : false,
|
||||||
message: ""},
|
message: ""},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ export default class Login extends Component {
|
||||||
params : params,
|
params : params,
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.status === "Errore") {
|
if (res.status === "Errore") {
|
||||||
this.setState({error: {state: true,
|
this.setState({error: { state: true,
|
||||||
message: "Errore"}});
|
message: "Errore"}});
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
|
|
@ -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'
|
||||||
|
|
Loading…
Reference in a new issue