Skip to content

Commit

Permalink
feat: auth page
Browse files Browse the repository at this point in the history
  • Loading branch information
Nilumilak committed Dec 17, 2024
1 parent 92b7db6 commit 8e78c51
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
4 changes: 3 additions & 1 deletion frontend/src/components/AuthPage/AuthPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ function AuthPage() {
return (
<S.AuthPageStyled>
<Header />
{data && <SignIn appAuthenticationSettings={data} />}
{data && (
<SignIn authType={data.authType} oAuthProviders={data.oAuthProviders} />
)}
</S.AuthPageStyled>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function BasicSignIn() {
methods.setError('root', { message: 'error' });
} else {
navigate('/');
window.location.reload();
}
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function AuthCard({ serviceName, authPath, Icon = ServiceImage }: Props) {
<S.ServiceButton
buttonSize="L"
buttonType="primary"
to={`http://localhost:8080${authPath}`}
to={`${window.basePath}${authPath}`}
>
Log in with {serviceName}
</S.ServiceButton>
Expand Down
9 changes: 4 additions & 5 deletions frontend/src/components/AuthPage/SignIn/SignIn.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<S.SignInStyled>
<S.SignInTitle>Sign in</S.SignInTitle>
Expand Down
20 changes: 12 additions & 8 deletions frontend/src/components/contexts/GlobalSettingsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,24 @@ export const GlobalSettingsProvider: React.FC<
> = ({ children }) => {
const info = useAppInfo();
const navigate = useNavigate();
const [value, setValue] = React.useState<GlobalSettingsContextProps>({
hasDynamicConfig: false,
});

React.useEffect(() => {
if (info.data?.raw.url.includes('auth')) {

Check failure on line 25 in frontend/src/components/contexts/GlobalSettingsContext.tsx

View workflow job for this annotation

GitHub Actions / build / build-and-test

App › Renders navigation

TypeError: Cannot read properties of undefined (reading 'url') at raw (src/components/contexts/GlobalSettingsContext.tsx:25:20) at commitHookEffectListMount (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:23150:26) at commitPassiveMountOnFiber (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:24931:11) at commitPassiveMountEffects_complete (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:24891:9) at commitPassiveMountEffects_begin (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:24878:7) at commitPassiveMountEffects (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:24866:3) at flushPassiveEffectsImpl (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:27039:3) at flushPassiveEffects (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:26984:14) at node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:26769:9 at flushActQueue (node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.development.js:2667:24) at act (node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.development.js:2582:11) at node_modules/.pnpm/@testing-library[email protected][email protected][email protected][email protected]/node_modules/@testing-library/react/dist/act-compat.js:47:25 at renderRoot (node_modules/.pnpm/@testing-library[email protected][email protected][email protected][email protected]/node_modules/@testing-library/react/dist/pure.js:180:26) at render (node_modules/.pnpm/@testing-library[email protected][email protected][email protected][email protected]/node_modules/@testing-library/react/dist/pure.js:271:10) at customRender (src/lib/testHelpers.tsx:136:16) at Object.<anonymous> (src/components/__tests__/App.spec.tsx:30:11)

Check failure on line 25 in frontend/src/components/contexts/GlobalSettingsContext.tsx

View workflow job for this annotation

GitHub Actions / build / build-and-test

App › Renders NavBar

TypeError: Cannot read properties of undefined (reading 'url') at raw (src/components/contexts/GlobalSettingsContext.tsx:25:20) at commitHookEffectListMount (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:23150:26) at commitPassiveMountOnFiber (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:24931:11) at commitPassiveMountEffects_complete (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:24891:9) at commitPassiveMountEffects_begin (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:24878:7) at commitPassiveMountEffects (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:24866:3) at flushPassiveEffectsImpl (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:27039:3) at flushPassiveEffects (node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:26984:14) at node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.development.js:26769:9 at flushActQueue (node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.development.js:2667:24) at act (node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.development.js:2582:11) at node_modules/.pnpm/@testing-library[email protected][email protected][email protected][email protected]/node_modules/@testing-library/react/dist/act-compat.js:47:25 at renderRoot (node_modules/.pnpm/@testing-library[email protected][email protected][email protected][email protected]/node_modules/@testing-library/react/dist/pure.js:180:26) at render (node_modules/.pnpm/@testing-library[email protected][email protected][email protected][email protected]/node_modules/@testing-library/react/dist/pure.js:271:10) at customRender (src/lib/testHelpers.tsx:136:16) at Object.<anonymous> (src/components/__tests__/App.spec.tsx:30:11)
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 (
Expand Down

0 comments on commit 8e78c51

Please sign in to comment.