mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 15:49:42 +02:00
feat(backend): ✨ rewrite mealplanner with simple api (#683)
* feat(backend): ✨ new meal-planner feature * feat(frontend): ✨ new meal plan feature * refactor(backend): ♻️ refactor base services classes and add mixins for crud * feat(frontend): ✨ add UI/API for mealplanner * feat(backend): ✨ add get_today and get_slice options for mealplanner * test(backend): ✅ add and update group mealplanner tests * fix(backend): 🐛 Fix recipe_id column type for PG Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
parent
bdaf758712
commit
b542583303
46 changed files with 869 additions and 255 deletions
|
@ -12,15 +12,14 @@ export interface CrudAPIInterface {
|
|||
|
||||
export interface CrudAPIMethodsInterface {
|
||||
// CRUD Methods
|
||||
getAll(): any
|
||||
createOne(): any
|
||||
getOne(): any
|
||||
updateOne(): any
|
||||
patchOne(): any
|
||||
deleteOne(): any
|
||||
getAll(): any;
|
||||
createOne(): any;
|
||||
getOne(): any;
|
||||
updateOne(): any;
|
||||
patchOne(): any;
|
||||
deleteOne(): any;
|
||||
}
|
||||
|
||||
|
||||
export abstract class BaseAPI {
|
||||
requests: ApiRequestInstance;
|
||||
|
||||
|
@ -33,9 +32,9 @@ export abstract class BaseCRUDAPI<T, U> extends BaseAPI implements CrudAPIInterf
|
|||
abstract baseRoute: string;
|
||||
abstract itemRoute(itemId: string | number): string;
|
||||
|
||||
async getAll(start = 0, limit = 9999) {
|
||||
async getAll(start = 0, limit = 9999, params = {}) {
|
||||
return await this.requests.get<T[]>(this.baseRoute, {
|
||||
params: { start, limit },
|
||||
params: { start, limit, ...params },
|
||||
});
|
||||
}
|
||||
|
||||
|
|
32
frontend/api/class-interfaces/group-mealplan.ts
Normal file
32
frontend/api/class-interfaces/group-mealplan.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { BaseCRUDAPI } from "./_base";
|
||||
|
||||
const prefix = "/api";
|
||||
|
||||
const routes = {
|
||||
mealplan: `${prefix}/groups/mealplans`,
|
||||
mealplanId: (id: string | number) => `${prefix}/groups/mealplans/${id}`,
|
||||
};
|
||||
|
||||
type PlanEntryType = "breakfast" | "lunch" | "dinner" | "snack";
|
||||
|
||||
export interface CreateMealPlan {
|
||||
date: string;
|
||||
entryType: PlanEntryType;
|
||||
title: string;
|
||||
text: string;
|
||||
recipeId?: number;
|
||||
}
|
||||
|
||||
export interface UpdateMealPlan extends CreateMealPlan {
|
||||
id: number;
|
||||
groupId: number;
|
||||
}
|
||||
|
||||
export interface MealPlan extends UpdateMealPlan {
|
||||
recipe: any;
|
||||
}
|
||||
|
||||
export class MealPlanAPI extends BaseCRUDAPI<MealPlan, CreateMealPlan> {
|
||||
baseRoute = routes.mealplan;
|
||||
itemRoute = routes.mealplanId;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue