fix: Create a client config function that is retrieved when app is loading (#496)

* fix: Create a client config function that is retrieved when app is loaded

* update index.tsx

* fixed linter issues
This commit is contained in:
Deepak Singh
2023-07-05 03:58:59 +05:30
committed by GitHub
parent 41edcd81d8
commit 9c09da18db
9 changed files with 115 additions and 6 deletions

View File

@ -0,0 +1,21 @@
import { useEffect } from 'react';
import { useRecoilState } from 'recoil';
import { useFetchClientConfig } from '@/auth/hooks/useFetchClientConfig';
import { displayGoogleLogin } from '@/auth/states/displayGoogleLogin';
import { prefillLoginWithSeed } from '@/auth/states/prefillLoginWithSeed';
export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
children,
}) => {
const [, setDisplayGoogleLogin] = useRecoilState(displayGoogleLogin);
const [, setPrefillLoginWithSeed] = useRecoilState(prefillLoginWithSeed);
const clientConfig = useFetchClientConfig();
useEffect(() => {
setDisplayGoogleLogin(clientConfig?.display_google_login ?? true);
setPrefillLoginWithSeed(clientConfig?.prefill_login_with_seed ?? true);
}, [setDisplayGoogleLogin, setPrefillLoginWithSeed, clientConfig]);
return <>{children}</>;
};