Hayden 9b1bf56a5d
[Feat] Migrate from Pages to Cookbooks (#664)
* feat:  Add Description to Cookbooks

* feat(frontend):  Cookbook view page

* feat(frontend): 💄 Add final UI touches

* fix(backend): 🐛 Add get by slug or id

* fix linting issue

* test(backend):  Update tests from pages -> cookbooks

* refactor(backend): 🔥 Delete old page files

Co-authored-by: hay-kot <hay-kot@pm.me>
2021-08-31 18:51:34 -08:00

33 lines
792 B
TypeScript

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;
description: 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);
}
}