From 5d2bd11463b9262598931dc109e7066ed94d4d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Br=C3=A5then=20Nomerstad?= Date: Wed, 8 Nov 2023 08:58:35 +0100 Subject: [PATCH] Setter parameter for locale til idporten ved innlogging --- src/utils/login.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/utils/login.ts b/src/utils/login.ts index 10ab6458c..9056699b5 100644 --- a/src/utils/login.ts +++ b/src/utils/login.ts @@ -1,6 +1,20 @@ import { erNavDekoratoren } from './Environment'; import { MenuValue } from './meny-storage-utils'; import { Environment } from '../store/reducers/environment-duck'; +import { Locale } from 'store/reducers/language-duck'; + +type IdPortenLocale = 'nb' | 'nn' | 'en' | 'se'; + +const idPortenLocaleMap: Record = { + [Locale.BOKMAL]: 'nb', + [Locale.NYNORSK]: 'nn', + [Locale.SAMISK]: 'se', + [Locale.ENGELSK]: 'en', + [Locale.POLSK]: 'en', + [Locale.RUSSISK]: 'en', + [Locale.UKRAINSK]: 'en', + [Locale.IKKEBESTEMT]: 'nb', +}; const getRedirectUrlLogin = (environment: Environment, arbeidsflate: MenuValue) => { const { MIN_SIDE_URL, MINSIDE_ARBEIDSGIVER_URL, PARAMS } = environment; @@ -29,11 +43,12 @@ const getRedirectUrlLogin = (environment: Environment, arbeidsflate: MenuValue) export const getLoginUrl = (environment: Environment, arbeidsflate: MenuValue, level?: string) => { const { LOGIN_URL, PARAMS } = environment; - const { LEVEL } = PARAMS; + const { LEVEL, LANGUAGE } = PARAMS; const redirectUrl = getRedirectUrlLogin(environment, arbeidsflate); + const idPortenLocale = idPortenLocaleMap[LANGUAGE]; - return `${LOGIN_URL}?redirect=${redirectUrl}&level=${level || LEVEL}`; + return `${LOGIN_URL}?redirect=${redirectUrl}&level=${level || LEVEL}&locale=${idPortenLocale}`; }; export const getLogOutUrl = (environment: Environment) => {