Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-19 00:34:37 +00:00
co-authored by renee-png
parent e1b34ef754
commit cc3aa5845a
+7 -5
View File
@@ -757,7 +757,9 @@ function ImportPage() {
errors.push(`Batch ${i / chunkSize + 1} (lookup): ${lookupError.message}`);
} else {
const existingByExternalId = new Map(
(existing ?? []).map((entry: { id: string; external_id: string | null }) => [entry.external_id, entry.id]),
((existing ?? []) as Array<{ id: string; external_id: string | null }>).map(
(entry) => [entry.external_id, entry.id] as [string | null, string],
),
);
const toUpdate: Array<Row & { id: string }> = withConflict
.filter((r) => existingByExternalId.has(String(r.external_id)))
@@ -768,7 +770,7 @@ function ImportPage() {
const updateResults = await Promise.all(
toUpdate.map(async (entry) => {
const { id, ...payload } = entry;
return supabase.from("time_entries").update(payload as any).eq("id", id).select("*").single();
return supabase.from(cfg.table as any).update(payload as any).eq("id", id).select("*").single();
}),
);
for (const result of updateResults) {
@@ -776,21 +778,21 @@ function ImportPage() {
errors.push(`Batch ${i / chunkSize + 1} (update): ${result.error.message}`);
} else if (result.data) {
inserted += 1;
inserted_rows.push(result.data);
inserted_rows.push(result.data as Row);
}
}
}
if (toInsert.length > 0) {
const { data, error } = await supabase
.from("time_entries")
.from(cfg.table as any)
.insert(toInsert as any)
.select("*");
if (error) {
errors.push(`Batch ${i / chunkSize + 1} (insert): ${error.message}`);
} else if (data) {
inserted += data.length;
inserted_rows.push(...data);
inserted_rows.push(...(data as Row[]));
}
}
}