mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 22:43:34 -07:00
arrow functions
This commit is contained in:
parent
e2f9ba0c7e
commit
9c821adab2
2 changed files with 32 additions and 25 deletions
|
@ -1,7 +1,7 @@
|
||||||
import { baseURL } from "./api-utils";
|
import { baseURL } from "./api-utils";
|
||||||
import { apiReq } from "./api-utils";
|
import { apiReq } from "./api-utils";
|
||||||
import { store } from "../store";
|
import { store } from "../store";
|
||||||
import i18n from '@/i18n.js';
|
import i18n from "@/i18n.js";
|
||||||
|
|
||||||
const prefix = baseURL + "recipes/";
|
const prefix = baseURL + "recipes/";
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ export const recipeAPI = {
|
||||||
const response = await apiReq.post(
|
const response = await apiReq.post(
|
||||||
recipeURLs.createByURL,
|
recipeURLs.createByURL,
|
||||||
{ url: recipeURL },
|
{ url: recipeURL },
|
||||||
function() { return i18n.t('recipe.recipe-creation-failed'); },
|
() => i18n.t("recipe.recipe-creation-failed"),
|
||||||
function() { return i18n.t('recipe.recipe-created'); }
|
() => i18n.t("recipe.recipe-created")
|
||||||
);
|
);
|
||||||
|
|
||||||
store.dispatch("requestRecentRecipes");
|
store.dispatch("requestRecentRecipes");
|
||||||
|
@ -49,8 +49,8 @@ export const recipeAPI = {
|
||||||
const response = await apiReq.post(
|
const response = await apiReq.post(
|
||||||
recipeURLs.create,
|
recipeURLs.create,
|
||||||
recipeData,
|
recipeData,
|
||||||
function() { return i18n.t('recipe.recipe-creation-failed'); },
|
() => i18n.t("recipe.recipe-creation-failed"),
|
||||||
function() { return i18n.t('recipe.recipe-created'); }
|
() => i18n.t("recipe.recipe-created")
|
||||||
);
|
);
|
||||||
store.dispatch("requestRecentRecipes");
|
store.dispatch("requestRecentRecipes");
|
||||||
return response.data;
|
return response.data;
|
||||||
|
@ -68,13 +68,17 @@ export const recipeAPI = {
|
||||||
|
|
||||||
let successMessage = null;
|
let successMessage = null;
|
||||||
if (!overrideSuccessMsg) {
|
if (!overrideSuccessMsg) {
|
||||||
successMessage = function() { return overrideSuccessMsg ? null : i18n.t('recipe.recipe-image-updated'); };
|
successMessage = function() {
|
||||||
|
return overrideSuccessMsg
|
||||||
|
? null
|
||||||
|
: i18n.t("recipe.recipe-image-updated");
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiReq.put(
|
return apiReq.put(
|
||||||
recipeURLs.updateImage(recipeSlug),
|
recipeURLs.updateImage(recipeSlug),
|
||||||
formData,
|
formData,
|
||||||
function() { return i18n.t('general.image-upload-failed'); },
|
() => i18n.t("general.image-upload-failed"),
|
||||||
successMessage
|
successMessage
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -93,8 +97,8 @@ export const recipeAPI = {
|
||||||
return apiReq.post(
|
return apiReq.post(
|
||||||
recipeURLs.updateImage(slug),
|
recipeURLs.updateImage(slug),
|
||||||
{ url: url },
|
{ url: url },
|
||||||
function() { return i18n.t('general.image-upload-failed'); },
|
() => i18n.t("general.image-upload-failed"),
|
||||||
function() { return i18n.t('recipe.recipe-image-updated'); }
|
() => i18n.t("recipe.recipe-image-updated")
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -102,8 +106,8 @@ export const recipeAPI = {
|
||||||
let response = await apiReq.put(
|
let response = await apiReq.put(
|
||||||
recipeURLs.update(data.slug),
|
recipeURLs.update(data.slug),
|
||||||
data,
|
data,
|
||||||
function() { return i18n.t('recipe.recipe-update-failed'); },
|
() => i18n.t("recipe.recipe-update-failed"),
|
||||||
function() { return i18n.t('recipe.recipe-updated'); }
|
() => i18n.t("recipe.recipe-updated")
|
||||||
);
|
);
|
||||||
if (response) {
|
if (response) {
|
||||||
store.dispatch("patchRecipe", response.data);
|
store.dispatch("patchRecipe", response.data);
|
||||||
|
@ -117,13 +121,15 @@ export const recipeAPI = {
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
delete(recipeSlug) {
|
async delete(recipeSlug) {
|
||||||
return apiReq.delete(
|
const response = await apiReq.delete(
|
||||||
recipeURLs.delete(recipeSlug),
|
recipeURLs.delete(recipeSlug),
|
||||||
null,
|
null,
|
||||||
function() { return i18n.t('recipe.unable-to-delete-recipe'); },
|
() => i18n.t("recipe.unable-to-delete-recipe"),
|
||||||
function() { return i18n.t('recipe.recipe-deleted'); }
|
() => i18n.t("recipe.recipe-deleted")
|
||||||
);
|
);
|
||||||
|
store.dispatch("dropRecipe", response.data);
|
||||||
|
return response;
|
||||||
},
|
},
|
||||||
|
|
||||||
async allSummary(start = 0, limit = 9999) {
|
async allSummary(start = 0, limit = 9999) {
|
||||||
|
|
|
@ -6,3 +6,4 @@ DB_URL.unlink(missing_ok=True)
|
||||||
if settings.DB_ENGINE != "postgres":
|
if settings.DB_ENGINE != "postgres":
|
||||||
# Monkeypatch Database Testing
|
# Monkeypatch Database Testing
|
||||||
settings.DB_URL = determine_sqlite_path(path=False, suffix="test")
|
settings.DB_URL = determine_sqlite_path(path=False, suffix="test")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue