Skip to content

Commit

Permalink
fix(offline): test
Browse files Browse the repository at this point in the history
  • Loading branch information
lailabjil committed Mar 27, 2024
1 parent 196c007 commit bdc3484
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edt",
"version": "3.14.2",
"version": "3.14.4",
"dateVersion": "27/03/2024",
"licence": "MIT",
"dependencies": {
Expand Down
12 changes: 10 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import {
} from "service/survey-service";
import { getUserRights, setAuth, setUser, setUserToken } from "service/user-service";
import { getCookie } from "utils/utils";

const App = () => {
const { t } = useTranslation();
const [initialized, setInitialized] = useState(false);
const [error, setError] = useState<ErrorCodeEnum | undefined>(undefined);
const auth = useAuth();

const getTokenHint = () => {
return localStorage.getItem("id_token") ?? undefined;
Expand All @@ -36,6 +36,10 @@ const App = () => {
};
const promisesToWait: Promise<any>[] = [];

const auth = useAuth();

console.log(auth);

useEffect(() => {
if (
window.location.search &&
Expand Down Expand Up @@ -80,13 +84,16 @@ const App = () => {
promisesToWait.push(
initializeDatas(setError).then(() => {
setInitialized(true);
return initPropsAuth(auth).then(() => setInitialized(true));
return initPropsAuth(auth).then(() => {
setInitialized(true);
});
}),
);

if (getUserRights() === EdtUserRightsEnum.REVIEWER && navigator.onLine) {
promisesToWait.push(
initializeListSurveys(setError).then(() => {
console.log("initialized");
setInitialized(true);
}),
);
Expand Down Expand Up @@ -118,6 +125,7 @@ const App = () => {
initializeDatas(setError).then(() => {
if (getUserRights() === EdtUserRightsEnum.REVIEWER) {
return initializeListSurveys(setError).then(() => {
console.log("initializeListSurveys");
setInitialized(true);
});
} else setInitialized(true);
Expand Down
11 changes: 10 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const oidcConfigSSO = {
userManager: createUserManager(),
};

const oidcConfig = {
const oidcConfigOnline = {
onSignIn: () => {
//to remove keycloak params in url
window.history.replaceState(null, "", window.location.pathname);
Expand All @@ -31,8 +31,17 @@ const oidcConfig = {
automaticSilentRenew: !navigator.onLine,
};

const oidcConfigOffline = {
automaticSilentRenew: !navigator.onLine,
silent_redirect_uri: "https://insee-edt.k8s.keyconsulting.fr/",
};

const oidcConfig = navigator.onLine ? oidcConfigOnline : oidcConfigOffline;

const oidcProps = isSSO ? Object.assign(oidcConfig, oidcConfigSSO) : oidcConfig;

console.log(oidcProps);

root.render(
<AuthProvider {...oidcProps}>
<React.StrictMode>
Expand Down

0 comments on commit bdc3484

Please sign in to comment.