mozrest-sdk-react-dev 0.3.48 → 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 +54 -18
  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
  });
@@ -48650,6 +48673,11 @@ const TextAreaField$1 = ({
48650
48673
  })
48651
48674
  });
48652
48675
  };
48676
+ const ContextReview = React__default.createContext([
48677
+ null,
48678
+ (value2) => {
48679
+ }
48680
+ ]);
48653
48681
  const ReplyForm = ({
48654
48682
  reviewId,
48655
48683
  onSucess,
@@ -48663,11 +48691,17 @@ const ReplyForm = ({
48663
48691
  platform: platform2,
48664
48692
  reply: reply2
48665
48693
  }) => {
48694
+ var _a2;
48666
48695
  const {
48667
48696
  t: t2
48668
48697
  } = useTranslation();
48698
+ const [review] = useContext(ContextReview);
48699
+ const {
48700
+ user
48701
+ } = useUser();
48669
48702
  const canUpdate = platform2 === "facebook" || platform2 === "google";
48670
48703
  const isUpdate = reply2 && canUpdate;
48704
+ const showTemplates = ((_a2 = user == null ? void 0 : user.company) == null ? void 0 : _a2.replyTemplates) !== false;
48671
48705
  const initialValues = {
48672
48706
  comment: ""
48673
48707
  };
@@ -48711,7 +48745,7 @@ const ReplyForm = ({
48711
48745
  if (reply2) {
48712
48746
  setValue("comment", reply2 == null ? void 0 : reply2.comment);
48713
48747
  }
48714
- }, [reply2]);
48748
+ }, [reply2, review]);
48715
48749
  return /* @__PURE__ */ jsx$1("form", {
48716
48750
  onSubmit: handleSubmit(handleExecute),
48717
48751
  children: /* @__PURE__ */ jsxs("div", {
@@ -48757,7 +48791,7 @@ const ReplyForm = ({
48757
48791
  display: "flex",
48758
48792
  justifyContent: isMobile2 ? "flex-end" : "space-between"
48759
48793
  },
48760
- children: [!isMobile2 && /* @__PURE__ */ jsx$1(Button$1, {
48794
+ children: [!isMobile2 && showTemplates && /* @__PURE__ */ jsx$1(Button$1, {
48761
48795
  onClick: () => {
48762
48796
  setShowTemplates(true);
48763
48797
  },
@@ -48767,7 +48801,9 @@ const ReplyForm = ({
48767
48801
  }), /* @__PURE__ */ jsxs("div", {
48768
48802
  style: {
48769
48803
  display: "flex",
48770
- gap: 5
48804
+ flex: 1,
48805
+ gap: 5,
48806
+ justifyContent: "flex-end"
48771
48807
  },
48772
48808
  children: [!isMobile2 && /* @__PURE__ */ jsx$1(Button$1, {
48773
48809
  isLoading: isExecuting || isSuggesting,
@@ -54716,9 +54752,14 @@ const DetailMobile = ({
54716
54752
  onSuggestTemplate,
54717
54753
  isSuggesting
54718
54754
  }) => {
54755
+ var _a2;
54719
54756
  const {
54720
54757
  t: t2
54721
54758
  } = useTranslation();
54759
+ const {
54760
+ user
54761
+ } = useUser();
54762
+ const showReplyTemplates = ((_a2 = user == null ? void 0 : user.company) == null ? void 0 : _a2.replyTemplates) !== false;
54722
54763
  const [showTemplates, setShowTemplates] = useState(false);
54723
54764
  const [showTranslation, setShowTranslation] = useState(false);
54724
54765
  const openModal = () => setShowTemplates(true);
@@ -54826,7 +54867,7 @@ const DetailMobile = ({
54826
54867
  },
54827
54868
  icon: "robot",
54828
54869
  children: t2("SUGGESTREPLY")
54829
- }), /* @__PURE__ */ jsx$1(Button$1, {
54870
+ }), showReplyTemplates && /* @__PURE__ */ jsx$1(Button$1, {
54830
54871
  onClick: openModal,
54831
54872
  children: t2("SHOWTEMPLATES")
54832
54873
  })]
@@ -55321,11 +55362,6 @@ const styles$1C = {
55321
55362
  content: content$8,
55322
55363
  empty
55323
55364
  };
55324
- const ContextReview = React__default.createContext([
55325
- null,
55326
- (value2) => {
55327
- }
55328
- ]);
55329
55365
  const Reviews = ({
55330
55366
  reviews,
55331
55367
  isEmpty,
@@ -153331,16 +153367,16 @@ const formatData$6 = (data2, params) => {
153331
153367
  data2 = data2.filter((item2) => item2.status !== "canceled");
153332
153368
  }
153333
153369
  return data2.map((item2) => {
153334
- var _a2;
153370
+ var _a2, _b;
153335
153371
  return {
153336
153372
  // logo:item.bookingChannel.logo,
153337
153373
  firstName: item2.contact.firstname ?? "",
153338
153374
  name: `${item2.contact.firstname ?? ""} ${item2.contact.lastname ?? ""}`,
153339
- tableName: item2.table.name,
153375
+ tableName: ((_a2 = item2 == null ? void 0 : item2.table) == null ? void 0 : _a2.name) ?? null,
153340
153376
  notes: item2.notes,
153341
153377
  partySize: item2.partySize,
153342
153378
  bookingChannelName: item2.bookingChannel.name,
153343
- 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,
153344
153380
  date: item2.date,
153345
153381
  status: item2.status,
153346
153382
  ...item2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mozrest-sdk-react-dev",
3
- "version": "0.3.48",
3
+ "version": "0.3.50",
4
4
  "main": "mozrest-sdk.es.js",
5
5
  "keywords": [
6
6
  "mozrest"