This commit is contained in:
2026-04-05 00:43:23 +05:30
commit 8be37d3e92
425 changed files with 101853 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
// Thin API client for the negoT8 FastAPI backend
import type { Negotiation, Stats } from "./types";
const BASE = process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:8000";
async function get<T>(path: string): Promise<T> {
const res = await fetch(`${BASE}${path}`, { cache: "no-store" });
if (!res.ok) throw new Error(`GET ${path}${res.status}`);
return res.json() as Promise<T>;
}
export const api = {
stats: () => get<Stats>("/api/stats"),
negotiations: () =>
get<{ negotiations: Negotiation[]; total: number }>("/api/negotiations"),
negotiation: (id: string) => get<Negotiation>(`/api/negotiations/${id}`),
analytics: (id: string) =>
get<Negotiation["analytics"]>(`/api/negotiations/${id}/analytics`),
};