@sawport/react-sdk 0.1.0-alpha.44 → 0.1.0-alpha.46

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
@@ -42290,7 +42290,8 @@ const Offline = react.exports.memo(({
42290
42290
  toTime,
42291
42291
  fromTime,
42292
42292
  toDay,
42293
- fromDay
42293
+ fromDay,
42294
+ callRequestOptions
42294
42295
  }) => {
42295
42296
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
42296
42297
  const [{
@@ -42302,7 +42303,9 @@ const Offline = react.exports.memo(({
42302
42303
  country_code,
42303
42304
  mobile,
42304
42305
  isLoading,
42305
- scheduled
42306
+ scheduled,
42307
+ continent,
42308
+ timezone: timezone2
42306
42309
  }, setState] = useState({
42307
42310
  ipAddress: "",
42308
42311
  country: "",
@@ -42312,7 +42315,9 @@ const Offline = react.exports.memo(({
42312
42315
  country_code: "",
42313
42316
  mobile: "",
42314
42317
  isLoading: false,
42315
- scheduled: false
42318
+ scheduled: false,
42319
+ continent: void 0,
42320
+ timezone: void 0
42316
42321
  });
42317
42322
  const saved = react.exports.useRef();
42318
42323
  const offlineSchema = create$1().shape({
@@ -42340,15 +42345,19 @@ const Offline = react.exports.memo(({
42340
42345
  country_name,
42341
42346
  longitude: longitude2,
42342
42347
  latitude: latitude2,
42343
- country_code: country_code2
42348
+ country_code: country_code2,
42349
+ timezone: timezone22
42344
42350
  } = data2.data;
42351
+ const continent2 = timezone22.split("/")[0];
42345
42352
  setState({
42346
42353
  country: country_name,
42347
42354
  longitude: longitude2,
42348
42355
  latitude: latitude2,
42349
42356
  location: region,
42350
42357
  ipAddress: ip,
42351
- country_code: country_code2
42358
+ country_code: country_code2,
42359
+ continent: continent2,
42360
+ timezone: timezone22
42352
42361
  });
42353
42362
  }).catch((error) => toast.error("Error occured, try again", {
42354
42363
  autoClose: 2e3
@@ -42408,7 +42417,10 @@ const Offline = react.exports.memo(({
42408
42417
  latitude,
42409
42418
  longitude,
42410
42419
  location: location2,
42411
- ip_address: ipAddress
42420
+ ip_address: ipAddress,
42421
+ timezone: timezone2,
42422
+ continent,
42423
+ access_platform: "online"
42412
42424
  });
42413
42425
  }
42414
42426
  resetForm({});
@@ -42421,7 +42433,7 @@ const Offline = react.exports.memo(({
42421
42433
  autoClose: 2e3
42422
42434
  });
42423
42435
  }
42424
- }, [country, latitude, longitude, location2, ipAddress, calendar2, mobile]);
42436
+ }, [country, latitude, longitude, location2, ipAddress, calendar2, mobile, timezone2, continent]);
42425
42437
  const {
42426
42438
  handleSubmit,
42427
42439
  handleChange,
@@ -42580,11 +42592,12 @@ const Offline = react.exports.memo(({
42580
42592
  }), /* @__PURE__ */ jsx(FInput, {
42581
42593
  style: {
42582
42594
  borderRight: void 0,
42583
- fontSize: 16,
42584
- height: 60
42595
+ fontSize: 16
42585
42596
  },
42586
- label: "Reason For Call",
42597
+ label: "Select A Reason For Call",
42587
42598
  name: "reason",
42599
+ type: "select",
42600
+ options: callRequestOptions,
42588
42601
  placeholder: "Why did you want to call?",
42589
42602
  handleChange,
42590
42603
  handleBlur,
@@ -42647,6 +42660,7 @@ const Schedules = react.exports.memo(function({
42647
42660
  const join2 = react.exports.useCallback(async ({
42648
42661
  conversation
42649
42662
  }) => {
42663
+ var _a, _b;
42650
42664
  try {
42651
42665
  dataRef.current = {
42652
42666
  customer,
@@ -42654,7 +42668,8 @@ const Schedules = react.exports.memo(function({
42654
42668
  customer,
42655
42669
  conversation: {
42656
42670
  id: conversation == null ? void 0 : conversation.id
42657
- }
42671
+ },
42672
+ id: (_b = (_a = conversation == null ? void 0 : conversation.waitLists) == null ? void 0 : _a[0]) == null ? void 0 : _b.id
42658
42673
  }
42659
42674
  };
42660
42675
  setParentState({
@@ -42803,6 +42818,7 @@ const FInput = react.exports.memo(({
42803
42818
  type,
42804
42819
  style: style2 = {},
42805
42820
  disabled,
42821
+ options,
42806
42822
  ...p2
42807
42823
  }) => {
42808
42824
  const regexPattern = /^[a-zA-Z\s]*$/;
@@ -42830,7 +42846,25 @@ const FInput = react.exports.memo(({
42830
42846
  })
42831
42847
  }), /* @__PURE__ */ jsxs(InputGroup$1, {
42832
42848
  className: "mt-n3",
42833
- children: [/* @__PURE__ */ jsx(Input$1, {
42849
+ children: [type === "select" ? /* @__PURE__ */ jsx(Input$1, {
42850
+ ...p2,
42851
+ style: style2,
42852
+ className: styles$1.offline_input,
42853
+ name,
42854
+ disabled,
42855
+ onChange: ["full_name", "name"].includes(name) ? onNameChange : onChange || handleChange,
42856
+ onBlur: onBlur || handleBlur,
42857
+ value: values[name],
42858
+ valid: touched[name] && !errors[name],
42859
+ invalid: touched[name] && !!errors[name],
42860
+ placeholder,
42861
+ type,
42862
+ bsSize: "sm",
42863
+ children: options.map((value2, index) => /* @__PURE__ */ jsx("option", {
42864
+ value: value2,
42865
+ children: value2
42866
+ }, index))
42867
+ }) : /* @__PURE__ */ jsx(Input$1, {
42834
42868
  ...p2,
42835
42869
  style: style2,
42836
42870
  className: styles$1.offline_input,
@@ -43030,10 +43064,10 @@ function WidgetOfflineHeader({
43030
43064
  children: "Video Banking Offline"
43031
43065
  })
43032
43066
  }), /* @__PURE__ */ jsx(SubTitle, {
43033
- from_day: company == null ? void 0 : company.from_day,
43034
- to_day: company == null ? void 0 : company.to_day,
43035
- from_time: hooks("2020-04-04 " + (company == null ? void 0 : company.from_time)).format("HH:mm"),
43036
- to_time: hooks("2020-04-04 " + (company == null ? void 0 : company.to_time)).format("HH:mm")
43067
+ from_day: company == null ? void 0 : company.from_day.substring(0, 3),
43068
+ to_day: company == null ? void 0 : company.to_day.substring(0, 3),
43069
+ from_time: hooks("2020-04-04 " + (company == null ? void 0 : company.from_time)).format("hh:mm A"),
43070
+ to_time: hooks("2020-04-04 " + (company == null ? void 0 : company.to_time)).format("hh:mm A")
43037
43071
  })]
43038
43072
  })
43039
43073
  });
@@ -43151,7 +43185,8 @@ function WidgetInitForm({
43151
43185
  location: location2,
43152
43186
  source_url,
43153
43187
  continent,
43154
- timezone: timezone2
43188
+ timezone: timezone2,
43189
+ access_platform: "online"
43155
43190
  }, "post"), {
43156
43191
  onError: (err) => {
43157
43192
  toast.error("Error occured, try again", {
@@ -46796,6 +46831,7 @@ const createFeedback = (params) => api("feedbacks", params, "post");
46796
46831
  const getWaitConnectors = async (data2) => api("wait-connectors", data2);
46797
46832
  const getLongestWaitTime = async (data2) => api("waits/longest", data2);
46798
46833
  const updateWait = async (id2, data2) => api(`waits/${id2}`, data2, "put");
46834
+ const getConnectedWait = async (data2) => api("waits/connected", data2);
46799
46835
  function Feedback({
46800
46836
  agent: agent_,
46801
46837
  quickStopChat,
@@ -47947,7 +47983,7 @@ function useVideoCalling({ userId, conversation_id }) {
47947
47983
  useSocketListeners({
47948
47984
  listeners: {
47949
47985
  "Recording.start": () => {
47950
- alert("This call is being recorded");
47986
+ toast.info("This call is being recorded");
47951
47987
  setState({ recording: true });
47952
47988
  },
47953
47989
  "Recording.end": () => setState({ recording: false })
@@ -49749,6 +49785,7 @@ const he = ({ id: e2, className: t2, classNameArrow: n2, variant: o2 = "dark", a
49749
49785
  const G2 = { id: e2, anchorId: t2, className: i2, classNameArrow: l2, content: T2, isHtmlContent: Y2, place: O2, variant: A2, offset: L2, wrapper: H2, events: U2, positionStrategy: V2, delayShow: C2, delayHide: D2, float: W2, noArrow: b2, clickable: x2, style: S2, position: _2, isOpen: R2, setIsOpen: k2 };
49750
49786
  return d2 ? c.exports.jsx(he, { ...G2, children: d2 }) : c.exports.jsx(he, { ...G2 });
49751
49787
  };
49788
+ const ReactToastify = "";
49752
49789
  const reactTooltip = "";
49753
49790
  const days = {
49754
49791
  Monday: 1,
@@ -49818,49 +49855,51 @@ function UnwrapWidget({
49818
49855
  if (isLoadingCompany || isLoadingCompany === void 0) {
49819
49856
  return null;
49820
49857
  }
49821
- return /* @__PURE__ */ jsxs("div", {
49822
- className: `widget-cover mb-2 ${isWidgetLaunched ? "widget-cover-container" : ""}`,
49823
- children: [/* @__PURE__ */ jsx(WidgetFormDisplay, {
49824
- companyIsClosed,
49825
- company_id,
49826
- company,
49827
- companyUser,
49828
- setIsWidgetLaunched,
49829
- isWidgetLaunched
49830
- }), /* @__PURE__ */ jsxs("div", {
49831
- style: {
49832
- position: "relative"
49833
- },
49834
- children: [/* @__PURE__ */ jsx("div", {
49835
- id: "welcomeMessage",
49836
- className: `widget-launcher-container m-5 ${isWidgetLaunched ? "" : "animate"}`,
49837
- onClick: () => {
49838
- setShowTip(false);
49839
- setIsWidgetLaunched(!isWidgetLaunched);
49840
- },
49841
- style: {
49842
- backgroundColor: `${hex_code}`
49843
- },
49844
- children: isWidgetLaunched ? /* @__PURE__ */ jsx("img", {
49845
- alt: "closeIcon",
49846
- src: closeIcon,
49847
- width: 30
49848
- }) : /* @__PURE__ */ jsx("img", {
49849
- alt: "videoIcon",
49850
- src: videoIcon,
49851
- width: 30
49852
- })
49853
- }), /* @__PURE__ */ jsx(ve, {
49854
- place: "left",
49855
- isOpen: showTip,
49856
- anchorId: "welcomeMessage",
49857
- className: "p-3",
49858
+ return /* @__PURE__ */ jsxs(Fragment, {
49859
+ children: [/* @__PURE__ */ jsx(ToastContainer, {}), /* @__PURE__ */ jsxs("div", {
49860
+ className: `widget-cover mb-2 ${isWidgetLaunched ? "widget-cover-container" : ""}`,
49861
+ children: [/* @__PURE__ */ jsx(WidgetFormDisplay, {
49862
+ companyIsClosed,
49863
+ company_id,
49864
+ company,
49865
+ companyUser,
49866
+ setIsWidgetLaunched,
49867
+ isWidgetLaunched
49868
+ }), /* @__PURE__ */ jsxs("div", {
49858
49869
  style: {
49859
- backgroundColor: `${hex_code}`,
49860
- width: 240,
49861
- fontWeight: 600
49870
+ position: "relative"
49862
49871
  },
49863
- children: "For Diaspora Banking, click here to start Video Banking."
49872
+ children: [/* @__PURE__ */ jsx("div", {
49873
+ id: "welcomeMessage",
49874
+ className: `widget-launcher-container m-5 ${isWidgetLaunched ? "" : "animate"}`,
49875
+ onClick: () => {
49876
+ setShowTip(false);
49877
+ setIsWidgetLaunched(!isWidgetLaunched);
49878
+ },
49879
+ style: {
49880
+ backgroundColor: `${hex_code}`
49881
+ },
49882
+ children: isWidgetLaunched ? /* @__PURE__ */ jsx("img", {
49883
+ alt: "closeIcon",
49884
+ src: closeIcon,
49885
+ width: 30
49886
+ }) : /* @__PURE__ */ jsx("img", {
49887
+ alt: "videoIcon",
49888
+ src: videoIcon,
49889
+ width: 30
49890
+ })
49891
+ }), /* @__PURE__ */ jsx(ve, {
49892
+ place: "left",
49893
+ isOpen: showTip,
49894
+ anchorId: "welcomeMessage",
49895
+ className: "p-3",
49896
+ style: {
49897
+ backgroundColor: `${hex_code}`,
49898
+ width: 240,
49899
+ fontWeight: 600
49900
+ },
49901
+ children: "For Diaspora Banking, click here to start Video Banking."
49902
+ })]
49864
49903
  })]
49865
49904
  })]
49866
49905
  });
@@ -49902,7 +49941,7 @@ const WidgetFormDisplay = react.exports.memo(({
49902
49941
  setIsWidgetLaunched,
49903
49942
  isWidgetLaunched
49904
49943
  }) => {
49905
- var _a, _b, _c, _d;
49944
+ var _a, _b, _c, _d, _e;
49906
49945
  const {
49907
49946
  socket: socket2
49908
49947
  } = useSocket();
@@ -50037,29 +50076,160 @@ const WidgetFormDisplay = react.exports.memo(({
50037
50076
  toTime: company == null ? void 0 : company.to_time,
50038
50077
  fromTime: company == null ? void 0 : company.from_time,
50039
50078
  toDay: company == null ? void 0 : company.to_day,
50040
- fromDay: company == null ? void 0 : company.from_day
50079
+ fromDay: company == null ? void 0 : company.from_day,
50080
+ callRequestOptions: ((_d = company == null ? void 0 : company.options) == null ? void 0 : _d.callRequestOptions) || []
50041
50081
  }) : chatInit && !chatClose ? /* @__PURE__ */ jsx(Feedback$1, {
50042
50082
  quickStopChat,
50043
50083
  agent,
50044
- conversation_id: (_d = dataRef.current) == null ? void 0 : _d.wait.conversation.id
50045
- }) : !chatInit ? /* @__PURE__ */ jsx(WidgetInitForm$1, {
50084
+ conversation_id: (_e = dataRef.current) == null ? void 0 : _e.wait.conversation.id
50085
+ }) : /* @__PURE__ */ jsx(ChatMode, {
50086
+ chatInit,
50046
50087
  company_id,
50047
50088
  companyUser,
50048
50089
  dataRef,
50049
50090
  setState,
50050
50091
  setIsScheduling,
50051
- fields: company == null ? void 0 : company.fields,
50052
- widgetColor: company == null ? void 0 : company.hex_code
50053
- }) : /* @__PURE__ */ jsx(ChatWidgetScreen$1, {
50054
- welcome_message: company == null ? void 0 : company.welcome_message,
50055
- dataRef,
50092
+ company,
50056
50093
  setChatClose,
50057
50094
  agent,
50058
- videoRef
50095
+ videoRef,
50096
+ customer
50059
50097
  })
50060
50098
  }), /* @__PURE__ */ jsx(Footer, {})]
50061
50099
  });
50062
50100
  });
50101
+ const ChatMode = react.exports.memo(({
50102
+ chatInit,
50103
+ company_id,
50104
+ companyUser,
50105
+ dataRef,
50106
+ setState,
50107
+ setIsScheduling,
50108
+ company,
50109
+ setChatClose,
50110
+ agent,
50111
+ videoRef,
50112
+ customer
50113
+ }) => {
50114
+ var _a, _b, _c;
50115
+ const {
50116
+ state: {
50117
+ data: data2
50118
+ },
50119
+ setState: _setState
50120
+ } = useRequest({
50121
+ asyncRequest: getConnectedWait,
50122
+ params: [{
50123
+ customer: customer == null ? void 0 : customer.id
50124
+ }]
50125
+ });
50126
+ const agent_ = react.exports.useMemo(() => {
50127
+ var _a2, _b2;
50128
+ const connectors = (_a2 = data2 == null ? void 0 : data2[0]) == null ? void 0 : _a2.connectors;
50129
+ return (_b2 = connectors == null ? void 0 : connectors[(connectors == null ? void 0 : connectors.length) - 1]) == null ? void 0 : _b2.agent;
50130
+ }, [data2]);
50131
+ return !chatInit ? (data2 == null ? void 0 : data2.length) ? /* @__PURE__ */ jsx(OngoingChat, {
50132
+ waitId: (_a = data2 == null ? void 0 : data2[0]) == null ? void 0 : _a.id,
50133
+ conversationId: (_c = (_b = data2 == null ? void 0 : data2[0]) == null ? void 0 : _b.conversation) == null ? void 0 : _c.id,
50134
+ agent: agent_,
50135
+ setState: _setState,
50136
+ customer,
50137
+ dataRef,
50138
+ setParentState: setState
50139
+ }) : /* @__PURE__ */ jsx(WidgetInitForm$1, {
50140
+ company_id,
50141
+ companyUser,
50142
+ dataRef,
50143
+ setState,
50144
+ setIsScheduling,
50145
+ fields: company == null ? void 0 : company.fields,
50146
+ widgetColor: company == null ? void 0 : company.hex_code
50147
+ }) : /* @__PURE__ */ jsx(ChatWidgetScreen$1, {
50148
+ welcome_message: company == null ? void 0 : company.welcome_message,
50149
+ dataRef,
50150
+ setChatClose,
50151
+ agent,
50152
+ videoRef
50153
+ });
50154
+ });
50155
+ const OngoingChat = ({
50156
+ setState,
50157
+ waitId,
50158
+ dataRef,
50159
+ customer,
50160
+ conversationId,
50161
+ setParentState,
50162
+ agent
50163
+ }) => {
50164
+ const {
50165
+ socket: socket2
50166
+ } = useSocket();
50167
+ const endChat = () => {
50168
+ t$1.emit("chat-ended");
50169
+ updateWait(waitId, {
50170
+ status: "ended"
50171
+ });
50172
+ setState({
50173
+ data: []
50174
+ });
50175
+ resume({
50176
+ chatClose: false
50177
+ });
50178
+ };
50179
+ const resume = ({
50180
+ chatClose
50181
+ } = {}) => {
50182
+ try {
50183
+ dataRef.current = {
50184
+ customer,
50185
+ wait: {
50186
+ customer,
50187
+ conversation: {
50188
+ id: conversationId
50189
+ },
50190
+ id: waitId
50191
+ }
50192
+ };
50193
+ const updates = {
50194
+ chatInit: true,
50195
+ companyClosed: false,
50196
+ agent
50197
+ };
50198
+ setState({
50199
+ data: []
50200
+ });
50201
+ chatClose !== void 0 && (updates.chatClose = chatClose);
50202
+ setParentState(updates);
50203
+ socket2.emit("customer-joined-conversation", {
50204
+ conversation: conversationId,
50205
+ customer: customer == null ? void 0 : customer.id
50206
+ });
50207
+ } catch (error) {
50208
+ console.log(error);
50209
+ }
50210
+ };
50211
+ return /* @__PURE__ */ jsxs("div", {
50212
+ className: "p-4 d-flex flex-column align-items-center justify-content-center",
50213
+ children: [/* @__PURE__ */ jsx("h3", {
50214
+ className: "my-2",
50215
+ children: "You have an ongoing chat!"
50216
+ }), /* @__PURE__ */ jsx("h4", {
50217
+ className: "mb-5",
50218
+ children: "Would you like to resume the chat?"
50219
+ }), /* @__PURE__ */ jsxs("div", {
50220
+ className: "mt-5 mb-3 d-flex align-items-center justify-content-center",
50221
+ children: [/* @__PURE__ */ jsx("button", {
50222
+ onClick: endChat,
50223
+ className: "btn btn-danger",
50224
+ children: "End Chat"
50225
+ }), /* @__PURE__ */ jsx("button", {
50226
+ onClick: resume,
50227
+ className: "btn btn-primary ml-4",
50228
+ children: "Resume"
50229
+ })]
50230
+ })]
50231
+ });
50232
+ };
50063
50233
  const Footer = () => /* @__PURE__ */ jsx("div", {
50064
50234
  className: "widget-footer-container",
50065
50235
  children: /* @__PURE__ */ jsxs("div", {