From 8e78c51af035cf4a7d5f3920a5a5e676ce7dbfd8 Mon Sep 17 00:00:00 2001 From: Renat Kalimulin Date: Tue, 17 Dec 2024 20:10:08 +0300 Subject: [PATCH] feat: auth page --- frontend/src/components/AuthPage/AuthPage.tsx | 4 +++- .../SignIn/BasicSignIn/BasicSignIn.tsx | 1 + .../SignIn/OAuthSignIn/AuthCard/AuthCard.tsx | 2 +- .../src/components/AuthPage/SignIn/SignIn.tsx | 9 ++++----- .../contexts/GlobalSettingsContext.tsx | 20 +++++++++++-------- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/AuthPage/AuthPage.tsx b/frontend/src/components/AuthPage/AuthPage.tsx index a5ce93313..ceae3069a 100644 --- a/frontend/src/components/AuthPage/AuthPage.tsx +++ b/frontend/src/components/AuthPage/AuthPage.tsx @@ -11,7 +11,9 @@ function AuthPage() { return (
- {data && } + {data && ( + + )} ); } diff --git a/frontend/src/components/AuthPage/SignIn/BasicSignIn/BasicSignIn.tsx b/frontend/src/components/AuthPage/SignIn/BasicSignIn/BasicSignIn.tsx index 0bb6c8a75..6684dd2c7 100644 --- a/frontend/src/components/AuthPage/SignIn/BasicSignIn/BasicSignIn.tsx +++ b/frontend/src/components/AuthPage/SignIn/BasicSignIn/BasicSignIn.tsx @@ -27,6 +27,7 @@ function BasicSignIn() { methods.setError('root', { message: 'error' }); } else { navigate('/'); + window.location.reload(); } }, }); diff --git a/frontend/src/components/AuthPage/SignIn/OAuthSignIn/AuthCard/AuthCard.tsx b/frontend/src/components/AuthPage/SignIn/OAuthSignIn/AuthCard/AuthCard.tsx index fc1162039..065a2ab0c 100644 --- a/frontend/src/components/AuthPage/SignIn/OAuthSignIn/AuthCard/AuthCard.tsx +++ b/frontend/src/components/AuthPage/SignIn/OAuthSignIn/AuthCard/AuthCard.tsx @@ -24,7 +24,7 @@ function AuthCard({ serviceName, authPath, Icon = ServiceImage }: Props) { Log in with {serviceName} diff --git a/frontend/src/components/AuthPage/SignIn/SignIn.tsx b/frontend/src/components/AuthPage/SignIn/SignIn.tsx index 88c6e1df1..987ee5ebf 100644 --- a/frontend/src/components/AuthPage/SignIn/SignIn.tsx +++ b/frontend/src/components/AuthPage/SignIn/SignIn.tsx @@ -1,17 +1,16 @@ import React from 'react'; -import { AppAuthenticationSettings, AuthType } from 'generated-sources'; +import { AuthType, OAuthProvider } from 'generated-sources'; import BasicSignIn from './BasicSignIn/BasicSignIn'; import * as S from './SignIn.styled'; import OAuthSignIn from './OAuthSignIn/OAuthSignIn'; interface Props { - appAuthenticationSettings: AppAuthenticationSettings; + authType?: AuthType; + oAuthProviders?: OAuthProvider[]; } -function SignInForm({ appAuthenticationSettings }: Props) { - const { authType, oAuthProviders } = appAuthenticationSettings; - +function SignInForm({ authType, oAuthProviders }: Props) { return ( Sign in diff --git a/frontend/src/components/contexts/GlobalSettingsContext.tsx b/frontend/src/components/contexts/GlobalSettingsContext.tsx index bcf87841f..27fb25cb4 100644 --- a/frontend/src/components/contexts/GlobalSettingsContext.tsx +++ b/frontend/src/components/contexts/GlobalSettingsContext.tsx @@ -17,20 +17,24 @@ export const GlobalSettingsProvider: React.FC< > = ({ children }) => { const info = useAppInfo(); const navigate = useNavigate(); + const [value, setValue] = React.useState({ + hasDynamicConfig: false, + }); React.useEffect(() => { if (info.data?.raw.url.includes('auth')) { navigate('auth'); + return; } - }, []); - const value = React.useMemo(() => { - const features = info.data?.enabledFeatures || []; - return { - hasDynamicConfig: features.includes( - ApplicationInfoEnabledFeaturesEnum.DYNAMIC_CONFIG - ), - }; + info.data?.value().then((res) => { + const features = res?.enabledFeatures || []; + setValue({ + hasDynamicConfig: features.includes( + ApplicationInfoEnabledFeaturesEnum.DYNAMIC_CONFIG + ), + }); + }); }, [info.data]); return (