feat: allow adding pantry items by text input with auto-ingredient creation
CI / backend (pytest + alembic) (push) Has been cancelled
CI / frontend (build) (push) Has been cancelled

- backend: expose POST /api/ingredients on public router so frontend can create ingredients without admin token
- frontend/api: point listIngredients and createIngredient to /api/ingredients
- frontend/pantry: replace ingredient dropdown with searchable text input + fuzzy matching + auto-create
This commit is contained in:
2026-05-17 21:31:37 -07:00
parent 986968b93d
commit 54b3e785b3
3 changed files with 89 additions and 22 deletions
+20
View File
@@ -55,6 +55,26 @@ def get_ingredient(ingredient_id: UUID, db: Session = Depends(get_db)) -> Ingred
return row
@public_router.post("", response_model=IngredientRead, status_code=status.HTTP_201_CREATED)
def create_ingredient_public(payload: IngredientCreate, db: Session = Depends(get_db)) -> Ingredient:
row = Ingredient(
name=payload.name,
name_lower=payload.name.lower(),
aliases=payload.aliases,
aisle=payload.aisle,
unit=payload.unit,
typical_price=payload.typical_price,
)
db.add(row)
try:
db.commit()
except IntegrityError:
db.rollback()
raise HTTPException(status_code=409, detail="ingredient name already exists")
db.refresh(row)
return row
@admin_router.post("", response_model=IngredientRead, status_code=status.HTTP_201_CREATED)
def create_ingredient(payload: IngredientCreate, db: Session = Depends(get_db)) -> Ingredient:
row = Ingredient(