mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-19 13:19:41 +02:00
* automated docs update * recipe rating component * recipe partial updates - closes #25 * use Vue.delete to update store * format * arrow functions * fix tests * format * initial context menu * localize * add confirmation dialog * context menu * fix bare exception * update line length * format all file with prettier * update changelog * download as json * update python dependencies * update javascript dependencies Co-authored-by: hay-kot <hay-kot@pm.me>
65 lines
1.5 KiB
JavaScript
65 lines
1.5 KiB
JavaScript
import { baseURL } from "./api-utils";
|
|
import { apiReq } from "./api-utils";
|
|
import i18n from "@/i18n.js";
|
|
|
|
const prefix = baseURL + "meal-plans/";
|
|
|
|
const mealPlanURLs = {
|
|
// Meals
|
|
all: `${prefix}all`,
|
|
create: `${prefix}create`,
|
|
thisWeek: `${prefix}this-week`,
|
|
update: planID => `${prefix}${planID}`,
|
|
delete: planID => `${prefix}${planID}`,
|
|
today: `${prefix}today`,
|
|
shopping: planID => `${prefix}${planID}/shopping-list`,
|
|
};
|
|
|
|
export const mealplanAPI = {
|
|
create(postBody) {
|
|
return apiReq.post(
|
|
mealPlanURLs.create,
|
|
postBody,
|
|
() => i18n.t("meal-plan.mealplan-creation-failed"),
|
|
() => i18n.t("meal-plan.mealplan-created")
|
|
);
|
|
},
|
|
|
|
async all() {
|
|
let response = await apiReq.get(mealPlanURLs.all);
|
|
return response;
|
|
},
|
|
|
|
async thisWeek() {
|
|
let response = await apiReq.get(mealPlanURLs.thisWeek);
|
|
return response.data;
|
|
},
|
|
|
|
async today() {
|
|
let response = await apiReq.get(mealPlanURLs.today);
|
|
return response;
|
|
},
|
|
|
|
delete(id) {
|
|
return apiReq.delete(
|
|
mealPlanURLs.delete(id),
|
|
null,
|
|
() => i18n.t("meal-plan.mealplan-deletion-failed"),
|
|
() => i18n.t("meal-plan.mealplan-deleted")
|
|
);
|
|
},
|
|
|
|
update(id, body) {
|
|
return apiReq.put(
|
|
mealPlanURLs.update(id),
|
|
body,
|
|
() => i18n.t("meal-plan.mealplan-update-failed"),
|
|
() => i18n.t("meal-plan.mealplan-updated")
|
|
);
|
|
},
|
|
|
|
async shoppingList(id) {
|
|
let response = await apiReq.get(mealPlanURLs.shopping(id));
|
|
return response.data;
|
|
},
|
|
};
|