mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 07:39:41 +02:00
feat: ✨ (WIP) base-shoppinglist infra (#911)
* feat: ✨ base-shoppinglist infra (WIP) * add type checker * implement controllers * apply router fixes * add checked section hide/animation * add label support * formatting * fix overflow images * add experimental banner * fix #912 word break issue * remove any type errors * bump dependencies * remove templates * fix build errors * bump node version * fix template literal
This commit is contained in:
parent
86c99b10a2
commit
6db1357064
66 changed files with 3455 additions and 1311 deletions
60
frontend/api/class-interfaces/group-shopping-lists.ts
Normal file
60
frontend/api/class-interfaces/group-shopping-lists.ts
Normal file
|
@ -0,0 +1,60 @@
|
|||
import { BaseCRUDAPI } from "../_base";
|
||||
import { ApiRequestInstance } from "~/types/api";
|
||||
import { IngredientFood, IngredientUnit } from "~/types/api-types/recipe";
|
||||
|
||||
const prefix = "/api";
|
||||
|
||||
const routes = {
|
||||
shoppingLists: `${prefix}/groups/shopping/lists`,
|
||||
shoppingListsId: (id: string) => `${prefix}/groups/shopping/lists/${id}`,
|
||||
shoppingListIdAddRecipe: (id: string, recipeId: number) => `${prefix}/groups/shopping/lists/${id}/recipe/${recipeId}`,
|
||||
};
|
||||
|
||||
export interface ShoppingListItemCreate {
|
||||
id: string;
|
||||
shoppingListId: string;
|
||||
checked: boolean;
|
||||
position: number;
|
||||
note: string;
|
||||
quantity: number;
|
||||
|
||||
isFood: boolean;
|
||||
unit: IngredientUnit | null;
|
||||
food: IngredientFood | null;
|
||||
|
||||
labelId: string | null;
|
||||
label?: {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ShoppingListCreate {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface ShoppingListSummary extends ShoppingListCreate {
|
||||
id: string;
|
||||
groupId: string;
|
||||
}
|
||||
|
||||
export interface ShoppingList extends ShoppingListSummary {
|
||||
listItems: ShoppingListItemCreate[];
|
||||
}
|
||||
|
||||
export class ShoppingListsApi extends BaseCRUDAPI<ShoppingList, ShoppingListCreate> {
|
||||
baseRoute = routes.shoppingLists;
|
||||
itemRoute = routes.shoppingListsId;
|
||||
|
||||
async addRecipe(itemId: string, recipeId: number) {
|
||||
return await this.requests.post(routes.shoppingListIdAddRecipe(itemId, recipeId), {});
|
||||
}
|
||||
}
|
||||
|
||||
export class ShoppingApi {
|
||||
public lists: ShoppingListsApi;
|
||||
|
||||
constructor(requests: ApiRequestInstance) {
|
||||
this.lists = new ShoppingListsApi(requests);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue