diff --git a/backend/routes/items.py b/backend/routes/items.py index fe6b7dc..f2afda1 100644 --- a/backend/routes/items.py +++ b/backend/routes/items.py @@ -83,3 +83,16 @@ def delete_item(item_id: UUID, db: Session = Depends(get_db)): raise HTTPException(status_code=404, detail="Item not found") db.delete(item) db.commit() + +@router.put("/{item_id}", response_model=ItemOut) +def update_item_name(item_id: UUID, payload: dict, db: Session = Depends(get_db)): + item = db.get(models.Item, item_id) + if not item: + raise HTTPException(status_code=404, detail="Item not found") + name = payload.get("name") + if not name or not isinstance(name, str): + raise HTTPException(status_code=400, detail="Missing or invalid name") + item.name = name + db.commit() + db.refresh(item) + return item