@sawport/react-sdk 0.1.0-alpha.71 → 0.1.0-alpha.73

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/dist/index.js CHANGED
@@ -69412,7 +69412,7 @@ function WidgetInitForm({
69412
69412
  const shape = {
69413
69413
  name: create$4().min(3).required(),
69414
69414
  email: create$4().email().required(),
69415
- message: create$4().min(7).required()
69415
+ message: create$4().min(7, "Message must be at least 7 characters").required("Message is a required field")
69416
69416
  };
69417
69417
  const possibleShape = {
69418
69418
  account: create$3().required().min(10).positive(),
@@ -69482,7 +69482,7 @@ function WidgetInitForm({
69482
69482
  ...emptyFields2
69483
69483
  }) => {
69484
69484
  var _a, _b;
69485
- const phoneNumberRegex = /^[0-9]{1,4}[-\s]?[0-9]{6,12}$/;
69485
+ const phoneNumberRegex = /^\+?\d{1,3}(\s?[-]?\d{3}){3}\s?\d$/;
69486
69486
  if (((_a = fields == null ? void 0 : fields.mobile) == null ? void 0 : _a.show) || ((_b = fields == null ? void 0 : fields.mobile) == null ? void 0 : _b.show) === void 0) {
69487
69487
  if (mobile === "") {
69488
69488
  toast.error("Phone number is required", {
@@ -73410,7 +73410,6 @@ function ChatWidgetScreen({
73410
73410
  transferredAgent: null,
73411
73411
  agentConnected: false
73412
73412
  });
73413
- const popupTime = ((_a = company == null ? void 0 : company.options) == null ? void 0 : _a.schedulePopUpTime) || 1e3 * 60;
73414
73413
  const {
73415
73414
  state: {
73416
73415
  data: {
@@ -73422,7 +73421,7 @@ function ChatWidgetScreen({
73422
73421
  asyncRequest: getMessages,
73423
73422
  params: [{
73424
73423
  conversation: {
73425
- id: (_b = dataRef.current) == null ? void 0 : _b.wait.conversation.id
73424
+ id: (_a = dataRef.current) == null ? void 0 : _a.wait.conversation.id
73426
73425
  }
73427
73426
  }]
73428
73427
  });
@@ -73519,7 +73518,7 @@ function ChatWidgetScreen({
73519
73518
  });
73520
73519
  }
73521
73520
  };
73522
- }, [(_d = (_c = dataRef.current) == null ? void 0 : _c.customer) == null ? void 0 : _d.id, t$3, setChatClose, ((_e = dataRef.current) == null ? void 0 : _e.wait.conversation.id) || ((_f = dataRef.current) == null ? void 0 : _f.wait.conversation), (_g = dataRef.current) == null ? void 0 : _g.wait.id]);
73521
+ }, [(_c = (_b = dataRef.current) == null ? void 0 : _b.customer) == null ? void 0 : _c.id, t$3, setChatClose, ((_d = dataRef.current) == null ? void 0 : _d.wait.conversation.id) || ((_e = dataRef.current) == null ? void 0 : _e.wait.conversation), (_f = dataRef.current) == null ? void 0 : _f.wait.id]);
73523
73522
  useSocketListeners({
73524
73523
  listeners: listeners2
73525
73524
  });
@@ -73527,11 +73526,14 @@ function ChatWidgetScreen({
73527
73526
  isOngoingChat && clearInterval(timeoutRef.current);
73528
73527
  }, [timeoutRef, isOngoingChat]);
73529
73528
  reactExports.useEffect(() => {
73530
- if (popupTime && !agentDetails) {
73531
- timeoutRef.current = setInterval(() => setPopupVisible(true), popupTime);
73532
- return () => clearInterval(timeoutRef.current);
73529
+ var _a2, _b2;
73530
+ if (((_a2 = company == null ? void 0 : company.options) == null ? void 0 : _a2.schedulePopUpTime) && !agentDetails) {
73531
+ const intervalId = setInterval(() => {
73532
+ setPopupVisible(true);
73533
+ }, (_b2 = company == null ? void 0 : company.options) == null ? void 0 : _b2.schedulePopUpTime);
73534
+ return () => clearInterval(intervalId);
73533
73535
  }
73534
- }, [popupTime, agentDetails]);
73536
+ }, [(_g = company == null ? void 0 : company.options) == null ? void 0 : _g.schedulePopUpTime, agentDetails]);
73535
73537
  return /* @__PURE__ */ jsxs("div", {
73536
73538
  className: "widget-chat-container",
73537
73539
  children: [/* @__PURE__ */ jsxs("div", {
@@ -73643,7 +73645,7 @@ const ChatInput = reactExports.memo(function({
73643
73645
  chatFiles: event.target.files[0]
73644
73646
  });
73645
73647
  } else {
73646
- toast.info("File format not supported");
73648
+ toast.info("Ony PDF Files supported");
73647
73649
  return;
73648
73650
  }
73649
73651
  }
@@ -74880,7 +74882,9 @@ function useVideoCalling({ userId, conversation_id }) {
74880
74882
  audio: false
74881
74883
  });
74882
74884
  } catch (e2) {
74883
- toast.error("Could not share the screen, please check the error and try again. " + e2);
74885
+ if (e2.message !== "Permission denied") {
74886
+ toast.error("Could not share the screen, please check the error and try again. " + e2);
74887
+ }
74884
74888
  }
74885
74889
  const { peerConnection, localStream, screenStream } = ref.current;
74886
74890
  if (screenStream) {
@@ -75725,6 +75729,7 @@ const WidgetFormDisplay = reactExports.memo(({
75725
75729
  setState({
75726
75730
  chatInit: false,
75727
75731
  chatClose: true,
75732
+ agent: void 0,
75728
75733
  companyClosed: companyIsClosed,
75729
75734
  ...extraState
75730
75735
  });
@@ -75826,7 +75831,7 @@ const WidgetFormDisplay = reactExports.memo(({
75826
75831
  paddingLeft: "4%",
75827
75832
  backgroundColor: `${hex_code}`
75828
75833
  },
75829
- children: ["You have ", customerCount, " customer(s) ahead of you!"]
75834
+ children: ["You have ", customerCount, " customer(s) ahead!"]
75830
75835
  }), /* @__PURE__ */ jsx(LongestWaitime, {})]
75831
75836
  })
75832
75837
  }), /* @__PURE__ */ jsx("div", {
@@ -76020,7 +76025,7 @@ const OngoingChat = ({
76020
76025
  const currentTimestamp = (/* @__PURE__ */ new Date()).getTime();
76021
76026
  const offlineAt = (/* @__PURE__ */ new Date(`${conversation == null ? void 0 : conversation.offlineAt}`)).getTime();
76022
76027
  const timeDifferenceInMilliseconds = currentTimestamp - offlineAt;
76023
- const timeDifferenceInMinutes = Math.floor(timeDifferenceInMilliseconds / (1e3 * 60));
76028
+ const timeDifferenceInMinutes = Math.floor(timeDifferenceInMilliseconds / chatSession);
76024
76029
  if (timeDifferenceInMinutes >= chatSession) {
76025
76030
  toast.info("Time expired for going off chat", {
76026
76031
  autoClose: 2e3
@@ -76028,7 +76033,7 @@ const OngoingChat = ({
76028
76033
  endChat();
76029
76034
  }
76030
76035
  }
76031
- }, []);
76036
+ }, [chatSession, wait == null ? void 0 : wait.status, conversation == null ? void 0 : conversation.offlineAt]);
76032
76037
  return /* @__PURE__ */ jsxs("div", {
76033
76038
  className: "p-4 d-flex flex-column align-items-center justify-content-center",
76034
76039
  children: [/* @__PURE__ */ jsx("h3", {