feat: bulk tag editing, bulk export, and move recipes between collections
Extends the existing bulk-select infra: recipes list gets tag add/remove and multi-recipe Markdown export; collection pages get a select mode to move recipes to another collection or remove them from the current one. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,7 @@ export async function PUT(req: NextRequest, { params }: Params) {
|
||||
addRecipeId: z.string().optional(),
|
||||
addRecipeIds: z.array(z.string()).max(200).optional(),
|
||||
removeRecipeId: z.string().optional(),
|
||||
removeRecipeIds: z.array(z.string()).max(200).optional(),
|
||||
}).safeParse(body);
|
||||
if (!parsed.success) return NextResponse.json({ error: "Validation error" }, { status: 400 });
|
||||
|
||||
@@ -66,9 +67,10 @@ export async function PUT(req: NextRequest, { params }: Params) {
|
||||
}
|
||||
}
|
||||
|
||||
if (data.removeRecipeId) {
|
||||
const idsToRemove = [...(data.removeRecipeId ? [data.removeRecipeId] : []), ...(data.removeRecipeIds ?? [])];
|
||||
if (idsToRemove.length > 0) {
|
||||
await db.delete(collectionRecipes).where(
|
||||
and(eq(collectionRecipes.collectionId, id), eq(collectionRecipes.recipeId, data.removeRecipeId))
|
||||
and(eq(collectionRecipes.collectionId, id), inArray(collectionRecipes.recipeId, idsToRemove))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user