fix(site): select default organization on /organizations page (#13992)

This commit is contained in:
Kayla Washburn-Love
2024-07-23 12:35:38 -06:00
committed by GitHub
parent a61c09e4dc
commit 0d453437de
@@ -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;