Skip to content

Commit

Permalink
feat: add language cookie for handler and enforce FI
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast committed Nov 19, 2024
1 parent c4a7df7 commit d77139d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
6 changes: 6 additions & 0 deletions backend/benefit/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,12 @@ msgstr ""
msgid "Handler is not allowed to do this action"
msgstr ""

msgid "Handling comment"
msgstr ""

msgid "Manual calculation comment"
msgstr ""

msgid "Only the terms currently in effect can be approved"
msgstr ""

Expand Down
6 changes: 6 additions & 0 deletions backend/benefit/locale/fi/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,12 @@ msgstr "Hakija ei saa tehdä tätä toimenpidettä"
msgid "Handler is not allowed to do this action"
msgstr "Käsittelijä ei saa tehdä tätä toimenpidettä"

msgid "Handling comment"
msgstr "Käsittelyn perustelu"

msgid "Manual calculation comment"
msgstr "Manuaalisen laskelman perustelu"

msgid "Only the terms currently in effect can be approved"
msgstr "Vain voimassa olevat ehdot voidaan hyväksyä"

Expand Down
6 changes: 6 additions & 0 deletions backend/benefit/locale/sv/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,12 @@ msgstr "Sökande får inte utföra denna åtgärd"
msgid "Handler is not allowed to do this action"
msgstr "Handläggare får inte utföra denna åtgärd"

msgid "Handling comment"
msgstr ""

msgid "Manual calculation comment"
msgstr ""

msgid "Only the terms currently in effect can be approved"
msgstr "Endast de villkor som för tillfället gäller kan godkännas"

Expand Down
6 changes: 1 addition & 5 deletions backend/benefit/users/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ def get(self, request):
lang = request.GET.get("lang")

if lang in ["fi", "en", "sv"]:
token = request.COOKIES.get("yjdhcsrftoken")

response = Response(
{"lang": lang, "token": token}, status=status.HTTP_200_OK
)
response = Response({"lang": lang}, status=status.HTTP_200_OK)
response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang, httponly=True)
return response

Expand Down
20 changes: 18 additions & 2 deletions frontend/benefit/handler/src/components/header/useHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
import axios from 'axios';
import NumberTag from 'benefit/handler/components/header/NumberTag';
import { ROUTES } from 'benefit/handler/constants';
import { ROUTES, SUPPORTED_LANGUAGES } from 'benefit/handler/constants';
import AppContext from 'benefit/handler/context/AppContext';
import useApplicationAlterationsQuery from 'benefit/handler/hooks/useApplicationAlterationsQuery';
import { useDetermineAhjoMode } from 'benefit/handler/hooks/useDetermineAhjoMode';
import {
BackendEndpoint,
getBackendDomain,
} from 'benefit-shared/backend-api/backend-api';
import { useRouter } from 'next/router';
import { TFunction, useTranslation } from 'next-i18next';
import React from 'react';
import React, { useEffect } from 'react';
import { NavigationItem, OptionType } from 'shared/types/common';
import { getLanguageOptions } from 'shared/utils/common';

const setLanguageToFinnish = (): void => {
const optionsEndpoint = `${getBackendDomain()}/${
BackendEndpoint.USER_OPTIONS
}`;
void axios.get(optionsEndpoint, {
params: { lang: SUPPORTED_LANGUAGES.FI },
});
};

type ExtendedComponentProps = {
t: TFunction;
languageOptions: OptionType<string>[];
Expand All @@ -33,6 +47,8 @@ const useHeader = (): ExtendedComponentProps => {
[t]
);

useEffect(setLanguageToFinnish, []);

const { data: alterationData, isLoading: isAlterationListLoading } =
useApplicationAlterationsQuery();

Expand Down

0 comments on commit d77139d

Please sign in to comment.