Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-19 01:10:58 +00:00
co-authored by renee-png
parent b2ffbba1bc
commit 62310e462f
+24
View File
@@ -597,6 +597,30 @@ function ImportPage() {
.then(({ data }) => setClientList((data ?? []) as { id: string; name: string }[]));
}, []);
// Load latest import per category
useEffect(() => {
void (async () => {
const { data, error } = await supabase
.from("import_runs" as any)
.select("importer_key, ran_at, total, inserted, skipped, error_count")
.order("ran_at", { ascending: false });
if (error || !data) return;
const map: Record<string, LastRun> = {};
for (const row of data as any[]) {
if (!map[row.importer_key]) {
map[row.importer_key] = {
ran_at: row.ran_at,
total: row.total,
inserted: row.inserted,
skipped: row.skipped,
error_count: row.error_count,
};
}
}
setLastRuns(map);
})();
}, []);
// Pre-load lookup caches from existing rows so subsequent imports can join.
// Always reload (and paginate past Supabase's 1000-row default limit) so caches
// pick up rows added since the page mounted (e.g., from a prior CSV import).