Skip to content

Commit

Permalink
Merge pull request #2063 from shuhaib-aot/Feature/FWF-3320-set-lang-t…
Browse files Browse the repository at this point in the history
…o-develop

Feature/fwf 3320 set lang to develop and also bring changes from master
  • Loading branch information
shuhaib-aot authored May 23, 2024
2 parents 8837306 + e7e4d67 commit 33848bc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

Mark items as `Added`, `Changed`, `Fixed`, `Modified`, `Removed`, `Untested Features`, `Upcoming Features`, `Known Issues`

## 6.0.1 - 2024-05-16
## 6.0.1 - 2024-05-21

`Added`

**forms-flow-web-root-config**
* Added resouce bundle for Spanish

`Fixed`

**forms-flow-web-root-config**
* Fixed service worker cache issue

## 6.0.0 - 2024-04-05

`Added`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,7 @@ export const appState = {
isFormChecked: false,
isAllFormChecked: false,
},
tenants:{
tenantData: {}
}
};
15 changes: 14 additions & 1 deletion forms-flow-web/src/components/PrivateRoute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ const PrivateRoute = React.memo((props) => {
const userRoles = useSelector((state) => state.user.roles || []);
const { tenantId } = useParams();
const redirecUrl = MULTITENANCY_ENABLED ? `/tenant/${tenantId}/` : `/`;
const selectedLanguage = useSelector((state) => state.user.lang);
const tenant = useSelector((state) => state.tenants);

const [kcInstance, setKcInstance] = React.useState(getKcInstance());

Expand All @@ -85,7 +87,6 @@ const PrivateRoute = React.memo((props) => {
);
dispatch(setUserAuth(instance.isAuthenticated()));
store.dispatch(setUserToken(instance.getToken()));
store.dispatch(setLanguage(instance.getUserData()?.locale || "en"));
//Set Cammunda/Formio Base URL
setApiBaseUrlToLocalStorage();
// get formio roles
Expand Down Expand Up @@ -139,6 +140,18 @@ const PrivateRoute = React.memo((props) => {
}
}, [props.store, tenantId, dispatch]);

/**
* Retrieves the user's locale from the Keycloak instance or the tenant data, and dispatches an action to set the language in the application state.
* This effect is triggered whenever the Keycloak instance or the tenant data changes.
*/
useEffect(() => {
const lang =
kcInstance?.getInstance()?.getUserData().locale ||
tenant?.tenantData?.details?.locale ||
selectedLanguage;
dispatch(setLanguage(lang));
}, [kcInstance, tenant?.tenantData]);

// useMemo prevents unneccessary rerendering caused by the route update.

const DesignerRoute = useMemo(
Expand Down

0 comments on commit 33848bc

Please sign in to comment.