import type { AEPOAction, StepResult, StateResult, ResetResult, TaskDifficulty } from "./types"; // Static export has no Next.js server-side rewrite proxy, so API calls go // directly to FastAPI at the same origin. FastAPI routes: /reset /step /state const BASE = ""; export async function fetchState(): Promise { const res = await fetch(`${BASE}/state`, { cache: "no-store" }); if (!res.ok) throw new Error(`GET /state → ${res.status}`); return res.json(); } export async function postReset(task: TaskDifficulty = "easy"): Promise { const res = await fetch(`${BASE}/reset`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ task }), }); if (!res.ok) throw new Error(`POST /reset → ${res.status}`); return res.json(); } export async function postStep(action: AEPOAction): Promise { const res = await fetch(`${BASE}/step`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ action }), }); if (!res.ok) throw new Error(`POST /step → ${res.status}`); return res.json(); }