Pass the error message from the api up to the button's error handler

Remove the "Error:" prefix front he front-end facing error message

The notice has already the error state and it's implied
This commit is contained in:
Mészáros Róbert 2020-04-23 17:05:44 +03:00
parent 74a4846861
commit cfe450f835
6 changed files with 11 additions and 16 deletions

View file

@ -19,8 +19,7 @@ class CartActionHandler {
return res.json();
}).then(function(data) {
if (!data.success) {
//Todo: Error handling
return;
throw Error(data.data);
}
return data.data.id;
});
@ -36,4 +35,4 @@ class CartActionHandler {
}
}
export default CartActionHandler;
export default CartActionHandler;

View file

@ -41,8 +41,7 @@ class CheckoutActionHandler {
return res.json();
}).then(function (data) {
if (!data.success) {
//Todo: Error handling
return;
throw Error(data.data);
}
return data.data.id;
});
@ -57,4 +56,4 @@ class CheckoutActionHandler {
}
}
export default CheckoutActionHandler;
export default CheckoutActionHandler;

View file

@ -15,7 +15,7 @@ class ErrorHandler {
{
const textarea = document.createElement('textarea');
textarea.innerHTML = text;
return textarea.value;
return textarea.value.replace('Error: ', '');
}
clear()
@ -28,4 +28,4 @@ class ErrorHandler {
}
}
export default ErrorHandler;
export default ErrorHandler;

View file

@ -83,8 +83,7 @@ class SingleProductActionHandler {
return res.json();
}).then(function (data) {
if (!data.success) {
//Todo: Error handling
return;
throw Error(data.data);
}
return data.data.id;
});
@ -123,4 +122,4 @@ class SingleProductActionHandler {
return this.formElement.classList.contains('grouped_form');
}
}
export default SingleProductActionHandler;
export default SingleProductActionHandler;

View file

@ -10,8 +10,7 @@ const onApprove = (context) => {
return res.json();
}).then((data)=>{
if (!data.success) {
//Todo: Error handling
return;
throw Error(data.data);
}
location.href = context.config.redirect;
});

View file

@ -10,8 +10,7 @@ const onApprove = (context) => {
return res.json();
}).then((data)=>{
if (!data.success) {
//Todo: Error handling
return;
throw Error(data.data);
}
document.querySelector('#place_order').click()
});
@ -19,4 +18,4 @@ const onApprove = (context) => {
}
}
export default onApprove;
export default onApprove;