fix: Bulk Add Recipes to Shopping List (#5054)

This commit is contained in:
Michael Genson 2025-02-27 07:58:40 -06:00 committed by GitHub
parent 3d1b76bcad
commit 716c85cc3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 306 additions and 77 deletions

View file

@ -1,7 +1,7 @@
import { BaseCRUDAPI } from "../base/base-clients";
import { RecipeIngredient } from "../types/recipe";
import { ApiRequestInstance } from "~/lib/api/types/non-generated";
import {
ShoppingListAddRecipeParamsBulk,
ShoppingListCreate,
ShoppingListItemCreate,
ShoppingListItemOut,
@ -16,7 +16,7 @@ const prefix = "/api";
const routes = {
shoppingLists: `${prefix}/households/shopping/lists`,
shoppingListsId: (id: string) => `${prefix}/households/shopping/lists/${id}`,
shoppingListIdAddRecipe: (id: string, recipeId: string) => `${prefix}/households/shopping/lists/${id}/recipe/${recipeId}`,
shoppingListIdAddRecipe: (id: string) => `${prefix}/households/shopping/lists/${id}/recipe`,
shoppingListIdRemoveRecipe: (id: string, recipeId: string) => `${prefix}/households/shopping/lists/${id}/recipe/${recipeId}/delete`,
shoppingListIdUpdateLabelSettings: (id: string) => `${prefix}/households/shopping/lists/${id}/label-settings`,
@ -29,8 +29,8 @@ export class ShoppingListsApi extends BaseCRUDAPI<ShoppingListCreate, ShoppingLi
baseRoute = routes.shoppingLists;
itemRoute = routes.shoppingListsId;
async addRecipe(itemId: string, recipeId: string, recipeIncrementQuantity = 1, recipeIngredients: RecipeIngredient[] | null = null) {
return await this.requests.post(routes.shoppingListIdAddRecipe(itemId, recipeId), { recipeIncrementQuantity, recipeIngredients });
async addRecipes(itemId: string, data: ShoppingListAddRecipeParamsBulk[]) {
return await this.requests.post(routes.shoppingListIdAddRecipe(itemId), data);
}
async removeRecipe(itemId: string, recipeId: string, recipeDecrementQuantity = 1) {