mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 15:49:42 +02:00
feat(frontend): ✨ Add Initial CookBook Support
This commit is contained in:
parent
2e6352cfbd
commit
83ab858e46
10 changed files with 266 additions and 32 deletions
31
frontend/api/class-interfaces/cookbooks.ts
Normal file
31
frontend/api/class-interfaces/cookbooks.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
import { BaseCRUDAPI } from "./_base";
|
||||
import { Category } from "./categories";
|
||||
import { CategoryBase } from "~/types/api-types/recipe";
|
||||
|
||||
const prefix = "/api";
|
||||
|
||||
export interface CreateCookBook {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface CookBook extends CreateCookBook {
|
||||
id: number;
|
||||
slug: string;
|
||||
position: number;
|
||||
group_id: number;
|
||||
categories: Category[] | CategoryBase[];
|
||||
}
|
||||
|
||||
const routes = {
|
||||
cookbooks: `${prefix}/groups/cookbooks`,
|
||||
cookbooksId: (id: number) => `${prefix}/groups/cookbooks/${id}`,
|
||||
};
|
||||
|
||||
export class CookbookAPI extends BaseCRUDAPI<CookBook, CreateCookBook> {
|
||||
baseRoute: string = routes.cookbooks;
|
||||
itemRoute = routes.cookbooksId;
|
||||
|
||||
async updateAll(payload: CookBook[]) {
|
||||
return await this.requests.put(this.baseRoute, payload);
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import { UtilsAPI } from "./class-interfaces/utils";
|
|||
import { NotificationsAPI } from "./class-interfaces/event-notifications";
|
||||
import { FoodAPI } from "./class-interfaces/recipe-foods";
|
||||
import { UnitAPI } from "./class-interfaces/recipe-units";
|
||||
import { CookbookAPI } from "./class-interfaces/cookbooks";
|
||||
import { ApiRequestInstance } from "~/types/api";
|
||||
|
||||
class Api {
|
||||
|
@ -27,6 +28,7 @@ class Api {
|
|||
public notifications: NotificationsAPI;
|
||||
public foods: FoodAPI;
|
||||
public units: UnitAPI;
|
||||
public cookbooks: CookbookAPI;
|
||||
|
||||
// Utils
|
||||
public upload: UploadFile;
|
||||
|
@ -46,6 +48,7 @@ class Api {
|
|||
// Users
|
||||
this.users = new UserApi(requests);
|
||||
this.groups = new GroupAPI(requests);
|
||||
this.cookbooks = new CookbookAPI(requests);
|
||||
|
||||
// Admin
|
||||
this.debug = new DebugAPI(requests);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue