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:
21
front/src/providers/clientConfig/ClientConfigProvider.tsx
Normal file
21
front/src/providers/clientConfig/ClientConfigProvider.tsx
Normal 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}</>;
|
||||
};
|
||||
Reference in New Issue
Block a user