call-control-sdk 6.5.1-uat.3 → 6.5.1-uat.5

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
@@ -88,7 +88,8 @@ var END_POINT = {
88
88
  TRANSFER_TO_DETAILS: `${BASE_URL}${VERSION.v1}/cti/transfer-to-details?provider=convox`,
89
89
  SEND_NOTIFICATIONS: `${BASE_URL}${VERSION.v1}/cti/notifications/send`,
90
90
  CALL_HISTORY: `${BASE_URL}${VERSION.v1}/dashboard/call-history`,
91
- SENTIMENTAL_ANALYSIS: `${BASE_URL}${VERSION.v1}/users/get_sentiment_analysis`
91
+ SENTIMENTAL_ANALYSIS: `${BASE_URL}${VERSION.v1}/users/get_sentiment_analysis`,
92
+ DISPOSITIONS: `${BASE_URL}${VERSION.v1}/cti/calls/dispositions`
92
93
  };
93
94
  var WS_END_POINT = {
94
95
  WS: `${WS_BASE_URL}${VERSION.v1}/cti/ws`
@@ -958,7 +959,7 @@ var useEndCall = () => {
958
959
  const [data, setData] = (0, import_react2.useState)(null);
959
960
  const handleEndCall = (0, import_react2.useCallback)(
960
961
  async (data2) => {
961
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
962
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
962
963
  const state = JSON.parse((_a2 = localStorage.getItem(STORAGE_KEY)) != null ? _a2 : "");
963
964
  setLoading(true);
964
965
  const payload = {
@@ -975,7 +976,11 @@ var useEndCall = () => {
975
976
  callback_mins: (_o = data2 == null ? void 0 : data2.callbackMins) != null ? _o : "",
976
977
  endcall_type: "CLOSE"
977
978
  };
978
- return axios_default.post(END_POINT.END_CALL, payload).then((res) => {
979
+ return axios_default.post(END_POINT.END_CALL, payload, {
980
+ params: {
981
+ isBreak: (_p = data2 == null ? void 0 : data2.isBreak) != null ? _p : false
982
+ }
983
+ }).then((res) => {
979
984
  sdkStateManager.resetConferenceLines();
980
985
  sdkStateManager.endCall();
981
986
  setData(res == null ? void 0 : res.data);
@@ -1306,6 +1311,59 @@ var reducer = (state, action) => {
1306
1311
  }
1307
1312
  throw Error("Unknown action.");
1308
1313
  };
1314
+ var useGetRequest = (props = {}) => {
1315
+ const { onSuccess = null, onError = null } = props;
1316
+ const { showToast } = useToast();
1317
+ const [state, dispatch] = (0, import_react9.useReducer)(reducer, initialState);
1318
+ const getRequest = (0, import_react9.useCallback)(
1319
+ (url, config = {}) => {
1320
+ dispatch({
1321
+ type: "isLoading",
1322
+ payload: true
1323
+ });
1324
+ axios_default.get(url, config).then((res) => {
1325
+ var _a2, _b;
1326
+ if ((_a2 = res.data) == null ? void 0 : _a2.success) {
1327
+ dispatch({
1328
+ type: "isSuccess",
1329
+ payload: res.data
1330
+ });
1331
+ onSuccess == null ? void 0 : onSuccess(res.data, config);
1332
+ } else {
1333
+ dispatch({
1334
+ type: "isError",
1335
+ payload: res.data
1336
+ });
1337
+ showToast((_b = res.data) == null ? void 0 : _b.message, "error");
1338
+ onError == null ? void 0 : onError(res.data, config);
1339
+ }
1340
+ }).catch((err) => {
1341
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1342
+ const error = {
1343
+ status: (_b = (_a2 = err.response) == null ? void 0 : _a2.status) != null ? _b : 500,
1344
+ message: ((_d = (_c = err.response) == null ? void 0 : _c.data) == null ? void 0 : _d.detail) || ((_f = (_e = err.response) == null ? void 0 : _e.data) == null ? void 0 : _f.message) || err.message || "An unknown error occurred",
1345
+ data: (_h = (_g = err.response) == null ? void 0 : _g.data) != null ? _h : null,
1346
+ statusText: (_j = (_i = err.response) == null ? void 0 : _i.statusText) != null ? _j : "",
1347
+ code: (_k = err == null ? void 0 : err.code) != null ? _k : "",
1348
+ name: (_l = err == null ? void 0 : err.name) != null ? _l : ""
1349
+ };
1350
+ showToast(error.message, "error");
1351
+ dispatch({
1352
+ type: "isError",
1353
+ payload: error
1354
+ });
1355
+ onError == null ? void 0 : onError(error, config);
1356
+ }).finally(() => {
1357
+ dispatch({
1358
+ type: "isLoading",
1359
+ payload: false
1360
+ });
1361
+ });
1362
+ },
1363
+ [onSuccess, onError, showToast]
1364
+ );
1365
+ return [getRequest, state];
1366
+ };
1309
1367
  var usePostRequest = (props = {}) => {
1310
1368
  const { onSuccess = null, onError = null, disabledSuccessToast = false } = props;
1311
1369
  const { showToast } = useToast();
@@ -1447,7 +1505,7 @@ var ConferenceTableRow = ({ each }) => {
1447
1505
  const line_used = __spreadValues(__spreadValues({}, line), data);
1448
1506
  setConferenceCallStart(true);
1449
1507
  const payload = {
1450
- action: "EXTERNAL_CONFERENCE",
1508
+ action: "INTERNAL_CONFERENCE",
1451
1509
  operation: `CALL${line_used.line}`,
1452
1510
  line_used: String(line_used.line),
1453
1511
  thirdparty_no: line_used.phone,
@@ -2450,18 +2508,16 @@ function CallTransferDialog({ open }) {
2450
2508
  ) });
2451
2509
  }
2452
2510
  function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2453
- var _a2, _b, _c, _d;
2511
+ var _a2, _b, _c, _d, _e;
2512
+ const [getDispositions, data] = useGetRequest();
2454
2513
  const [formData, setFormData] = (0, import_react10.useState)({
2455
2514
  disposition: { label: "Resolved", value: "RES" },
2456
2515
  followUp: { label: "No", value: "N" },
2457
2516
  callbackDate: "",
2458
2517
  callbackHrs: "",
2459
- callbackMins: ""
2518
+ callbackMins: "",
2519
+ selected_break: false
2460
2520
  });
2461
- const dispositionOptions = [
2462
- { label: "Not Interested", value: "NI" },
2463
- { label: "Resolved", value: "RES" }
2464
- ];
2465
2521
  const followUpOptions = [
2466
2522
  { label: "Yes", value: "Y" },
2467
2523
  { label: "No", value: "N" }
@@ -2475,13 +2531,25 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2475
2531
  followUp: { label: "No", value: "N" },
2476
2532
  callbackDate: "",
2477
2533
  callbackHrs: "",
2478
- callbackMins: ""
2534
+ callbackMins: "",
2535
+ selected_break: false
2479
2536
  });
2480
2537
  };
2481
2538
  const handleClose = () => {
2482
2539
  handleReset();
2483
2540
  setOpen(false);
2484
2541
  };
2542
+ (0, import_react10.useEffect)(() => {
2543
+ getDispositions(END_POINT.DISPOSITIONS);
2544
+ }, []);
2545
+ console.log("dispositionsData", formData);
2546
+ const dispositionsOptions = (0, import_react10.useMemo)(() => {
2547
+ var _a3, _b2;
2548
+ return ((_b2 = (_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.data) == null ? void 0 : _b2.map((item) => ({
2549
+ label: item.name,
2550
+ value: item.code
2551
+ }))) || [];
2552
+ }, [(_a2 = data == null ? void 0 : data.data) == null ? void 0 : _a2.data]);
2485
2553
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2486
2554
  import_material3.Dialog,
2487
2555
  {
@@ -2534,7 +2602,7 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2534
2602
  import_material3.Autocomplete,
2535
2603
  {
2536
2604
  value: formData.disposition,
2537
- options: dispositionOptions,
2605
+ options: dispositionsOptions,
2538
2606
  getOptionLabel: (opt) => opt.label,
2539
2607
  onChange: (_, val) => handleChange("disposition", val),
2540
2608
  size: "small",
@@ -2569,14 +2637,37 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2569
2637
  ]
2570
2638
  }
2571
2639
  ),
2572
- ((_b = (_a2 = formData == null ? void 0 : formData.followUp) == null ? void 0 : _a2.label) == null ? void 0 : _b.toLowerCase()) === "yes" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2640
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2573
2641
  import_material3.Box,
2574
2642
  {
2575
2643
  display: "flex",
2576
2644
  gap: 2,
2577
2645
  mt: 2,
2578
2646
  children: [
2579
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2647
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Box, { sx: {
2648
+ flex: "1",
2649
+ border: "1px solid #bdbdbd",
2650
+ borderRadius: "5px"
2651
+ }, children: [
2652
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2653
+ import_material3.Checkbox,
2654
+ {
2655
+ name: "selected_break",
2656
+ sx: {
2657
+ padding: "6px"
2658
+ },
2659
+ checked: formData.selected_break,
2660
+ onChange: (event) => {
2661
+ handleChange("selected_break", event.target.checked);
2662
+ },
2663
+ slotProps: {
2664
+ input: { "aria-label": "controlled" }
2665
+ }
2666
+ }
2667
+ ),
2668
+ " Mark as break"
2669
+ ] }),
2670
+ ((_c = (_b = formData == null ? void 0 : formData.followUp) == null ? void 0 : _b.label) == null ? void 0 : _c.toLowerCase()) === "yes" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2580
2671
  import_material3.TextField,
2581
2672
  {
2582
2673
  size: "small",
@@ -2590,7 +2681,17 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2590
2681
  fullWidth: true,
2591
2682
  sx: { flex: 1 }
2592
2683
  }
2593
- ),
2684
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Box, { sx: { flex: 1 } })
2685
+ ]
2686
+ }
2687
+ ),
2688
+ ((_e = (_d = formData == null ? void 0 : formData.followUp) == null ? void 0 : _d.label) == null ? void 0 : _e.toLowerCase()) === "yes" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2689
+ import_material3.Box,
2690
+ {
2691
+ display: "flex",
2692
+ gap: 2,
2693
+ mt: 2,
2694
+ children: [
2594
2695
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2595
2696
  import_material3.TextField,
2596
2697
  {
@@ -2602,17 +2703,7 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2602
2703
  fullWidth: true,
2603
2704
  sx: { flex: 1 }
2604
2705
  }
2605
- )
2606
- ]
2607
- }
2608
- ),
2609
- ((_d = (_c = formData == null ? void 0 : formData.followUp) == null ? void 0 : _c.label) == null ? void 0 : _d.toLowerCase()) === "yes" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2610
- import_material3.Box,
2611
- {
2612
- display: "flex",
2613
- gap: 2,
2614
- mt: 2,
2615
- children: [
2706
+ ),
2616
2707
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2617
2708
  import_material3.TextField,
2618
2709
  {
@@ -2624,8 +2715,7 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2624
2715
  fullWidth: true,
2625
2716
  sx: { flex: 1 }
2626
2717
  }
2627
- ),
2628
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Box, { sx: { flex: 1 } })
2718
+ )
2629
2719
  ]
2630
2720
  }
2631
2721
  )
@@ -2887,6 +2977,57 @@ function cleanupAudioResources() {
2887
2977
  audioBuffer = null;
2888
2978
  }
2889
2979
 
2980
+ // call-control-sdk/lib/services/micController.ts
2981
+ function createMicController(constraints = { audio: true }) {
2982
+ let stream = null;
2983
+ let muted = false;
2984
+ async function start() {
2985
+ if (stream) return;
2986
+ stream = await navigator.mediaDevices.getUserMedia(constraints);
2987
+ stream.getAudioTracks().forEach((track) => track.enabled = true);
2988
+ muted = false;
2989
+ }
2990
+ function setEnabled(enabled) {
2991
+ if (!stream) return;
2992
+ stream.getAudioTracks().forEach((track) => track.enabled = enabled);
2993
+ muted = !enabled;
2994
+ }
2995
+ function mute() {
2996
+ setEnabled(false);
2997
+ }
2998
+ function unmute() {
2999
+ setEnabled(true);
3000
+ }
3001
+ function toggleMute() {
3002
+ if (muted) {
3003
+ unmute();
3004
+ } else {
3005
+ mute();
3006
+ }
3007
+ }
3008
+ function stop() {
3009
+ if (!stream) return;
3010
+ stream.getTracks().forEach((t) => t.stop());
3011
+ stream = null;
3012
+ muted = false;
3013
+ }
3014
+ function isMuted() {
3015
+ return muted;
3016
+ }
3017
+ function getStream() {
3018
+ return stream;
3019
+ }
3020
+ return {
3021
+ start,
3022
+ stop,
3023
+ mute,
3024
+ unmute,
3025
+ toggleMute,
3026
+ isMuted,
3027
+ getStream
3028
+ };
3029
+ }
3030
+
2890
3031
  // call-control-sdk/lib/components/callControls.tsx
2891
3032
  var import_jsx_runtime3 = require("react/jsx-runtime");
2892
3033
  var getCombineConfrenceData = (localState, apiData) => {
@@ -2927,6 +3068,7 @@ function CallControls({ onDataChange }) {
2927
3068
  enabled: ((_b = state.sdkConfig) == null ? void 0 : _b.enabled) || {},
2928
3069
  outlined: ((_c = state.sdkConfig) == null ? void 0 : _c.outlined) || {}
2929
3070
  });
3071
+ const micRef = (0, import_react11.useRef)(null);
2930
3072
  const webSocketRef = (0, import_react11.useRef)(null);
2931
3073
  const audioRef = (0, import_react11.useRef)(null);
2932
3074
  const reconnectTimeoutRef = (0, import_react11.useRef)(null);
@@ -3063,7 +3205,7 @@ function CallControls({ onDataChange }) {
3063
3205
  muteOrUnMute(END_POINT.MUTE_CALL, payload);
3064
3206
  };
3065
3207
  const handleEndCall = (data) => {
3066
- var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2;
3208
+ var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2;
3067
3209
  const payload = {
3068
3210
  action: "ENDCALL",
3069
3211
  userId: state.agentId,
@@ -3079,7 +3221,11 @@ function CallControls({ onDataChange }) {
3079
3221
  endcall_type: "CLOSE"
3080
3222
  };
3081
3223
  setPhoneNumber("");
3082
- endCall(END_POINT.END_CALL, payload);
3224
+ endCall(END_POINT.END_CALL, payload, {
3225
+ params: {
3226
+ isBreak: (_q2 = data == null ? void 0 : data.selected_break) != null ? _q2 : false
3227
+ }
3228
+ });
3083
3229
  sdkStateManager.endCall();
3084
3230
  setOpenCallDisposition(false);
3085
3231
  };
@@ -3093,8 +3239,13 @@ function CallControls({ onDataChange }) {
3093
3239
  };
3094
3240
  }, []);
3095
3241
  (0, import_react11.useEffect)(() => {
3242
+ const mic = createMicController();
3243
+ micRef.current = mic;
3244
+ mic.start().catch((err) => {
3245
+ console.error("Failed to start mic:", err);
3246
+ });
3096
3247
  const handleKeyDown = (event) => {
3097
- var _a3, _b2, _c2, _d2, _e2, _f2, _g2;
3248
+ var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
3098
3249
  const fullState = JSON.parse((_a3 = localStorage.getItem("call-control-sdk-state")) != null ? _a3 : "");
3099
3250
  const key = (_b2 = event.key) == null ? void 0 : _b2.toLowerCase();
3100
3251
  if (!event.altKey || ((_c2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _c2.status) !== "ONCALL") {
@@ -3102,21 +3253,23 @@ function CallControls({ onDataChange }) {
3102
3253
  }
3103
3254
  if (key === "m" && String((_d2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _d2.mute) === "0") {
3104
3255
  event.preventDefault();
3256
+ (_e2 = micRef.current) == null ? void 0 : _e2.mute();
3105
3257
  const payload = {
3106
3258
  action: "MUTE",
3107
3259
  userId: fullState.agentId
3108
3260
  };
3109
3261
  muteOrUnMute(END_POINT.MUTE_CALL, payload);
3110
3262
  }
3111
- if (key === "u" && String((_e2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _e2.mute) === "1") {
3263
+ if (key === "u" && String((_f2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _f2.mute) === "1") {
3112
3264
  event.preventDefault();
3113
3265
  const payload = {
3114
3266
  action: "UNMUTE",
3115
3267
  userId: fullState.agentId
3116
3268
  };
3117
3269
  muteOrUnMute(END_POINT.MUTE_CALL, payload);
3270
+ (_g2 = micRef.current) == null ? void 0 : _g2.unmute();
3118
3271
  }
3119
- if (key === "h" && String((_f2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _f2.hold) === "0") {
3272
+ if (key === "h" && String((_h2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _h2.hold) === "0") {
3120
3273
  event.preventDefault();
3121
3274
  const payload = {
3122
3275
  action: "HOLD",
@@ -3124,7 +3277,7 @@ function CallControls({ onDataChange }) {
3124
3277
  };
3125
3278
  holdOrUnHold(END_POINT.HOLD_CALL, payload);
3126
3279
  }
3127
- if (key === "r" && String((_g2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _g2.hold) === "1") {
3280
+ if (key === "r" && String((_i2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _i2.hold) === "1") {
3128
3281
  event.preventDefault();
3129
3282
  const payload = {
3130
3283
  action: "UNHOLD",
@@ -4056,7 +4209,7 @@ async function initSDK({
4056
4209
  apiKey.trim(),
4057
4210
  tenantId.trim(),
4058
4211
  agentId.trim(),
4059
- sdkConfig,
4212
+ __spreadValues(__spreadValues({}, initResult == null ? void 0 : initResult.call_controls), sdkConfig),
4060
4213
  initResult
4061
4214
  );
4062
4215
  } else {