"use client"; import { toast } from "sonner"; async function post(url: string): Promise { const res = await fetch(url, { method: "POST" }); if (res.ok) return true; const body = await res.json().catch(() => ({})); toast.error(body.error?.message ?? `Request failed (${res.status})`); return false; } export async function startDownload(modelId: string) { if (await post(`/api/models/${modelId}/download`)) toast.success("Download queued"); } export async function cancelJob(jobId: string) { if (await post(`/api/jobs/${jobId}/cancel`)) toast.info("Cancelling…"); }