"use client"; import { toast } from "sonner"; async function call(url: string, method: string, body?: unknown): Promise { const res = await fetch(url, { method, ...(body ? { headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) } : {}) }); if (res.ok) return true; const json = await res.json().catch(() => ({})); toast.error(json.error?.message ?? `Request failed (${res.status})`); return false; } export const cancelBenchmark = (id: string) => call(`/api/benchmarks/${id}/cancel`, "POST"); export const deleteBenchmark = (id: string) => call(`/api/benchmarks/${id}`, "DELETE"); export const renameBenchmark = (id: string, label: string | null) => call(`/api/benchmarks/${id}`, "PATCH", { label });