fix: react-doctor label-has-associated-control 9→0, async-await-in-loop 3→0 (Promise.allSettled), role-supports-aria-props 3→0 (already done in prior batch)

This commit is contained in:
Nora
2026-06-26 06:01:06 -06:00
parent ed5afe4b21
commit d6d6a366e3
7 changed files with 220 additions and 139 deletions
+39 -15
View File
@@ -340,15 +340,13 @@ await getSession(); const adminUser = await getAdminUser();
return { success: false, error: "Not authorized for this brand" };
}
const result: ImportResult = { created: 0, updated: 0, skipped: 0, errors: [] };
const validRows = params.contacts.filter(
(row) => row.email || row.phone,
);
for (const row of params.contacts) {
if (!row.email && !row.phone) {
result.skipped++;
continue;
}
try {
const r = await upsertContact({
const settled = await Promise.allSettled(
validRows.map((row) =>
upsertContact({
brand_id: params.brandId,
email: row.email,
phone: row.phone,
@@ -361,16 +359,42 @@ await getSession(); const adminUser = await getAdminUser();
external_id: row.external_id,
tags: row.tags,
metadata: row._metadata,
});
if (r.success) result.created++;
else {
result.errors.push({ row, error: r.error });
}
} catch (err) {
}).then(
(r) => ({ row, r }),
(err) => ({ row, err }),
),
),
);
const result: ImportResult = {
created: 0,
updated: 0,
skipped: params.contacts.length - validRows.length,
errors: [],
};
for (const entry of settled) {
if (entry.status === "rejected") {
const err = (entry as PromiseRejectedResult).reason;
result.errors.push({
row,
row: validRows[settled.indexOf(entry)],
error: err instanceof Error ? err.message : String(err),
});
continue;
}
const value = entry.value as
| { row: ContactImportEntry; r: { success: boolean; error?: string } }
| { row: ContactImportEntry; err: unknown };
if ("err" in value) {
const err = value.err;
result.errors.push({
row: value.row,
error: err instanceof Error ? err.message : String(err),
});
} else if (value.r.success) {
result.created++;
} else {
result.errors.push({ row: value.row, error: value.r.error ?? "Unknown error" });
}
}