Skip to content

Commit

Permalink
Loading the previous language is corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
YaswanthNagarjuna committed Jul 28, 2023
1 parent 8de3bd9 commit a5851d5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
44 changes: 28 additions & 16 deletions oidc-ui/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import langConfigService from "./services/langConfigService";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import EsignetDetailsPage from "./pages/EsignetDetails";
import LoadingIndicator from "./common/LoadingIndicator";
import { LoadingStates as states } from "./constants/states";

function App() {
const { i18n } = useTranslation();
const [langOptions, setLangOptions] = useState([]);
const [dir, setDir] = useState("");
const [statusLoading, SetStatusLoading] = useState(states.LOADING);

//Loading rtlLangs
useEffect(() => {
Expand All @@ -39,12 +42,11 @@ function App() {
setDir(response.rtlLanguages.includes(lng) ? "rtl" : "ltr");
});
setLangOptions(langData);
SetStatusLoading(states.LOADED)
});

} catch (error) {
console.error("Failed to load rtl languages!");
}

}, []);

const changeLanguage = (loadLang) => {
Expand All @@ -53,7 +55,6 @@ function App() {

//1. Check for ui locales param. Highest priority.
//This will override the language detectors selected language
// let defaultConfigs = await getLocaleConfiguration();
let supportedLanguages = loadLang.languages_2Letters;
let searchUrlParams = new URLSearchParams(window.location.search);
let uiLocales = searchUrlParams.get("ui_locales");
Expand Down Expand Up @@ -86,19 +87,30 @@ function App() {
//4. default lang set in env_configs file as fallback language.
};

return (
<div dir={dir} className="h-screen">
<NavHeader langOptions={langOptions} />
<BrowserRouter>
<Routes>
<Route path="/" element={<EsignetDetailsPage />} />
<Route path="/login" element={<LoginPage />} />
<Route path="/authorize" element={<AuthorizePage />} />
<Route path="/consent" element={<ConsentPage />} />
</Routes>
</BrowserRouter>
</div>
);
let el;

switch (statusLoading) {
case states.LOADING:
el = <LoadingIndicator size="medium" message={"loading_msg"} />;
break;
case states.LOADED:
el = (
<div dir={dir} className="h-screen">
<NavHeader langOptions={langOptions} />
<BrowserRouter>
<Routes>
<Route path="/" element={<EsignetDetailsPage />} />
<Route path="/login" element={<LoginPage />} />
<Route path="/authorize" element={<AuthorizePage />} />
<Route path="/consent" element={<ConsentPage />} />
</Routes>
</BrowserRouter>
</div>
);
break;
}

return el;
}

export default App;
5 changes: 0 additions & 5 deletions oidc-ui/src/components/Authorize.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import React from "react";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate, useSearchParams } from "react-router-dom";
import ErrorIndicator from "../common/ErrorIndicator";
import LoadingIndicator from "../common/LoadingIndicator";
import { LoadingStates as states } from "../constants/states";

export default function Authorize({
authService,
i18nKeyPrefix = "authorize",
}) {
const { i18n } = useTranslation("translation", {
keyPrefix: i18nKeyPrefix,
});

const get_CsrfToken = authService.get_CsrfToken;
const post_OauthDetails = authService.post_OauthDetails;
Expand Down
3 changes: 0 additions & 3 deletions oidc-ui/src/pages/Authorize.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from "react";
import Authorize from "../components/Authorize";
import authService from "../services/authService";
import langConfigService from "../services/langConfigService";


export default function AuthorizePage() {

Expand All @@ -12,7 +10,6 @@ export default function AuthorizePage() {
<div className="max-w-md w-full space-y-8">
<Authorize
authService={new authService(null)}
langConfigService={langConfigService}
/>
</div>
</div>
Expand Down

0 comments on commit a5851d5

Please sign in to comment.