mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 15:49:42 +02:00
feat(frontend): 🚧 CRUD Functionality
This commit is contained in:
parent
00a8fdda41
commit
afcad2f701
49 changed files with 845 additions and 275 deletions
|
@ -11,30 +11,35 @@ const routes = {
|
|||
recipesCreateUrl: `${prefix}/recipes/create-url`,
|
||||
recipesCreateFromZip: `${prefix}/recipes/create-from-zip`,
|
||||
|
||||
recipesCategory: `${prefix}/recipes/category`,
|
||||
|
||||
recipesRecipeSlug: (recipe_slug: string) => `${prefix}/recipes/${recipe_slug}`,
|
||||
recipesRecipeSlugZip: (recipe_slug: string) => `${prefix}/recipes/${recipe_slug}/zip`,
|
||||
recipesRecipeSlugImage: (recipe_slug: string) => `${prefix}/recipes/${recipe_slug}/image`,
|
||||
recipesRecipeSlugAssets: (recipe_slug: string) => `${prefix}/recipes/${recipe_slug}/assets`,
|
||||
};
|
||||
|
||||
class RecipeAPI extends BaseAPIClass {
|
||||
async getAll(start = 0, limit = 9999) {
|
||||
return await this.requests.get<Recipe[]>(routes.recipesSummary, {
|
||||
params: { start, limit },
|
||||
class RecipeAPI extends BaseAPIClass<Recipe> {
|
||||
baseRoute: string = routes.recipesSummary;
|
||||
itemRoute = (itemid: string) => routes.recipesRecipeSlug(itemid);
|
||||
|
||||
|
||||
async getAllByCategory(categories: string[]) {
|
||||
return await this.requests.get<Recipe[]>(routes.recipesCategory, {
|
||||
categories
|
||||
});
|
||||
}
|
||||
|
||||
async getOne(slug: string) {
|
||||
return await this.requests.get<Recipe>(routes.recipesRecipeSlug(slug));
|
||||
}
|
||||
|
||||
// @ts-ignore - Override method doesn't take same arguments are parent class
|
||||
async createOne(name: string) {
|
||||
return await this.requests.post(routes.recipesBase, { name });
|
||||
}
|
||||
|
||||
async createOneByUrl(url: string) {
|
||||
return await this.requests.post(routes.recipesCreateUrl, { url });
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * Methods to Generate reference urls for assets/images *
|
||||
recipeImage(recipeSlug: string, version = null, key = null) {
|
||||
return `/api/media/recipes/${recipeSlug}/images/original.webp?&rnd=${key}&version=${version}`;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue