Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
b2ffbba1bc
commit
62310e462f
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user