Skip to content

Commit

Permalink
Merge pull request #1089 from divyanshu-patil/main
Browse files Browse the repository at this point in the history
fix: #1088 Uncaught TypeError: Cannot read properties of undefined (reading 'uniqueId')
  • Loading branch information
paustint authored Nov 23, 2024
2 parents dc4a724 + ee306af commit bf8f822
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libs/features/organizations/src/lib/OrganizationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,15 @@ export function Organizations() {
(organization?: Maybe<JetstreamOrganizationWithOrgs>) => {
setActiveOrganizationId(organization?.id);
if (organization && (!selectedOrg || !organization.orgs.find(({ uniqueId }) => uniqueId === selectedOrg.uniqueId))) {
setSelectedOrgId(organization.orgs[0].uniqueId);
const firstOrgUniqueId = organization.orgs?.[0]?.uniqueId || null;
setSelectedOrgId(firstOrgUniqueId);
} else if (!organization && (!selectedOrg || selectedOrg.jetstreamOrganizationId != null)) {
const orgsWithNoOrganization = allOrgs.filter(({ jetstreamOrganizationId }) => !jetstreamOrganizationId);
setSelectedOrgId(orgsWithNoOrganization[0].uniqueId);
const firstUnassignedOrgId = orgsWithNoOrganization?.[0]?.uniqueId || null;
setSelectedOrgId(firstUnassignedOrgId);
}
},

},
[allOrgs, selectedOrg, setActiveOrganizationId, setSelectedOrgId]
);

Expand Down

0 comments on commit bf8f822

Please sign in to comment.