Skip to content

Commit

Permalink
fix: set preferred language in registration
Browse files Browse the repository at this point in the history
  • Loading branch information
janrembold committed Apr 24, 2024
1 parent d44fb00 commit 9c04d8b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/extensions/components/registration/Registration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import {
registrationSessionStorageKey,
RegistrationData,
NotificationsContext,
NOTIFICATION_TYPE_ERROR
NOTIFICATION_TYPE_ERROR,
LocaleContext
} from '../../../globalState';
import { GlobalComponentContext } from '../../../globalState/provider/GlobalComponentContext';
import {
Expand Down Expand Up @@ -83,6 +84,7 @@ export const Registration = () => {
} = useContext(RegistrationContext);
const { consultant: preselectedConsultant } = useContext(UrlParamsContext);
const { tenant } = useContext(TenantContext);
const { locale } = useContext(LocaleContext);

const [stepData, setStepData] = useState<Partial<RegistrationData>>({});
const [redirectOverlayActive, setRedirectOverlayActive] =
Expand Down Expand Up @@ -185,7 +187,7 @@ export const Registration = () => {
agencyId: registrationData.agency.id.toString(),
postcode: registrationData.zipcode,
termsAccepted: 'true',
preferredLanguage: 'de',
preferredLanguage: locale || 'de',
consultingType: registrationData.agency.consultingType,
...(preselectedConsultant
? { consultantId: preselectedConsultant?.consultantId }
Expand Down Expand Up @@ -222,7 +224,8 @@ export const Registration = () => {
settings.multitenancyWithSingleDomainEnabled,
tenant,
addNotification,
t
t,
locale
]);

const stepPaths = useMemo(
Expand Down
11 changes: 9 additions & 2 deletions src/globalState/provider/LocaleProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { useContext, useEffect, useMemo, useState } from 'react';
import i18n, { FALLBACK_LNG, init } from '../../i18n';
import { InformalContext } from './InformalProvider';
import { useAppConfig } from '../../hooks/useAppConfig';
import { setValueInCookie } from '../../components/sessionCookie/accessSessionCookie';
import {
getValueFromCookie,
setValueInCookie
} from '../../components/sessionCookie/accessSessionCookie';
import { useTenant } from './TenantProvider';
import useTenantTheming from '../../utils/useTenantTheming';
import { LocaleContext, TLocaleContext } from '../context/LocaleContext';
Expand All @@ -18,7 +21,11 @@ export function LocaleProvider(props) {
const [initLocale, setInitLocale] = useState(null);
const { informal } = useContext(InformalContext);
const [locales, setLocales] = useState([]);
const [locale, setLocale] = useState(null);
const [locale, setLocale] = useState(
getValueFromCookie('lang') ||
localStorage.getItem(STORAGE_KEY_LOCALE) ||
null
);

useEffect(() => {
// If using the tenant service we should load first the tenant because we need the
Expand Down

0 comments on commit 9c04d8b

Please sign in to comment.