diff --git a/src/routes/settings.import.tsx b/src/routes/settings.import.tsx index a9c64a5..31b4de7 100644 --- a/src/routes/settings.import.tsx +++ b/src/routes/settings.import.tsx @@ -930,6 +930,33 @@ function ImportPage() { const summary = { total: rawRows.length, inserted, skipped, errors, skipReasons }; setResults((r) => ({ ...r, [cfg.key]: summary })); + + // Persist run history (best-effort) + const runRow = { + importer_key: cfg.key, + total: rawRows.length, + inserted, + skipped, + error_count: errors.length, + ran_by: user.id, + }; + void supabase.from("import_runs" as any).insert(runRow as any).then(({ error: runErr }) => { + if (runErr) { + console.warn("[import] failed to record run", runErr); + return; + } + setLastRuns((prev) => ({ + ...prev, + [cfg.key]: { + ran_at: new Date().toISOString(), + total: rawRows.length, + inserted, + skipped, + error_count: errors.length, + }, + })); + }); + if (errors.length === 0) { const extra = mirrored > 0 ? ` (+${mirrored} mirrored to Clients)` : ""; toast.success(`${cfg.label}: ${inserted} imported${extra}`);