@legalplace/wizardx-core 4.13.2 → 4.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export declare const redirectToLogin: (redirectUrl: string, redirectParams?: boolean) => void;
@@ -0,0 +1,12 @@
1
+ export const redirectToLogin = (redirectUrl, redirectParams = false) => {
2
+ const currentParams = new URLSearchParams(window.location.search);
3
+ const redirectURL = new URL(redirectUrl, window.location.origin);
4
+ currentParams.forEach((value, key) => {
5
+ redirectURL.searchParams.append(key, value);
6
+ });
7
+ if (redirectParams) {
8
+ redirectURL.searchParams.append("redirectUrl", encodeURIComponent(window.location.href));
9
+ }
10
+ window.onbeforeunload = null;
11
+ window.location.href = redirectURL.toString();
12
+ };
@@ -21,6 +21,7 @@ import { FETCH_MODEL, FETCH_MODEL_PREREQUISITES, } from "../constants/sagas/mode
21
21
  import { fetchModelAction } from "../actions/sagas/model";
22
22
  import { initInputsDecorator } from "./initInputs";
23
23
  import { cancelOnResetState } from "../../helpers/sagaCancelOnResetState";
24
+ import { redirectToLogin } from "../../helpers/redirectToLogin";
24
25
  const cookies = new Cookies();
25
26
  function* setFetchModelToNonBlocking(firstCurrentAppState) {
26
27
  yield put(initPaginationAction({
@@ -82,10 +83,7 @@ function* getWizardConfig(permalink, uniqidParam, prefix, queryParams) {
82
83
  }
83
84
  response = yield call([response, "json"]);
84
85
  if (response.redirect) {
85
- window.onbeforeunload = null;
86
- window.location.href = `${response.redirect}${response.redirectParams
87
- ? `?redirectUrl=${encodeURIComponent(window.location.href)}`
88
- : ""}`;
86
+ redirectToLogin(response.redirect, response.redirectParams);
89
87
  }
90
88
  yield put(setModelUuidAction(response.modelUuid));
91
89
  return { modelUuid: response.modelUuid };
@@ -132,10 +130,7 @@ function* fetchInstanceInformation(appStates, permalink, uniqid, uniqidParam, pr
132
130
  }
133
131
  response = yield call([response, "json"]);
134
132
  if (response.redirect) {
135
- window.onbeforeunload = null;
136
- window.location.href = `${response.redirect}${response.redirectParams
137
- ? `?redirectUrl=${encodeURIComponent(window.location.href)}`
138
- : ""}`;
133
+ redirectToLogin(response.redirect, response.redirectParams);
139
134
  }
140
135
  if (response.errors || response.status === "error") {
141
136
  throw new Error(`Unable to fetch ${permalink}${uniqid && uniqid.trim().length > 0 ? `/${uniqid}` : ""}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/wizardx-core",
3
- "version": "4.13.2",
3
+ "version": "4.14.0",
4
4
  "author": "Moncef Hammou (moncef@legalplace.fr)",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -24,7 +24,7 @@
24
24
  "@legalplace/lp-events": "1.14.0",
25
25
  "@legalplace/lplogic": "2.3.1",
26
26
  "@legalplace/model-healthcheck": "^1.1.5",
27
- "@legalplace/referencesparser": "^3.1.16",
27
+ "@legalplace/referencesparser": "^3.1.17",
28
28
  "@legalplace/storybook": "^2.171.0",
29
29
  "@legalplace/typeorm-constants": "^3.32.0",
30
30
  "@loadable/component": "^5.15.0",
@@ -54,11 +54,11 @@
54
54
  "xss": "^1.0.9"
55
55
  },
56
56
  "devDependencies": {
57
- "@legalplace/data-gouv": "^1.5.10",
57
+ "@legalplace/data-gouv": "^1.5.11",
58
58
  "@legalplace/eslint-config": "^2.2.0",
59
59
  "@legalplace/models-v3-types": "^5.11.4",
60
60
  "@legalplace/prettier-config": "^2.1.3",
61
- "@legalplace/typeorm-entities": "^5.29.6",
61
+ "@legalplace/typeorm-entities": "^5.29.7",
62
62
  "@swc-node/jest": "^1.3.2",
63
63
  "@swc/core": "^1.2.93",
64
64
  "@swc/jest": "^0.2.4",
@@ -96,5 +96,5 @@
96
96
  "*.test.ts",
97
97
  "*.test.tsx"
98
98
  ],
99
- "gitHead": "3240a0186197e2448190353665f556d64d945bf5"
99
+ "gitHead": "9c5402206e418e9aba10b90da7c95d088d85961f"
100
100
  }