Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Oppdatert flere filer med language
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindskifjeld committed Nov 7, 2023
1 parent 6e8fa7d commit 2fd0bbc
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Locale, languageDuck } from 'store/reducers/language-duck';
import { Locale } from 'store/reducers/language-duck';
import { LangKey } from 'tekster/ledetekster';
import { MenuValue } from 'utils/meny-storage-utils';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Locale } from 'store/reducers/language-duck';
import { MenuValue } from 'utils/meny-storage-utils';
import { arbeidsgiverContextLenke, personContextLenke, samarbeidspartnerContextLenke } from './arbeidsflate-lenker';
import { Environment } from 'store/reducers/environment-duck';
Expand All @@ -22,33 +23,33 @@ export const dittNavLenkeData = (url: string): ArbeidsflateLenkeData => ({
key: MenuValue.PRIVATPERSON,
});

const privatpersonLenker = (env: Environment): ArbeidsflateLenkeData[] => [
const privatpersonLenker = (env: Environment, language: Locale): ArbeidsflateLenkeData[] => [
dittNavLenkeData(env.MIN_SIDE_URL),
arbeidsgiverContextLenke(env.XP_BASE_URL),
samarbeidspartnerContextLenke(env.XP_BASE_URL),
arbeidsgiverContextLenke(env.XP_BASE_URL, language),
samarbeidspartnerContextLenke(env.XP_BASE_URL, language),
];

const arbeidsgiverLenker = (env: Environment): ArbeidsflateLenkeData[] => [
const arbeidsgiverLenker = (env: Environment, language: Locale): ArbeidsflateLenkeData[] => [
{
url: env.MINSIDE_ARBEIDSGIVER_URL + valgtbedrift(),
lenkeTekstId: 'arbeidsgiver-minside-lenke',
stikkordId: 'meny-bunnlenke-arbeidsgiver-stikkord',
key: MenuValue.ARBEIDSGIVER,
},
personContextLenke(env.XP_BASE_URL),
samarbeidspartnerContextLenke(env.XP_BASE_URL),
personContextLenke(env.XP_BASE_URL, language),
samarbeidspartnerContextLenke(env.XP_BASE_URL, language),
];

const samarbeidspartnerLenker = (env: Environment): ArbeidsflateLenkeData[] => [
personContextLenke(env.XP_BASE_URL),
arbeidsgiverContextLenke(env.XP_BASE_URL),
const samarbeidspartnerLenker = (env: Environment, language: Locale): ArbeidsflateLenkeData[] => [
personContextLenke(env.XP_BASE_URL, language),
arbeidsgiverContextLenke(env.XP_BASE_URL, language),
];

const IKKEBESTEMTLenker = (): ArbeidsflateLenkeData[] => [];

export const bunnLenker = (env: Environment) => ({
[MenuValue.PRIVATPERSON]: privatpersonLenker(env),
[MenuValue.ARBEIDSGIVER]: arbeidsgiverLenker(env),
[MenuValue.SAMARBEIDSPARTNER]: samarbeidspartnerLenker(env),
export const bunnLenker = (env: Environment, language: Locale) => ({
[MenuValue.PRIVATPERSON]: privatpersonLenker(env, language),
[MenuValue.ARBEIDSGIVER]: arbeidsgiverLenker(env, language),
[MenuValue.SAMARBEIDSPARTNER]: samarbeidspartnerLenker(env, language),
[MenuValue.IKKEBESTEMT]: IKKEBESTEMTLenker(),
});
2 changes: 1 addition & 1 deletion src/komponenter/common/nav-logo/NavLogoLenke.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const NavLogoLenke = (props: Props) => {
const [, setCookie] = useCookies([CookieName.DECORATOR_CONTEXT]);
const { XP_BASE_URL } = useSelector((state: AppState) => state.environment);
const { language } = useSelector((state: AppState) => state.language);
const context = getArbeidsflateContext(XP_BASE_URL, MenuValue.PRIVATPERSON);
const context = getArbeidsflateContext(XP_BASE_URL, MenuValue.PRIVATPERSON, language);

const url = getHomeUrl(XP_BASE_URL, language);

Expand Down
9 changes: 2 additions & 7 deletions src/komponenter/header/common/brodsmulesti/Brodsmulesti.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const Brodsmulesti = (props: Props) => {
const [showAll, setShowAll] = useState(false);
const { status } = useSelector((state: AppState) => state.arbeidsflate);
const { language } = useSelector((state: AppState) => state.language);
const context = getArbeidsflateContext(XP_BASE_URL, status);
const context = getArbeidsflateContext(XP_BASE_URL, status, language);
const { breadcrumbs } = props;

const homeUrl = getHomeUrl(XP_BASE_URL, language);
Expand All @@ -62,12 +62,7 @@ export const Brodsmulesti = (props: Props) => {
action: 'nav.no',
}}
>
<Home
className={style.iconHome}
title="Hjem-ikon"
titleId={'breadcrumb-home'}
aria-hidden
/>
<Home className={style.iconHome} title="Hjem-ikon" titleId={'breadcrumb-home'} aria-hidden />
<span>nav.no</span>
<Next
className={style.iconNext}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const HovedmenyInnholdSmall = ({
return null;
}

const arbeidsflateLenker = bunnLenker(environment)[arbeidsflate].filter((lenke) =>
const arbeidsflateLenker = bunnLenker(environment, language)[arbeidsflate].filter((lenke) =>
language !== Locale.BOKMAL && language !== Locale.NYNORSK ? !lenke.key : true
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface Props {

export const Bunnseksjon = ({ language, arbeidsflate }: Props) => {
const { environment } = useSelector((state: AppState) => state);
const lenker = bunnLenker(environment)[arbeidsflate] as ArbeidsflateLenke[];
const lenker = bunnLenker(environment, language)[arbeidsflate] as ArbeidsflateLenke[];

return (
<div className={style.bunnSeksjon} data-testid={'bunnseksjon'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export const MobilHovedmenyInnholdPrivat = ({ setUndermeny, hovedmenyLenker }: P
const [, setCookie] = useCookies();

const dittNavLenke = dittNavLenkeData(dittNavUrl);
const arbgiverLenke = arbeidsgiverContextLenke(xpBaseUrl);
const samarbeidspartnerLenke = samarbeidspartnerContextLenke(xpBaseUrl);
const arbgiverLenke = arbeidsgiverContextLenke(xpBaseUrl, language);
const samarbeidspartnerLenke = samarbeidspartnerContextLenke(xpBaseUrl, language);

const analyticsArgs = {
context: MenuValue.PRIVATPERSON,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Props = {

export const MobilArbeidsflateValg = ({ lang }: Props) => {
const { arbeidsflate, environment } = useSelector(stateProps);
const lenker = bunnLenker(environment)[arbeidsflate];
const lenker = bunnLenker(environment, lang)[arbeidsflate];

return (
<UnstyledList className={'mobilArbeidsflateValg'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { AppState } from 'store/reducers';
import { LenkeMedSporing } from 'komponenter/common/lenke-med-sporing/LenkeMedSporing';
import Tekst from 'tekster/finn-tekst';
import { AnalyticsCategory } from 'utils/analytics/analytics';

import 'komponenter/header/header-regular/mobil/meny/innhold/hovedmeny/header/MobilHovedmenyHeader.scss';
import { LangKey } from 'tekster/ledetekster';

Expand All @@ -17,8 +16,9 @@ const stateSelector = (state: AppState) => ({

export const MobilHovedmenyHeader = () => {
const { XP_BASE_URL, arbeidsflate } = useSelector(stateSelector);
const { language } = useSelector((state: AppState) => state.language);

const lenke = arbeidsflateLenker(XP_BASE_URL).find((item) => item.key === arbeidsflate);
const lenke = arbeidsflateLenker(XP_BASE_URL, language).find((item) => item.key === arbeidsflate);

const href = lenke?.url || 'https://www.nav.no';

Expand Down

0 comments on commit 2fd0bbc

Please sign in to comment.