feat: add item duplication with copy-and-edit workflow
Adds POST /api/items/:id/duplicate endpoint, useDuplicateItem hook, and a Duplicate button on ItemCard (collection view only) that opens the new item for editing immediately after creation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import { parseId } from "../lib/params.ts";
|
||||
import {
|
||||
createItem,
|
||||
deleteItem,
|
||||
duplicateItem,
|
||||
getAllItems,
|
||||
getItemById,
|
||||
updateItem,
|
||||
@@ -52,6 +53,15 @@ app.put(
|
||||
},
|
||||
);
|
||||
|
||||
app.post("/:id/duplicate", (c) => {
|
||||
const db = c.get("db");
|
||||
const id = parseId(c.req.param("id"));
|
||||
if (!id) return c.json({ error: "Invalid item ID" }, 400);
|
||||
const newItem = duplicateItem(db, id);
|
||||
if (!newItem) return c.json({ error: "Item not found" }, 404);
|
||||
return c.json(newItem, 201);
|
||||
});
|
||||
|
||||
app.delete("/:id", async (c) => {
|
||||
const db = c.get("db");
|
||||
const id = parseId(c.req.param("id"));
|
||||
|
||||
Reference in New Issue
Block a user