Add messages upon recipe updated

This commit is contained in:
Florian Dupret 2021-04-29 08:41:36 +02:00
commit 9f361ba10f
3 changed files with 15 additions and 6 deletions

View file

@ -88,9 +88,16 @@ export const recipeAPI = {
},
async update(data) {
let response = await apiReq.put(recipeURLs.update(data.slug), data);
store.dispatch("patchRecipe", response.data);
return response.data.slug; // ! Temporary until I rewrite to refresh page without additional request
let response = await apiReq.put(
recipeURLs.update(data.slug),
data,
function() { return i18n.t('recipe.recipe-update-failed'); },
function() { return i18n.t('recipe.recipe-updated'); }
);
if(response) {
store.dispatch("patchRecipe", response.data);
return response.data.slug; // ! Temporary until I rewrite to refresh page without additional request
}
},
async patch(data) {

View file

@ -194,6 +194,8 @@
"recipe-image": "Recipe Image",
"recipe-image-updated": "Recipe image updated",
"recipe-name": "Recipe Name",
"recipe-update-failed": "Recipe update failed",
"recipe-updated": "Recipe updated",
"servings": "Servings",
"sodium-content": "Sodium Content",
"step-index": "Step: {step}",

View file

@ -180,9 +180,9 @@ export default {
return this.$refs.recipeEditor.validateRecipe();
}
},
async saveImage() {
async saveImage(overrideSuccessMsg = false) {
if (this.fileObject) {
if (api.recipes.updateImage(this.recipeDetails.slug, this.fileObject)) {
if (api.recipes.updateImage(this.recipeDetails.slug, this.fileObject, overrideSuccessMsg)) {
this.imageKey += 1;
}
}
@ -192,7 +192,7 @@ export default {
let slug = await api.recipes.update(this.recipeDetails);
if (this.fileObject) {
this.saveImage();
this.saveImage(true);
}
this.form = false;