mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(site): select default organization on /organizations page (#13992)
This commit is contained in:
@@ -61,10 +61,11 @@ export const ManagementSettingsLayout: FC = () => {
|
||||
currentOrganizationId: !inOrganizationSettings
|
||||
? undefined
|
||||
: !organization
|
||||
? "00000000-0000-0000-0000-000000000000"
|
||||
: organizationsQuery.data.find(
|
||||
(org) => org.name === organization,
|
||||
)?.id,
|
||||
? getOrganizationIdByDefault(organizationsQuery.data)
|
||||
: getOrganizationIdByName(
|
||||
organizationsQuery.data,
|
||||
organization,
|
||||
),
|
||||
organizations: organizationsQuery.data,
|
||||
}}
|
||||
>
|
||||
@@ -93,3 +94,9 @@ export const ManagementSettingsLayout: FC = () => {
|
||||
</RequirePermission>
|
||||
);
|
||||
};
|
||||
|
||||
const getOrganizationIdByName = (organizations: Organization[], name: string) =>
|
||||
organizations.find((org) => org.name === name)?.id;
|
||||
|
||||
const getOrganizationIdByDefault = (organizations: Organization[]) =>
|
||||
organizations.find((org) => org.is_default)?.id;
|
||||
|
||||
Reference in New Issue
Block a user