import { apiFetch } from "@/lib/auth/api-client"; import { CreateOptions, idempotencyHeaders } from "@/lib/offline/idempotency"; import { CreateHarvestInput, Harvest, UpdateHarvestInput } from "./types"; export function fetchHarvests(): Promise { return apiFetch("/harvests"); } export function fetchHarvest(id: string): Promise { return apiFetch(`/harvests/${encodeURIComponent(id)}`); } export function createHarvest( input: CreateHarvestInput, options: CreateOptions = {}, ): Promise { return apiFetch("/harvests", { method: "POST", headers: idempotencyHeaders(options), body: JSON.stringify(input), }); } export function updateHarvest(id: string, input: UpdateHarvestInput): Promise { return apiFetch(`/harvests/${encodeURIComponent(id)}`, { method: "PATCH", body: JSON.stringify(input), }); }