@legalplace/wizardx-core 3.0.1 → 3.0.2

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.0.2](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@3.0.1...@legalplace/wizardx-core@3.0.2) (2023-02-08)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix smartscrip loading api[#7714](https://git.legalplace.eu/legalplace/monorepo/issues/7714) ([7e42cba](https://git.legalplace.eu/legalplace/monorepo/commits/7e42cbac2f65d7815b069d54e8feab8f83bd5467))
12
+ * fix test api[#7714](https://git.legalplace.eu/legalplace/monorepo/issues/7714) ([cdd9dee](https://git.legalplace.eu/legalplace/monorepo/commits/cdd9dee1816f5f61a057bfaabf8edca589dde060))
13
+
14
+
15
+
16
+
17
+
6
18
  ## [3.0.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@3.0.0...@legalplace/wizardx-core@3.0.1) (2023-02-08)
7
19
 
8
20
 
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import type { Action } from "redux";
3
2
  import moment from "moment-business-days";
4
3
  import { SmartScriptStore } from "../libs/SmartScriptStore";
@@ -27,13 +26,5 @@ declare global {
27
26
  initTriggers: (callback: TInitTriggersCallback, inputs: StateType.Inputs, newInstance: boolean) => void;
28
27
  }
29
28
  }
30
- declare const _default: import("react-redux").ConnectedComponent<React.FC<{
31
- permalink: string;
32
- uniqid: string;
33
- metaFetchStatus: "failed" | "waiting" | "succeeded" | "unhealthy" | "userLocked" | "nonBlocking";
34
- }>, import("react-redux").Omit<{
35
- permalink: string;
36
- uniqid: string;
37
- metaFetchStatus: "failed" | "waiting" | "succeeded" | "unhealthy" | "userLocked" | "nonBlocking";
38
- }, "permalink" | "uniqid" | "metaFetchStatus">>;
39
- export default _default;
29
+ declare const SmartScriptComponent: () => JSX.Element;
30
+ export default SmartScriptComponent;
@@ -1,14 +1,14 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
+ import { useParams } from "react-router-dom";
3
4
  import queryString from "query-string";
4
5
  import moment from "moment-business-days";
5
- import { connect } from "react-redux";
6
6
  import { getConfig } from "../config";
7
7
  import { SmartScriptStore } from "../libs/SmartScriptStore";
8
- let initTriggersCallback = null;
9
- const SmartScriptComponent = ({ permalink, uniqid, metaFetchStatus, }) => {
8
+ const SmartScriptComponent = () => {
10
9
  const [smartScriptLoaded, setSmartScriptLoaded] = useState(false);
11
10
  const [isNewInstance, setIsNewInstance] = useState(true);
11
+ const [initTriggersCallback, setInitTriggersCallback] = useState(null);
12
12
  window.onInit = SmartScriptStore.onInit;
13
13
  window.onLoad = SmartScriptStore.onLoad;
14
14
  window.onOptionChange = SmartScriptStore.onOptionChange;
@@ -27,9 +27,10 @@ const SmartScriptComponent = ({ permalink, uniqid, metaFetchStatus, }) => {
27
27
  window.displayOption = SmartScriptStore.displayOption;
28
28
  window.moment = moment;
29
29
  const apiEndpoint = getConfig().apiEndpoint + (/\/$/.test(getConfig().apiEndpoint) ? "" : "/");
30
+ const { permalink, uniqid } = useParams();
30
31
  const modelVersion = queryString.parse(window.location.search).version;
31
32
  useEffect(() => {
32
- if (metaFetchStatus === "succeeded" && !smartScriptLoaded) {
33
+ if (!smartScriptLoaded) {
33
34
  const src = `${apiEndpoint}wizard/contractv1/smartscript/${permalink}${uniqid ? `/${uniqid}` : ""}${modelVersion ? `?version=${modelVersion}` : ""}`;
34
35
  const scriptElement = document.createElement("script");
35
36
  scriptElement.setAttribute("src", src);
@@ -49,11 +50,11 @@ const SmartScriptComponent = ({ permalink, uniqid, metaFetchStatus, }) => {
49
50
  }, [
50
51
  smartScriptLoaded,
51
52
  apiEndpoint,
53
+ initTriggersCallback,
52
54
  modelVersion,
53
55
  permalink,
54
56
  uniqid,
55
57
  isNewInstance,
56
- metaFetchStatus,
57
58
  ]);
58
59
  window.initTriggers = (callback, inputs, newInstance = true) => {
59
60
  SmartScriptStore.inputs = inputs;
@@ -64,7 +65,7 @@ const SmartScriptComponent = ({ permalink, uniqid, metaFetchStatus, }) => {
64
65
  callback(SmartScriptStore.triggers, SmartScriptStore.grabActions());
65
66
  }
66
67
  else {
67
- initTriggersCallback = callback;
68
+ setInitTriggersCallback(callback);
68
69
  setIsNewInstance(newInstance);
69
70
  }
70
71
  };
@@ -82,11 +83,6 @@ const SmartScriptComponent = ({ permalink, uniqid, metaFetchStatus, }) => {
82
83
  }
83
84
  return SmartScriptStore.grabActions();
84
85
  };
85
- return (_jsx(_Fragment, { children: smartScriptLoaded ? "SmartScript Loaded." : "Loading SmartScript..." }, void 0));
86
+ return _jsx(_Fragment, { children: smartScriptLoaded ? "SmartScript" : "Loading..." }, void 0);
86
87
  };
87
- const mapStateToProps = (state) => ({
88
- permalink: state.app.meta.permalink,
89
- uniqid: state.app.instance.uniqid,
90
- metaFetchStatus: state.app.meta.fetchStatus,
91
- });
92
- export default connect(mapStateToProps)(SmartScriptComponent);
88
+ export default SmartScriptComponent;
@@ -19,8 +19,10 @@ const watchEnableSmartScript = (mpi, next, action) => {
19
19
  iframe = document.createElement("iframe");
20
20
  iframe.id = "lp-smartscript";
21
21
  iframe.setAttribute("style", "position: absolute; width:0; height:0; border:0;");
22
- const { permalink, prefix } = mpi.getState().app.meta;
23
- const { uniqid } = mpi.getState().app.instance;
22
+ const state = mpi.getState();
23
+ const permalink = getConfig().permalink || state.app.meta.permalink || "";
24
+ const prefix = getConfig().prefix || state.app.meta.prefix || "";
25
+ const uniqid = getConfig().uniqid || state.app.instance.uniqid || "";
24
26
  const { modelVersion } = new PathReader(mpi.getState());
25
27
  if (getConfig().router.smartscriptPath) {
26
28
  const path = generatePath(getConfig().router.smartscriptPath, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/wizardx-core",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "author": "Moncef Hammou (moncef@legalplace.fr)",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -94,5 +94,5 @@
94
94
  "*.test.ts",
95
95
  "*.test.tsx"
96
96
  ],
97
- "gitHead": "1fb61bd835073ac75c833b826fa35e0cd04cfb42"
97
+ "gitHead": "29260cdc0aac1698afff6be27bdc78c8ac7ef174"
98
98
  }