import { apiFetch } from './client' import type { Budget, CreateBudget, UpdateBudget } from '@llm-router/shared' export async function listBudgets(): Promise { const res = await apiFetch('/v1/expense/budgets') if (!res.ok) throw new Error('Failed to load budgets') return res.json() as Promise } export async function createBudget(data: CreateBudget): Promise { const res = await apiFetch('/v1/expense/budgets', { method: 'POST', body: JSON.stringify(data), }) if (!res.ok) { const err = await res.json() as { error?: string } throw new Error(err.error ?? 'Failed to create budget') } return res.json() as Promise } export async function updateBudget(id: string, data: UpdateBudget): Promise { const res = await apiFetch(`/v1/expense/budgets/${id}`, { method: 'PUT', body: JSON.stringify(data), }) if (!res.ok) { const err = await res.json() as { error?: string } throw new Error(err.error ?? 'Failed to update budget') } return res.json() as Promise } export async function deleteBudget(id: string): Promise { const res = await apiFetch(`/v1/expense/budgets/${id}`, { method: 'DELETE' }) if (!res.ok) throw new Error('Failed to delete budget') }