1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-23 07:09:41 +02:00
mealie/frontend/src/api/mealplan.js
sephrat 1e5edc7434
More localization (#358)
* Translate missing items on About page

* Localize import summary dialog

* Make site menu translation reactive

* Localize import options

* Include semi colon in string

* Move API texts to frontend + better status codes

* Provide feedback to user when no meal is planned

* Fix API tests after latest rework

* Add warning for API changes in changelog

* Refactor API texts handling

* Refactor API texts handling #2

* Better API feedback

* Rearrange strings hierarchy

* Add messages upon recipe updated

* Fix 'recipe effected' typo

* Remove snackbar usage in backend

* Translate toolbox

* Provide feedback for tags CRUD

* Fix messed up merge

* Translate sign-up form

* Better feedback for sign-up CRUD

* Refactor log-in API texts handling

* No error message when user is not authenticated

* Remove unimportant console log
2021-04-29 08:22:45 -08:00

64 lines
1.6 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,
function() { return i18n.t('meal-plan.mealplan-creation-failed')},
function() { return 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,
function() { return i18n.t('meal-plan.mealplan-deletion-failed'); },
function() { return i18n.t('meal-plan.mealplan-deleted'); }
);
},
update(id, body) {
return apiReq.put(
mealPlanURLs.update(id),
body,
function() { return i18n.t('meal-plan.mealplan-update-failed'); },
function() { return i18n.t('meal-plan.mealplan-updated'); }
);
},
async shoppingList(id) {
let response = await apiReq.get(mealPlanURLs.shopping(id));
return response.data;
},
};