diff --git a/frontend/src/api.ts b/frontend/src/api.ts index 18cea36..a978ce7 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -58,11 +58,11 @@ export async function deleteItemTag(itemId: string, tagId: string): Promise { +export async function addItemTag(itemId: string, tagId: string): Promise { const res = await fetch(`${API_BASE}/items/${itemId}/tags`, { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ name: tagName }), + body: JSON.stringify({ tag_id: tagId }), }); if (!res.ok) throw new Error("Failed to add tag to item"); return res.json(); diff --git a/frontend/src/pages/ItemsPage.tsx b/frontend/src/pages/ItemsPage.tsx index e66a3a1..9692574 100644 --- a/frontend/src/pages/ItemsPage.tsx +++ b/frontend/src/pages/ItemsPage.tsx @@ -55,8 +55,8 @@ export default function ItemsPage() { setItems((prev) => prev.map((it) => (it.id === itemId ? updated : it))); } - async function handleAddTag(itemId: string, tagName: string) { - const updated = await addItemTag(itemId, tagName); + async function handleAddTag(itemId: string, tagId: string) { + const updated = await addItemTag(itemId, tagId); setItems((prev) => prev.map((it) => (it.id === itemId ? updated : it))); }