"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…"); } export async function startVerify(modelId: string, deep: boolean) { if (await post(`/api/models/${modelId}/verify${deep ? "?deep=1" : ""}`)) toast.success(deep ? "Deep verify queued" : "Verify queued"); } export async function startRepair(modelId: string) { if (await post(`/api/models/${modelId}/repair`)) toast.success("Repair queued"); } export async function startUpdate(modelId: string): Promise { const ok = await post(`/api/models/${modelId}/update`); if (ok) toast.success("Update queued"); return ok; }