"use client"; export async function uploadImport(file: File): Promise { const text = await file.text(); // validate JSON before upload for a clearer error try { JSON.parse(text); } catch { throw new Error("File is not valid JSON"); } const res = await fetch("/api/import", { method: "POST", headers: { "Content-Type": "application/json" }, body: text, }); if (!res.ok) throw new Error(`Import failed: ${await res.text()}`); }