fix: update addItemTag function to use tagId instead of tagName in API calls

This commit is contained in:
Felix Zett 2025-08-30 20:15:53 +02:00
parent a99c0218fb
commit 24947ed391
2 changed files with 4 additions and 4 deletions

View file

@ -58,11 +58,11 @@ export async function deleteItemTag(itemId: string, tagId: string): Promise<Item
return res.json();
}
export async function addItemTag(itemId: string, tagName: string): Promise<Item> {
export async function addItemTag(itemId: string, tagId: string): Promise<Item> {
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();

View file

@ -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)));
}