import { apiFetch } from './client' export interface ShoppingItem { id: string name: string amount?: number unit?: string checked: boolean recipe_id?: string recipe_title?: string created_at?: string } export interface ShoppingGroup { recipe_title: string recipe_id?: string items: ShoppingItem[] } export function fetchShopping() { return apiFetch('/shopping') } export function addFromRecipe(recipeId: string) { return apiFetch<{ added: number }>(`/shopping/from-recipe/${recipeId}`, { method: 'POST' }) } export function addCustomItem(item: { name: string; amount?: number; unit?: string }) { return apiFetch('/shopping', { method: 'POST', body: JSON.stringify(item), }) } export function toggleCheck(id: string) { return apiFetch(`/shopping/${id}/check`, { method: 'PATCH' }) } export function deleteItem(id: string) { return apiFetch(`/shopping/${id}`, { method: 'DELETE' }) } export function deleteAll() { return apiFetch('/shopping/all', { method: 'DELETE' }) } export function deleteChecked() { return apiFetch('/shopping/checked', { method: 'DELETE' }) }