Skip to content

Commit 0d45343

Browse files
authored
fix(site): select default organization on /organizations page (#13992)
1 parent a61c09e commit 0d45343

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

site/src/pages/ManagementSettingsPage/ManagementSettingsLayout.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ export const ManagementSettingsLayout: FC = () => {
6161
currentOrganizationId: !inOrganizationSettings
6262
? undefined
6363
: !organization
64-
? "00000000-0000-0000-0000-000000000000"
65-
: organizationsQuery.data.find(
66-
(org) => org.name === organization,
67-
)?.id,
64+
? getOrganizationIdByDefault(organizationsQuery.data)
65+
: getOrganizationIdByName(
66+
organizationsQuery.data,
67+
organization,
68+
),
6869
organizations: organizationsQuery.data,
6970
}}
7071
>
@@ -93,3 +94,9 @@ export const ManagementSettingsLayout: FC = () => {
9394
</RequirePermission>
9495
);
9596
};
97+
98+
const getOrganizationIdByName = (organizations: Organization[], name: string) =>
99+
organizations.find((org) => org.name === name)?.id;
100+
101+
const getOrganizationIdByDefault = (organizations: Organization[]) =>
102+
organizations.find((org) => org.is_default)?.id;

0 commit comments

Comments
 (0)