call-control-sdk 6.5.1-uat.4 → 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`
@@ -1310,6 +1311,59 @@ var reducer = (state, action) => {
1310
1311
  }
1311
1312
  throw Error("Unknown action.");
1312
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
+ };
1313
1367
  var usePostRequest = (props = {}) => {
1314
1368
  const { onSuccess = null, onError = null, disabledSuccessToast = false } = props;
1315
1369
  const { showToast } = useToast();
@@ -1451,7 +1505,7 @@ var ConferenceTableRow = ({ each }) => {
1451
1505
  const line_used = __spreadValues(__spreadValues({}, line), data);
1452
1506
  setConferenceCallStart(true);
1453
1507
  const payload = {
1454
- action: "EXTERNAL_CONFERENCE",
1508
+ action: "INTERNAL_CONFERENCE",
1455
1509
  operation: `CALL${line_used.line}`,
1456
1510
  line_used: String(line_used.line),
1457
1511
  thirdparty_no: line_used.phone,
@@ -2454,7 +2508,8 @@ function CallTransferDialog({ open }) {
2454
2508
  ) });
2455
2509
  }
2456
2510
  function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2457
- var _a2, _b, _c, _d;
2511
+ var _a2, _b, _c, _d, _e;
2512
+ const [getDispositions, data] = useGetRequest();
2458
2513
  const [formData, setFormData] = (0, import_react10.useState)({
2459
2514
  disposition: { label: "Resolved", value: "RES" },
2460
2515
  followUp: { label: "No", value: "N" },
@@ -2463,10 +2518,6 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2463
2518
  callbackMins: "",
2464
2519
  selected_break: false
2465
2520
  });
2466
- const dispositionOptions = [
2467
- { label: "Not Interested", value: "NI" },
2468
- { label: "Resolved", value: "RES" }
2469
- ];
2470
2521
  const followUpOptions = [
2471
2522
  { label: "Yes", value: "Y" },
2472
2523
  { label: "No", value: "N" }
@@ -2488,6 +2539,17 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2488
2539
  handleReset();
2489
2540
  setOpen(false);
2490
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]);
2491
2553
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2492
2554
  import_material3.Dialog,
2493
2555
  {
@@ -2540,7 +2602,7 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2540
2602
  import_material3.Autocomplete,
2541
2603
  {
2542
2604
  value: formData.disposition,
2543
- options: dispositionOptions,
2605
+ options: dispositionsOptions,
2544
2606
  getOptionLabel: (opt) => opt.label,
2545
2607
  onChange: (_, val) => handleChange("disposition", val),
2546
2608
  size: "small",
@@ -2605,7 +2667,7 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2605
2667
  ),
2606
2668
  " Mark as break"
2607
2669
  ] }),
2608
- ((_b = (_a2 = formData == null ? void 0 : formData.followUp) == null ? void 0 : _a2.label) == null ? void 0 : _b.toLowerCase()) === "yes" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
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)(
2609
2671
  import_material3.TextField,
2610
2672
  {
2611
2673
  size: "small",
@@ -2623,7 +2685,7 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2623
2685
  ]
2624
2686
  }
2625
2687
  ),
2626
- ((_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)(
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)(
2627
2689
  import_material3.Box,
2628
2690
  {
2629
2691
  display: "flex",