fix: handle add message in frontend (#1340)

This commit is contained in:
Yaodong Yu
2022-11-29 20:32:47 +08:00
committed by GitHub
parent 7867060b71
commit d815bf92bd
18 changed files with 86 additions and 47 deletions

View File

@ -45,9 +45,12 @@ class ProductListPage extends BaseListPage {
const newProduct = this.newProduct();
ProductBackend.addProduct(newProduct)
.then((res) => {
this.props.history.push({pathname: `/products/${newProduct.name}`, mode: "add"});
}
)
if (res.status === "ok") {
this.props.history.push({pathname: `/products/${newProduct.name}`, mode: "add"});
} else {
Setting.showMessage("error", `Product failed to add: ${res.msg}`);
}
})
.catch(error => {
Setting.showMessage("error", `Product failed to add: ${error}`);
});