2021-10-24 00:42:20 +00:00
|
|
|
import { BaseCRUDAPI } from "../_base";
|
2021-08-31 22:39:02 +00:00
|
|
|
import { CategoryBase } from "~/types/api-types/recipe";
|
2022-02-13 21:23:42 +00:00
|
|
|
import { RecipeCategory } from "~/types/api-types/user";
|
2021-08-31 22:39:02 +00:00
|
|
|
|
|
|
|
const prefix = "/api";
|
|
|
|
|
|
|
|
export interface CreateCookBook {
|
|
|
|
name: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface CookBook extends CreateCookBook {
|
|
|
|
id: number;
|
|
|
|
slug: string;
|
2021-09-01 02:51:34 +00:00
|
|
|
description: string;
|
2021-08-31 22:39:02 +00:00
|
|
|
position: number;
|
|
|
|
group_id: number;
|
2022-02-13 21:23:42 +00:00
|
|
|
categories: RecipeCategory[] | CategoryBase[];
|
2021-08-31 22:39:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|