diff --git a/frontend/packages/akr/package.json b/frontend/packages/akr/package.json index e5b3a7b43..1a95bc311 100644 --- a/frontend/packages/akr/package.json +++ b/frontend/packages/akr/package.json @@ -22,6 +22,6 @@ "akr:tslint": "yarn g:tsc --pretty --noEmit" }, "dependencies": { - "shared": "npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.10.0" + "shared": "npm:@opetushallitus/kieli-ja-kaantajatutkinnot.shared@1.10.2" } } diff --git a/frontend/packages/akr/src/components/common/AkrLangSelector.tsx b/frontend/packages/akr/src/components/common/AkrLangSelector.tsx new file mode 100644 index 000000000..2b1b448ff --- /dev/null +++ b/frontend/packages/akr/src/components/common/AkrLangSelector.tsx @@ -0,0 +1,32 @@ +import { LangSelector } from 'shared/components'; +import { AppLanguage } from 'shared/enums'; + +import { + changeLang, + getCurrentLang, + getSupportedLangs, + useAppTranslation, +} from 'configs/i18n'; + +export const AkrLangSelector = ({ usage }: { usage: 'dialog' | 'header' }) => { + const { t } = useAppTranslation({ + keyPrefix: 'akr.component.header', + }); + const [finnish, swedish, english] = getSupportedLangs(); + + const langDict = new Map([ + [t('lang.fi'), finnish], + [t('lang.sv'), swedish], + [t('lang.en'), english], + ]); + + return ( + + ); +}; diff --git a/frontend/packages/akr/src/components/layouts/Header.tsx b/frontend/packages/akr/src/components/layouts/Header.tsx index 45dbbc485..2ccfd9670 100644 --- a/frontend/packages/akr/src/components/layouts/Header.tsx +++ b/frontend/packages/akr/src/components/layouts/Header.tsx @@ -1,20 +1,14 @@ import { AppBar, Toolbar } from '@mui/material'; import { Link } from 'react-router-dom'; -import { - LangSelector, - OPHClerkLogo, - OPHLogoViewer, - SkipLink, -} from 'shared/components'; -import { AppLanguage, Direction } from 'shared/enums'; +import { OPHClerkLogo, OPHLogoViewer, SkipLink } from 'shared/components'; +import { Direction } from 'shared/enums'; import { useWindowProperties } from 'shared/hooks'; +import { AkrLangSelector } from 'components/common/AkrLangSelector'; import { ClerkNavTabs } from 'components/layouts//clerkHeader/ClerkNavTabs'; import { ClerkHeaderButtons } from 'components/layouts/clerkHeader/ClerkHeaderButtons'; import { - changeLang, getCurrentLang, - getSupportedLangs, useAppTranslation, useCommonTranslation, } from 'configs/i18n'; @@ -26,13 +20,6 @@ export const Header = (): JSX.Element => { keyPrefix: 'akr.component.header', }); const translateCommon = useCommonTranslation(); - const [finnish, swedish, english] = getSupportedLangs(); - - const langDict = new Map([ - [t('lang.fi'), finnish], - [t('lang.sv'), swedish], - [t('lang.en'), english], - ]); const { isPhone } = useWindowProperties(); const { isAuthenticated, isClerkUI } = useAuthentication(); @@ -46,12 +33,7 @@ export const Header = (): JSX.Element => { {isPhone && ( - + )} @@ -79,14 +61,7 @@ export const Header = (): JSX.Element => {
{isAuthenticated && } - {!isPhone && ( - - )} + {!isPhone && }
diff --git a/frontend/packages/akr/src/pages/PublicHomePage.tsx b/frontend/packages/akr/src/pages/PublicHomePage.tsx index 7b242eafd..083319b99 100644 --- a/frontend/packages/akr/src/pages/PublicHomePage.tsx +++ b/frontend/packages/akr/src/pages/PublicHomePage.tsx @@ -2,6 +2,7 @@ import { Box, Grid } from '@mui/material'; import { FC, useEffect } from 'react'; import { CookieBanner, Text } from 'shared/components'; +import { AkrLangSelector } from 'components/common/AkrLangSelector'; import { PublicTranslatorGrid } from 'components/publicTranslator/PublicTranslatorGrid'; import { useAppTranslation } from 'configs/i18n'; import { useAppDispatch, useAppSelector } from 'configs/redux'; @@ -30,6 +31,7 @@ export const PublicHomePage: FC = () => { cookieTag="cookie-consent-akr" buttonAriaLabel={t('buttonAriaLabel')} path="/akr" + languageSelector={} > {t('description')} diff --git a/frontend/packages/akr/src/tests/jest/components/layouts/__snapshots__/Header.test.tsx.snap b/frontend/packages/akr/src/tests/jest/components/layouts/__snapshots__/Header.test.tsx.snap index 609bd3bdd..0bb11f366 100644 --- a/frontend/packages/akr/src/tests/jest/components/layouts/__snapshots__/Header.test.tsx.snap +++ b/frontend/packages/akr/src/tests/jest/components/layouts/__snapshots__/Header.test.tsx.snap @@ -3,7 +3,7 @@ exports[`Header should render Header correctly 1`] = ` Array [