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

Endre lenke fra to the front page til engelsk forside #1506

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions src/komponenter/common/arbeidsflate-lenker/arbeidsflate-lenker.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Locale } from 'store/reducers/language-duck';
import { LangKey } from 'tekster/ledetekster';
import { MenuValue } from 'utils/meny-storage-utils';

Expand All @@ -8,42 +9,50 @@ export interface ArbeidsflateLenke {
key: MenuValue;
}

export const arbeidsflateLenker = (XP_BASE_URL: string): ArbeidsflateLenke[] => [
personContextLenke(XP_BASE_URL),
arbeidsgiverContextLenke(XP_BASE_URL),
samarbeidspartnerContextLenke(XP_BASE_URL),
const erNorsk = (language: Locale) => {
return language === Locale.BOKMAL || language === Locale.NYNORSK || language === Locale.SAMISK;
};

export const arbeidsflateLenker = (XP_BASE_URL: string, language: Locale): ArbeidsflateLenke[] => [
personContextLenke(XP_BASE_URL, language),
arbeidsgiverContextLenke(XP_BASE_URL, language),
samarbeidspartnerContextLenke(XP_BASE_URL, language),
];

export const personContextLenke = (XP_BASE_URL: string): ArbeidsflateLenke => {
export const personContextLenke = (XP_BASE_URL: string, language: Locale): ArbeidsflateLenke => {
const url = erNorsk(language) ? `${XP_BASE_URL}` : `${XP_BASE_URL}/en/`;
return {
url: `${XP_BASE_URL}`,
url,
lenkeTekstId: 'rolle-privatperson',
stikkordId: 'meny-bunnlenke-minside-stikkord',
key: MenuValue.PRIVATPERSON,
};
};

export const arbeidsgiverContextLenke = (XP_BASE_URL: string): ArbeidsflateLenke => {
export const arbeidsgiverContextLenke = (XP_BASE_URL: string, language: Locale): ArbeidsflateLenke => {
const url = erNorsk(language) ? `${XP_BASE_URL}/no/bedrift` : `${XP_BASE_URL}/en/`;
return {
url: `${XP_BASE_URL}/no/bedrift`,
url,
lenkeTekstId: 'rolle-arbeidsgiver',
stikkordId: 'meny-bunnlenke-arbeidsgiver-stikkord',
key: MenuValue.ARBEIDSGIVER,
};
};

export const samarbeidspartnerContextLenke = (XP_BASE_URL: string): ArbeidsflateLenke => {
export const samarbeidspartnerContextLenke = (XP_BASE_URL: string, language: Locale): ArbeidsflateLenke => {
const url = erNorsk(language) ? `${XP_BASE_URL}/no/samarbeidspartner` : `${XP_BASE_URL}/en/`;
return {
url: `${XP_BASE_URL}/no/samarbeidspartner`,
url,
lenkeTekstId: 'rolle-samarbeidspartner',
stikkordId: 'meny-bunnlenke-samarbeidspartner-stikkord',
key: MenuValue.SAMARBEIDSPARTNER,
};
};

export const getArbeidsflateContext = (XP_BASE_URL: string, arbeidsflate: MenuValue) =>
arbeidsflate === MenuValue.ARBEIDSGIVER
? arbeidsgiverContextLenke(XP_BASE_URL)
export const getArbeidsflateContext = (XP_BASE_URL: string, arbeidsflate: MenuValue, language: Locale) => {
return arbeidsflate === MenuValue.ARBEIDSGIVER
? arbeidsgiverContextLenke(XP_BASE_URL, language)
: arbeidsflate === MenuValue.SAMARBEIDSPARTNER
? samarbeidspartnerContextLenke(XP_BASE_URL)
: personContextLenke(XP_BASE_URL);
? samarbeidspartnerContextLenke(XP_BASE_URL, language)
: personContextLenke(XP_BASE_URL, language);
};
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 @@ -34,7 +34,7 @@ const Arbeidsflatemeny = () => {
return (
<div className={'arbeidsflate'} id={'arbeidsflate'}>
<ul className={style.toppListeRad} aria-label="Velg brukergruppe">
{arbeidsflateLenker(XP_BASE_URL).map((lenke, index) => {
{arbeidsflateLenker(XP_BASE_URL, language).map((lenke, index) => {
return (
<li className={style.listeElement} key={lenke.key}>
<LenkeMedSporing
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 @@ -21,16 +21,16 @@ export const Toppseksjon = () => {
const [, setCookie] = useCookies([CookieName.DECORATOR_CONTEXT]);
const { XP_BASE_URL } = useSelector((state: AppState) => state.environment);
const arbeidsflate = useSelector((state: AppState) => state.arbeidsflate.status);
const context = getArbeidsflateContext(XP_BASE_URL, arbeidsflate);

const { language } = useSelector((state: AppState) => state.language);
const context = getArbeidsflateContext(XP_BASE_URL, arbeidsflate, language);
return (
<div className={style.toppSeksjon} data-testid={'toppseksjon'}>
<Heading level="2" size="medium" className={style.toppSeksjonTittel}>
<Tekst
id={
arbeidsflate === MenuValue.PRIVATPERSON
? 'how-can-we-help'
: `rolle-${arbeidsflate.toLowerCase()}` as LangKey
: (`rolle-${arbeidsflate.toLowerCase()}` as LangKey)
}
/>
</Heading>
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