mozrest-sdk-react-dev 0.3.49 → 0.3.50

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 +47 -12
  2. package/package.json +1 -1
package/mozrest-sdk.es.js CHANGED
@@ -3506,6 +3506,7 @@ const AuthHandler = ({
3506
3506
  accessKey
3507
3507
  }) => {
3508
3508
  const {
3509
+ data: user,
3509
3510
  isLoading,
3510
3511
  error: error3
3511
3512
  } = useFetch(GetToken, {
@@ -3525,7 +3526,7 @@ const AuthHandler = ({
3525
3526
  error: error3
3526
3527
  });
3527
3528
  }
3528
- return children;
3529
+ return typeof children === "function" ? children(user) : children;
3529
3530
  };
3530
3531
  function a$1(e) {
3531
3532
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
@@ -16783,6 +16784,25 @@ const ProviderContext = ({
16783
16784
  })
16784
16785
  });
16785
16786
  };
16787
+ const UserContext = createContext(void 0);
16788
+ const UserProvider = ({
16789
+ user,
16790
+ children
16791
+ }) => {
16792
+ return /* @__PURE__ */ jsx$1(UserContext.Provider, {
16793
+ value: {
16794
+ user
16795
+ },
16796
+ children
16797
+ });
16798
+ };
16799
+ const useUser = () => {
16800
+ const context = useContext(UserContext);
16801
+ if (context === void 0) {
16802
+ throw new Error("useUser must be used within a UserProvider");
16803
+ }
16804
+ return context;
16805
+ };
16786
16806
  const Provider = ({
16787
16807
  accessKey,
16788
16808
  lang: lang2,
@@ -16791,11 +16811,14 @@ const Provider = ({
16791
16811
  }) => {
16792
16812
  return /* @__PURE__ */ jsx$1(AuthHandler, {
16793
16813
  accessKey,
16794
- children: /* @__PURE__ */ jsx$1(ProviderContext, {
16795
- lang: lang2,
16796
- children: /* @__PURE__ */ jsx$1(Children2, {
16797
- ...props,
16798
- lang: lang2
16814
+ children: (userData2) => /* @__PURE__ */ jsx$1(UserProvider, {
16815
+ user: (userData2 == null ? void 0 : userData2.data) || userData2,
16816
+ children: /* @__PURE__ */ jsx$1(ProviderContext, {
16817
+ lang: lang2,
16818
+ children: /* @__PURE__ */ jsx$1(Children2, {
16819
+ ...props,
16820
+ lang: lang2
16821
+ })
16799
16822
  })
16800
16823
  })
16801
16824
  });
@@ -48668,12 +48691,17 @@ const ReplyForm = ({
48668
48691
  platform: platform2,
48669
48692
  reply: reply2
48670
48693
  }) => {
48694
+ var _a2;
48671
48695
  const {
48672
48696
  t: t2
48673
48697
  } = useTranslation();
48674
48698
  const [review] = useContext(ContextReview);
48699
+ const {
48700
+ user
48701
+ } = useUser();
48675
48702
  const canUpdate = platform2 === "facebook" || platform2 === "google";
48676
48703
  const isUpdate = reply2 && canUpdate;
48704
+ const showTemplates = ((_a2 = user == null ? void 0 : user.company) == null ? void 0 : _a2.replyTemplates) !== false;
48677
48705
  const initialValues = {
48678
48706
  comment: ""
48679
48707
  };
@@ -48763,7 +48791,7 @@ const ReplyForm = ({
48763
48791
  display: "flex",
48764
48792
  justifyContent: isMobile2 ? "flex-end" : "space-between"
48765
48793
  },
48766
- children: [!isMobile2 && /* @__PURE__ */ jsx$1(Button$1, {
48794
+ children: [!isMobile2 && showTemplates && /* @__PURE__ */ jsx$1(Button$1, {
48767
48795
  onClick: () => {
48768
48796
  setShowTemplates(true);
48769
48797
  },
@@ -48773,7 +48801,9 @@ const ReplyForm = ({
48773
48801
  }), /* @__PURE__ */ jsxs("div", {
48774
48802
  style: {
48775
48803
  display: "flex",
48776
- gap: 5
48804
+ flex: 1,
48805
+ gap: 5,
48806
+ justifyContent: "flex-end"
48777
48807
  },
48778
48808
  children: [!isMobile2 && /* @__PURE__ */ jsx$1(Button$1, {
48779
48809
  isLoading: isExecuting || isSuggesting,
@@ -54722,9 +54752,14 @@ const DetailMobile = ({
54722
54752
  onSuggestTemplate,
54723
54753
  isSuggesting
54724
54754
  }) => {
54755
+ var _a2;
54725
54756
  const {
54726
54757
  t: t2
54727
54758
  } = useTranslation();
54759
+ const {
54760
+ user
54761
+ } = useUser();
54762
+ const showReplyTemplates = ((_a2 = user == null ? void 0 : user.company) == null ? void 0 : _a2.replyTemplates) !== false;
54728
54763
  const [showTemplates, setShowTemplates] = useState(false);
54729
54764
  const [showTranslation, setShowTranslation] = useState(false);
54730
54765
  const openModal = () => setShowTemplates(true);
@@ -54832,7 +54867,7 @@ const DetailMobile = ({
54832
54867
  },
54833
54868
  icon: "robot",
54834
54869
  children: t2("SUGGESTREPLY")
54835
- }), /* @__PURE__ */ jsx$1(Button$1, {
54870
+ }), showReplyTemplates && /* @__PURE__ */ jsx$1(Button$1, {
54836
54871
  onClick: openModal,
54837
54872
  children: t2("SHOWTEMPLATES")
54838
54873
  })]
@@ -153332,16 +153367,16 @@ const formatData$6 = (data2, params) => {
153332
153367
  data2 = data2.filter((item2) => item2.status !== "canceled");
153333
153368
  }
153334
153369
  return data2.map((item2) => {
153335
- var _a2;
153370
+ var _a2, _b;
153336
153371
  return {
153337
153372
  // logo:item.bookingChannel.logo,
153338
153373
  firstName: item2.contact.firstname ?? "",
153339
153374
  name: `${item2.contact.firstname ?? ""} ${item2.contact.lastname ?? ""}`,
153340
- tableName: item2.table.name,
153375
+ tableName: ((_a2 = item2 == null ? void 0 : item2.table) == null ? void 0 : _a2.name) ?? null,
153341
153376
  notes: item2.notes,
153342
153377
  partySize: item2.partySize,
153343
153378
  bookingChannelName: item2.bookingChannel.name,
153344
- bookingChannelLogo: ((_a2 = item2 == null ? void 0 : item2.bookingChannel) == null ? void 0 : _a2.name) == "Resbook" ? "https://mozrest-statics.s3.eu-west-1.amazonaws.com/resbook/widget.png" : item2.bookingChannel.logo,
153379
+ bookingChannelLogo: ((_b = item2 == null ? void 0 : item2.bookingChannel) == null ? void 0 : _b.name) == "Resbook" ? "https://mozrest-statics.s3.eu-west-1.amazonaws.com/resbook/widget.png" : item2.bookingChannel.logo,
153345
153380
  date: item2.date,
153346
153381
  status: item2.status,
153347
153382
  ...item2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mozrest-sdk-react-dev",
3
- "version": "0.3.49",
3
+ "version": "0.3.50",
4
4
  "main": "mozrest-sdk.es.js",
5
5
  "keywords": [
6
6
  "mozrest"