fix: prevent "cannot read properties of undefined (reading 'map')" crash (#532)
This commit is contained in:
committed by
GitHub
Unverified
parent
925fbab86d
commit
11e28a2cfa
@@ -97,11 +97,14 @@ export function buildProviderListItems(
|
||||
vendors: ProviderVendorInfo[],
|
||||
defaultAccountId: string | null,
|
||||
): ProviderListItem[] {
|
||||
const vendorMap = new Map(vendors.map((vendor) => [vendor.id, vendor]));
|
||||
const statusMap = new Map(statuses.map((status) => [status.id, status]));
|
||||
const safeAccounts = accounts ?? [];
|
||||
const safeStatuses = statuses ?? [];
|
||||
const safeVendors = vendors ?? [];
|
||||
const vendorMap = new Map(safeVendors.map((vendor) => [vendor.id, vendor]));
|
||||
const statusMap = new Map(safeStatuses.map((status) => [status.id, status]));
|
||||
|
||||
if (accounts.length > 0) {
|
||||
return accounts
|
||||
if (safeAccounts.length > 0) {
|
||||
return safeAccounts
|
||||
.map((account) => ({
|
||||
account,
|
||||
vendor: vendorMap.get(account.vendorId),
|
||||
@@ -114,7 +117,7 @@ export function buildProviderListItems(
|
||||
});
|
||||
}
|
||||
|
||||
return statuses.map((status) => ({
|
||||
return safeStatuses.map((status) => ({
|
||||
account: legacyProviderToAccount(status),
|
||||
vendor: vendorMap.get(status.type),
|
||||
status,
|
||||
|
||||
Reference in New Issue
Block a user