diff --git a/src/components/import/GenerateTab.tsx b/src/components/import/GenerateTab.tsx
index 5b42b14..c2f58eb 100644
--- a/src/components/import/GenerateTab.tsx
+++ b/src/components/import/GenerateTab.tsx
@@ -6,6 +6,7 @@ export function GenerateTab({ importType }: { importType: "flashcards" | "quizze
const [instructions, setInstructions] = useState("");
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
+ const [saveResult, setSaveResult] = useState<"success" | "error" | null>(null);
const [copied, setCopied] = useState(false);
useEffect(() => {
@@ -17,14 +18,20 @@ export function GenerateTab({ importType }: { importType: "flashcards" | "quizze
async function handleSave() {
setSaving(true);
+ setSaveResult(null);
try {
- await fetch(`/api/settings/llm-instructions?type=${importType}`, {
+ const res = await fetch(`/api/settings/llm-instructions?type=${importType}`, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ value: instructions }),
});
+ if (!res.ok) throw new Error("Failed to save");
+ setSaveResult("success");
+ } catch {
+ setSaveResult("error");
} finally {
setSaving(false);
+ setTimeout(() => setSaveResult(null), 2500);
}
}
@@ -91,9 +98,23 @@ export function GenerateTab({ importType }: { importType: "flashcards" | "quizze