@legalplace/wizardx-core 3.0.0 → 3.0.1

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.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@3.0.0...@legalplace/wizardx-core@3.0.1) (2023-02-08)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix smartscript api[#7714](https://git.legalplace.eu/legalplace/monorepo/issues/7714) ([0c8fc01](https://git.legalplace.eu/legalplace/monorepo/commits/0c8fc01e209eb4e631f72c2dfa4cdab202453dba))
12
+ * fix smartscript initiating api[#7714](https://git.legalplace.eu/legalplace/monorepo/issues/7714) ([365a087](https://git.legalplace.eu/legalplace/monorepo/commits/365a087a4e16bada6f133859a11d935fec8a1a5d))
13
+
14
+
15
+
16
+
17
+
6
18
  # [3.0.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.15.1...@legalplace/wizardx-core@3.0.0) (2023-02-08)
7
19
 
8
20
 
@@ -1,3 +1,4 @@
1
+ import React from "react";
1
2
  import type { Action } from "redux";
2
3
  import moment from "moment-business-days";
3
4
  import { SmartScriptStore } from "../libs/SmartScriptStore";
@@ -26,5 +27,13 @@ declare global {
26
27
  initTriggers: (callback: TInitTriggersCallback, inputs: StateType.Inputs, newInstance: boolean) => void;
27
28
  }
28
29
  }
29
- declare const SmartScriptComponent: () => JSX.Element;
30
- export default SmartScriptComponent;
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;
@@ -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";
4
3
  import queryString from "query-string";
5
4
  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
- const SmartScriptComponent = () => {
8
+ let initTriggersCallback = null;
9
+ const SmartScriptComponent = ({ permalink, uniqid, metaFetchStatus, }) => {
9
10
  const [smartScriptLoaded, setSmartScriptLoaded] = useState(false);
10
11
  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,10 +27,9 @@ const SmartScriptComponent = () => {
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();
31
30
  const modelVersion = queryString.parse(window.location.search).version;
32
31
  useEffect(() => {
33
- if (!smartScriptLoaded) {
32
+ if (metaFetchStatus === "succeeded" && !smartScriptLoaded) {
34
33
  const src = `${apiEndpoint}wizard/contractv1/smartscript/${permalink}${uniqid ? `/${uniqid}` : ""}${modelVersion ? `?version=${modelVersion}` : ""}`;
35
34
  const scriptElement = document.createElement("script");
36
35
  scriptElement.setAttribute("src", src);
@@ -50,11 +49,11 @@ const SmartScriptComponent = () => {
50
49
  }, [
51
50
  smartScriptLoaded,
52
51
  apiEndpoint,
53
- initTriggersCallback,
54
52
  modelVersion,
55
53
  permalink,
56
54
  uniqid,
57
55
  isNewInstance,
56
+ metaFetchStatus,
58
57
  ]);
59
58
  window.initTriggers = (callback, inputs, newInstance = true) => {
60
59
  SmartScriptStore.inputs = inputs;
@@ -65,7 +64,7 @@ const SmartScriptComponent = () => {
65
64
  callback(SmartScriptStore.triggers, SmartScriptStore.grabActions());
66
65
  }
67
66
  else {
68
- setInitTriggersCallback(callback);
67
+ initTriggersCallback = callback;
69
68
  setIsNewInstance(newInstance);
70
69
  }
71
70
  };
@@ -83,6 +82,11 @@ const SmartScriptComponent = () => {
83
82
  }
84
83
  return SmartScriptStore.grabActions();
85
84
  };
86
- return _jsx(_Fragment, { children: "SmartScript" }, void 0);
85
+ return (_jsx(_Fragment, { children: smartScriptLoaded ? "SmartScript Loaded." : "Loading SmartScript..." }, void 0));
87
86
  };
88
- export default SmartScriptComponent;
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/wizardx-core",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
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": "b1dc121743e12b48abd21b580ff8aab4543d74c7"
97
+ "gitHead": "1fb61bd835073ac75c833b826fa35e0cd04cfb42"
98
98
  }