@sawport/react-sdk 0.1.0-alpha.24 → 0.1.0-alpha.25

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
@@ -45788,6 +45788,7 @@ var Rating = dist.Rating = function(t2) {
45788
45788
  const createFeedback = (params) => api("feedbacks", params, "post");
45789
45789
  const getWaitConnectors = async (data2) => api("wait-connectors", data2);
45790
45790
  const getLongestWaitTime = async (data2) => api("waits/longest", data2);
45791
+ const updateWait = async (id2, data2) => api(`waits/${id2}`, data2, "put");
45791
45792
  function Feedback({
45792
45793
  agent: agent_,
45793
45794
  quickStopChat,
@@ -47285,7 +47286,7 @@ const WidgetFormDisplay = react.exports.memo(({
47285
47286
  setIsWidgetLaunched,
47286
47287
  isWidgetLaunched
47287
47288
  }) => {
47288
- var _a, _b, _c, _d, _e, _f;
47289
+ var _a, _b, _c, _d;
47289
47290
  const {
47290
47291
  socket: socket2
47291
47292
  } = useSocket();
@@ -47332,26 +47333,18 @@ const WidgetFormDisplay = react.exports.memo(({
47332
47333
  }
47333
47334
  }, [socket2.connected, chatInit, customer == null ? void 0 : customer.id]);
47334
47335
  const quickStopChat = react.exports.useCallback(() => {
47335
- var _a2, _b2, _c2, _d2;
47336
47336
  setState({
47337
47337
  chatInit: false,
47338
47338
  chatClose: true,
47339
47339
  companyClosed: companyIsClosed
47340
47340
  });
47341
- ((_a2 = dataRef.current) == null ? void 0 : _a2.wait) && socket2.emit("chat.ended", {
47342
- to: (_b2 = agent == null ? void 0 : agent.user) == null ? void 0 : _b2.id,
47343
- waitId: (_d2 = (_c2 = dataRef.current) == null ? void 0 : _c2.wait) == null ? void 0 : _d2.id,
47344
- customer
47345
- });
47346
47341
  dataRef.current = null;
47347
- }, [companyIsClosed, (_b = dataRef.current) == null ? void 0 : _b.wait, (_c = agent == null ? void 0 : agent.user) == null ? void 0 : _c.id, customer]);
47342
+ }, [companyIsClosed, dataRef]);
47348
47343
  const setChatClose = (chatClose2) => {
47349
- var _a2, _b2, _c2;
47344
+ var _a2, _b2;
47350
47345
  t$1.emit("chat-ended");
47351
- socket2.emit("chat.ended", {
47352
- to: (_a2 = agent == null ? void 0 : agent.user) == null ? void 0 : _a2.id,
47353
- waitId: (_c2 = (_b2 = dataRef.current) == null ? void 0 : _b2.wait) == null ? void 0 : _c2.id,
47354
- customer
47346
+ updateWait((_b2 = (_a2 = dataRef.current) == null ? void 0 : _a2.wait) == null ? void 0 : _b2.id, {
47347
+ status: "ended"
47355
47348
  });
47356
47349
  setState({
47357
47350
  chatClose: chatClose2
@@ -47406,7 +47399,7 @@ const WidgetFormDisplay = react.exports.memo(({
47406
47399
  quickStopChat,
47407
47400
  company,
47408
47401
  videoRef
47409
- }), !!((_e = (_d = dataRef == null ? void 0 : dataRef.current) == null ? void 0 : _d.wait) == null ? void 0 : _e.createdAt) && !stateRef.current.agent && /* @__PURE__ */ jsx(LongestWaitime, {}), /* @__PURE__ */ jsx("div", {
47402
+ }), !!((_c = (_b = dataRef == null ? void 0 : dataRef.current) == null ? void 0 : _b.wait) == null ? void 0 : _c.createdAt) && !stateRef.current.agent && /* @__PURE__ */ jsx(LongestWaitime, {}), /* @__PURE__ */ jsx("div", {
47410
47403
  className: `widget-body-container px-3 ${companyClosed && "widget-body-container-offline"} `,
47411
47404
  children: isLoadingCustomer ? /* @__PURE__ */ jsx(Spinner$2, {}) : isScheduling ? /* @__PURE__ */ jsx(Schedules, {
47412
47405
  setParentState: setState,
@@ -47428,7 +47421,7 @@ const WidgetFormDisplay = react.exports.memo(({
47428
47421
  }) : chatInit && !chatClose ? /* @__PURE__ */ jsx(Feedback$1, {
47429
47422
  quickStopChat,
47430
47423
  agent,
47431
- conversation_id: (_f = dataRef.current) == null ? void 0 : _f.wait.conversation.id
47424
+ conversation_id: (_d = dataRef.current) == null ? void 0 : _d.wait.conversation.id
47432
47425
  }) : !chatInit ? /* @__PURE__ */ jsx(WidgetInitForm$1, {
47433
47426
  company_id,
47434
47427
  companyUser,