mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
fixed form mixin
This commit is contained in:
parent
95c199bed6
commit
82d14b30fc
@ -18,20 +18,24 @@ export const FormMixin = {
|
|||||||
this.setState({submitted: true});
|
this.setState({submitted: true});
|
||||||
fetch
|
fetch
|
||||||
.post(this.url(), { body: this.getFormData() })
|
.post(this.url(), { body: this.getFormData() })
|
||||||
.then(response => { this.props.onRequestHide(); })
|
.then(response => { this.props.handleSuccess(); })
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleError(err){
|
handleError(err){
|
||||||
if (err.json) {
|
if (err.json) {
|
||||||
for (var input in errors){
|
for (var input in err.json.errors){
|
||||||
if (this.refs && this.refs[input] && this.refs[input].state) {
|
if (this.refs && this.refs[input] && this.refs[input].state) {
|
||||||
this.refs[input].setAlerts(errors[input]);
|
this.refs[input].setAlerts( err.json.errors[input]);
|
||||||
} else {
|
} else {
|
||||||
this.setState({errors: this.state.errors.concat(errors[input])});
|
this.setState({errors: this.state.errors.concat(err.json.errors[input])});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
this.setState({errors: ['Something went wrong, please try again later"']});
|
||||||
|
}
|
||||||
|
this.setState({submitted: false});
|
||||||
},
|
},
|
||||||
|
|
||||||
getBitcoinIds(){
|
getBitcoinIds(){
|
||||||
@ -48,9 +52,6 @@ export const FormMixin = {
|
|||||||
|
|
||||||
render(){
|
render(){
|
||||||
let alert = null;
|
let alert = null;
|
||||||
if (this.state.status >= 500){
|
|
||||||
alert = <AlertDismissable error="Something went wrong, please try again later"/>;
|
|
||||||
}
|
|
||||||
if (this.state.errors.length > 0){
|
if (this.state.errors.length > 0){
|
||||||
alert = this.state.errors.map(
|
alert = this.state.errors.map(
|
||||||
function(error) {
|
function(error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user