fix: update addItemTag function to use tagId instead of tagName in API calls
This commit is contained in:
parent
a99c0218fb
commit
24947ed391
2 changed files with 4 additions and 4 deletions
|
|
@ -58,11 +58,11 @@ export async function deleteItemTag(itemId: string, tagId: string): Promise<Item
|
||||||
return res.json();
|
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`, {
|
const res = await fetch(`${API_BASE}/items/${itemId}/tags`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
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");
|
if (!res.ok) throw new Error("Failed to add tag to item");
|
||||||
return res.json();
|
return res.json();
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,8 @@ export default function ItemsPage() {
|
||||||
setItems((prev) => prev.map((it) => (it.id === itemId ? updated : it)));
|
setItems((prev) => prev.map((it) => (it.id === itemId ? updated : it)));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleAddTag(itemId: string, tagName: string) {
|
async function handleAddTag(itemId: string, tagId: string) {
|
||||||
const updated = await addItemTag(itemId, tagName);
|
const updated = await addItemTag(itemId, tagId);
|
||||||
setItems((prev) => prev.map((it) => (it.id === itemId ? updated : it)));
|
setItems((prev) => prev.map((it) => (it.id === itemId ? updated : it)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue