Correcting demo data import and the button interaction

This commit is contained in:
Christbru 2025-10-19 08:24:07 -05:00
commit 3fc2beed58
2 changed files with 51 additions and 9 deletions

View file

@ -17,7 +17,10 @@ export default function ChatHeader({ title = "Title of Chat" }) {
setIngesting(true);
const res = await fetch("/api/files/import-demo", { method: "POST" });
const json = await res.json().catch(() => ({}));
setToast(`Imported: ${json.imported ?? "?"}, Skipped: ${json.skipped ?? "?"}`);
const imported = json.imported ?? "?";
const skipped = json.skipped ?? "?";
const summary = `Imported: ${imported}, Skipped: ${skipped}`;
setToast(json.error ? `${summary} - ${json.error}` : summary);
setTimeout(() => setToast(""), 4000);
} catch (e) {
setToast("Import failed");