Skip to content

Commit

Permalink
FWF-3414 [bugfix] fixed default language selection (#2146)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuhaib-aot authored Jul 16, 2024
1 parent c7e914e commit 312711d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 5 additions & 3 deletions forms-flow-web/src/components/PrivateRoute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import {
import { AppConfig } from "../config";
import { getFormioRoleIds } from "../apiManager/services/userservices";
import AccessDenied from "./AccessDenied";
import { LANGUAGE } from "../constants/constants";

export const kcServiceInstance = (tenantId = null) => {
return KeycloakService.getInstance(
Expand Down Expand Up @@ -159,12 +160,13 @@ const PrivateRoute = React.memo((props) => {
}, [tenantId, props.store, dispatch]);

useEffect(() => {
if (kcInstance) {
if (kcInstance ) {
const lang =
kcInstance?.userData?.locale ||
tenant?.tenantData?.details?.locale ||
selectedLanguage;
dispatch(setLanguage(lang));
selectedLanguage ||
LANGUAGE;
dispatch(setLanguage(lang));
}
}, [kcInstance, tenant?.tenantData]);

Expand Down
3 changes: 1 addition & 2 deletions forms-flow-web/src/modules/userDetailReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
setShowApplications,
setUserRolesToObject,
} from "../helper/user";
import { LANGUAGE } from "../constants/constants";
import { setFormAndSubmissionAccess } from "../helper/access";

const getLanguages = localStorage.getItem("languages");
Expand All @@ -28,7 +27,7 @@ const initialState = {
isAuthenticated: false,
currentPage: "",
showApplications: false,
lang: localStorage.getItem("lang") ? localStorage.getItem("lang") : LANGUAGE,
lang: localStorage.getItem("lang") ? localStorage.getItem("lang") : null,
selectLanguages: getLanguages ? JSON.parse(getLanguages) : [],
defaultFilter: "",
};
Expand Down

0 comments on commit 312711d

Please sign in to comment.