diff --git a/src/hooks/settingsHooks/useGetSettings.ts b/src/hooks/settingsHooks/useGetSettings.ts index bc1b1fb258..0c726c51dc 100644 --- a/src/hooks/settingsHooks/useGetSettings.ts +++ b/src/hooks/settingsHooks/useGetSettings.ts @@ -127,17 +127,25 @@ const extractPassword = ( } export const useGetSettings = ( - siteName: string + siteName: string, + isEmailLogin?: boolean ): UseQueryResult => { + const shouldGetPrivacyDetails = + isEmailLogin === undefined ? false : isEmailLogin return useQuery( - [SETTINGS_CONTENT_KEY, siteName], + [SETTINGS_CONTENT_KEY, siteName, shouldGetPrivacyDetails], async () => { const siteSettings = await SettingsService.get({ siteName }) - // TODO: reimplement actual functionality once netlify issue resolved - // const passwordSettings = await SettingsService.getPassword({ siteName }) - const passwordSettings = { - isAmplifySite: false, - password: "", + let passwordSettings + const isLaunchDarklyImplemented = false + if (shouldGetPrivacyDetails && isLaunchDarklyImplemented) { + // TODO: LaunchDarkly to allow specific groups to access this feature first + passwordSettings = await SettingsService.getPassword({ siteName }) + } else { + passwordSettings = { + isAmplifySite: false, + password: "", + } } const convertedSettings = convertFromBe(siteSettings) const parsedPassword = extractPassword(passwordSettings) diff --git a/src/layouts/Settings/Settings.tsx b/src/layouts/Settings/Settings.tsx index 01dab29141..d7d530aee5 100644 --- a/src/layouts/Settings/Settings.tsx +++ b/src/layouts/Settings/Settings.tsx @@ -14,6 +14,8 @@ import { useEffect, useRef } from "react" import { useForm, FormProvider } from "react-hook-form" import { useParams } from "react-router-dom" +import { useLoginContext } from "contexts/LoginContext" + import { useGetSettings, useUpdateSettings } from "hooks/settingsHooks" import { useErrorToast, useSuccessToast } from "utils/toasts" @@ -34,11 +36,13 @@ import { SocialMediaSettings } from "./SocialMediaSettings" export const Settings = (): JSX.Element => { const { siteName } = useParams<{ siteName: string }>() + const { userId } = useLoginContext() + const isGithubUser = userId !== "Unknown user" && !!userId const { data: settingsData, isLoading: isGetSettingsLoading, isError: isGetSettingsError, - } = useGetSettings(siteName) + } = useGetSettings(siteName, !isGithubUser) const errorToast = useErrorToast() // Trigger an error toast informing the user if settings data could not be fetched