From aed0a36114a7cca95dedd144437e81b8370a1a0a Mon Sep 17 00:00:00 2001 From: Thisyahlen Date: Fri, 20 Sep 2024 10:33:20 +0800 Subject: [PATCH] chore: fix undefined length --- src/hooks/useIsOAuth2Enabled.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/useIsOAuth2Enabled.ts b/src/hooks/useIsOAuth2Enabled.ts index ff44d6a..3350f9f 100644 --- a/src/hooks/useIsOAuth2Enabled.ts +++ b/src/hooks/useIsOAuth2Enabled.ts @@ -12,7 +12,7 @@ type hydraBEApps = { * @returns {boolean} - a boolean indicating whether OAuth2 is enabled for the current app id */ export const useIsOAuth2Enabled = ( - OAuth2EnabledApps: hydraBEApps[], + OAuth2EnabledApps: hydraBEApps[] = [], OAuth2EnabledAppsInitialised: boolean ): boolean => { const [isOAuth2Enabled, setIsOAuth2Enabled] = useState(false); @@ -20,7 +20,7 @@ export const useIsOAuth2Enabled = ( useEffect(() => { if (OAuth2EnabledAppsInitialised) { - const FEHydraAppIds = OAuth2EnabledApps.length + const FEHydraAppIds = OAuth2EnabledApps?.length ? (OAuth2EnabledApps[OAuth2EnabledApps.length - 1]?.enabled_for ?? []) : []; setIsOAuth2Enabled(FEHydraAppIds.includes(+(appId as string)));