summaryrefslogtreecommitdiff
path: root/routers/grocery.py
diff options
context:
space:
mode:
authorTyler Hoang <tyler@tylerhoang.xyz>2026-05-09 02:31:10 -0700
committerTyler Hoang <tyler@tylerhoang.xyz>2026-05-09 02:31:10 -0700
commit360eadf78fb001e947f3850603152adc413bb3a8 (patch)
tree2d67065890ce195bc2c0f2f6e430e86c241b2424 /routers/grocery.py
parentaba03fd72df5729a86d21c6866761b43a8abad68 (diff)
Recipe detail page, menu revamp, and UX improvements
- Add recipe detail page (recipe.html) with full ingredients and instructions - Simplify menu tab: cards show name + description only, click through for full recipe - Add description field to Recipe model with DB migration - Add AI-generated descriptions to menu, swap, and import prompts - Add single dish by description (POST /api/menus/current/recipes) - Add grocery item delete without pantry add (DELETE /api/grocery/{id}/items) - Persist grocery checked state server-side (PATCH /api/grocery/{id}/check-item) - Hash-based tab routing — refresh stays on current tab - Logo branding in header and favicon - Dark theme fixes: URL/text inputs, amber accent, muted danger/warning colors - Markdown rendering in chat (bold, italic, code blocks, lists, headers) - Fix instruction step splitting for inline-numbered steps (1. 2. 3.) - Import recipe from URL with JSON-LD structured data + AI fallback Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'routers/grocery.py')
-rw-r--r--routers/grocery.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/routers/grocery.py b/routers/grocery.py
index cbc66bb..a74776d 100644
--- a/routers/grocery.py
+++ b/routers/grocery.py
@@ -211,6 +211,28 @@ async def mark_purchased(id: int, db: Session = Depends(get_db)):
return GroceryListRead.from_orm(grocery_list)
+@router.delete("/{id}/items")
+async def delete_grocery_item(id: int, request: dict = Body(...), db: Session = Depends(get_db)):
+ """Remove a single item from a grocery list by name."""
+ grocery_list = db.query(GroceryList).filter(GroceryList.id == id).first()
+ if not grocery_list:
+ raise HTTPException(status_code=404, detail="Grocery list not found")
+
+ item_name = request.get("name")
+ if not item_name:
+ raise HTTPException(status_code=400, detail="Item name is required")
+
+ try:
+ items = json.loads(grocery_list.items)
+ except json.JSONDecodeError:
+ items = []
+
+ items = [i for i in items if not (isinstance(i, dict) and i.get("name") == item_name)]
+ grocery_list.items = json.dumps(items)
+ db.commit()
+ return {"status": "ok"}
+
+
@ai_router.post("/suggest-recipe")
async def suggest_recipe_endpoint(db: Session = Depends(get_db)):
"""Suggest a recipe based on current pantry."""