mozrest-sdk-react-dev 0.3.31 → 0.3.32

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.
Files changed (2) hide show
  1. package/mozrest-sdk.es.js +42 -17
  2. package/package.json +1 -1
package/mozrest-sdk.es.js CHANGED
@@ -126367,7 +126367,7 @@ const Chart = ({
126367
126367
  border: "1px solid var(--moz-cta-content-sec-bg)"
126368
126368
  }
126369
126369
  }), sources2.map((src) => {
126370
- const displayName = src.name === "Resbook" ? "Widget" : src.name;
126370
+ const displayName = src.name === "Resbook" ? "Widget" : (src == null ? void 0 : src.hubDisplayName) || (src == null ? void 0 : src.name);
126371
126371
  return /* @__PURE__ */ jsx$1(Bar, {
126372
126372
  dataKey: src.code,
126373
126373
  name: displayName,
@@ -169938,37 +169938,62 @@ const CodeViewer = ({
169938
169938
  })]
169939
169939
  });
169940
169940
  };
169941
+ const GetWidget = async () => {
169942
+ const responseData = await instance$1.get(
169943
+ `/widgets`
169944
+ );
169945
+ const data2 = responseData.data;
169946
+ return data2;
169947
+ };
169941
169948
  function Main({
169942
169949
  venueId
169943
169950
  }) {
169944
169951
  const {
169945
169952
  t: t2
169946
169953
  } = useTranslation();
169947
- const widgetKey = "6256887299abe06e10e168d0";
169948
- const widgetHost = "https://widget-dev.mozrest.com";
169949
- const widgetUrl = `${widgetHost}/?key=${widgetKey}&mzId=${venueId}`;
169954
+ const {
169955
+ data: data2,
169956
+ isLoading
169957
+ } = useFetch(GetWidget, {
169958
+ cacheId: "widget"
169959
+ });
169960
+ const [widgetUrl, setWidgetUrl] = useState(null);
169961
+ const buildWidgetUrl = (data22) => {
169962
+ const widget2 = data22 && data22.length > 0 ? data22[0] : {
169963
+ key: "61afa0d0b5fb12d27dfa89e3"
169964
+ };
169965
+ const widgetKey = widget2 == null ? void 0 : widget2.key;
169966
+ const widgetHost = "https://widget-dev.mozrest.com";
169967
+ const widgetUrl2 = `${widgetHost}/?key=${widgetKey}&mzId=${venueId}`;
169968
+ setWidgetUrl(widgetUrl2);
169969
+ };
169970
+ useEffect(() => {
169971
+ buildWidgetUrl(data2);
169972
+ }, [data2]);
169950
169973
  const widgetCode = `<iframe
169951
169974
  src="${widgetUrl}"
169952
169975
  frameborder="0"
169953
169976
  style="width: 100%; min-height: calc(-130px + 100vh)"
169954
169977
  >
169955
169978
  </iframe>`;
169956
- return /* @__PURE__ */ jsxs(LayoutPage$1, {
169979
+ return /* @__PURE__ */ jsx$1(LayoutPage$1, {
169957
169980
  header: /* @__PURE__ */ jsx$1("h1", {
169958
169981
  children: t2("widget")
169959
169982
  }),
169960
- children: [/* @__PURE__ */ jsx$1(CodeViewer, {
169961
- code: widgetCode
169962
- }), /* @__PURE__ */ jsx$1("div", {
169963
- className: styles$6.buttonContainer,
169964
- children: /* @__PURE__ */ jsx$1(Button$1, {
169965
- mode: "primary",
169966
- onClick: () => {
169967
- window.open(widgetUrl, "_blank");
169968
- },
169969
- children: t2("openWidget")
169970
- })
169971
- })]
169983
+ children: isLoading ? /* @__PURE__ */ jsx$1(SkeletonPage, {}) : /* @__PURE__ */ jsxs(React__default.Fragment, {
169984
+ children: [/* @__PURE__ */ jsx$1(CodeViewer, {
169985
+ code: widgetCode
169986
+ }), /* @__PURE__ */ jsx$1("div", {
169987
+ className: styles$6.buttonContainer,
169988
+ children: /* @__PURE__ */ jsx$1(Button$1, {
169989
+ mode: "primary",
169990
+ onClick: () => {
169991
+ window.open(widgetUrl, "_blank");
169992
+ },
169993
+ children: t2("openWidget")
169994
+ })
169995
+ })]
169996
+ })
169972
169997
  });
169973
169998
  }
169974
169999
  const skeleton = "_skeleton_1bgvx_1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mozrest-sdk-react-dev",
3
- "version": "0.3.31",
3
+ "version": "0.3.32",
4
4
  "main": "mozrest-sdk.es.js",
5
5
  "keywords": [
6
6
  "mozrest"