callix-dialer-widget 2.8.0 → 2.8.1

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/WIDGET-README.md CHANGED
@@ -141,6 +141,12 @@ Entrar, avisado de que encerra a sessão de lá. Se o Callix derrubar a sessão
141
141
  Callix web, supervisor, bloqueio), o widget volta à tela de login com o motivo e não reentra
142
142
  sozinho.
143
143
 
144
+ Pausas no modo motor (2.8.1): a lista de pausas é a do serviço no Callix, trazida pela vista
145
+ do motor; a pausa escolhida vai no comando `pause` e o discador mostra o nome dela. Com um
146
+ motor anterior ao 2.8.1 a lista cai numa pausa única ("Pausa") e o motor usa a configurada
147
+ nele. O widget também informa a própria versão ao host, que a registra no log: é o jeito de
148
+ achar navegadores com um build antigo em cache.
149
+
144
150
  Sem `engineUrl` nada muda: o SDK continua rodando no navegador como sempre.
145
151
 
146
152
  ## 🔐 Login e usuário conhecido
@@ -43838,6 +43838,7 @@ class EngineClient {
43838
43838
  role: "tab",
43839
43839
  agentId: this.agentId,
43840
43840
  ...this.options.token ? { token: this.options.token } : {},
43841
+ ...this.options.version ? { version: this.options.version } : {},
43841
43842
  ...sessionToken ? { sessionToken } : {},
43842
43843
  label: this.options.label ?? "Discador",
43843
43844
  ...this.session ? { session: this.session } : {}
@@ -44012,8 +44013,17 @@ class EngineClient {
44012
44013
  this.session = session;
44013
44014
  this.setState({ rejected: null, sessionLost: null });
44014
44015
  if (this.ws && this.ws.readyState === WebSocket.OPEN) {
44015
- this.send({ type: "session", session });
44016
- return;
44016
+ if (this.state.tabId) {
44017
+ this.send({ type: "session", session });
44018
+ return;
44019
+ }
44020
+ const stale = this.ws;
44021
+ this.ws = null;
44022
+ stale.onopen = null;
44023
+ stale.onmessage = null;
44024
+ stale.onclose = null;
44025
+ stale.close();
44026
+ this.setState({ wsState: "closed" });
44017
44027
  }
44018
44028
  if (this.reconnectTimer) {
44019
44029
  clearTimeout(this.reconnectTimer);
@@ -44219,6 +44229,18 @@ function useEngineState(client2) {
44219
44229
  return useSyncExternalStore(client2.subscribe.bind(client2), client2.getState.bind(client2), client2.getState.bind(client2));
44220
44230
  }
44221
44231
  const ENGINE_BREAKS = [{ id: 0, name: "Pausa" }];
44232
+ function breaksFromView(view) {
44233
+ var _a2;
44234
+ const breaks = (_a2 = view == null ? void 0 : view.snapshot) == null ? void 0 : _a2.leg.breaks;
44235
+ return breaks && breaks.length > 0 ? breaks.map((b) => ({ id: b.id, name: b.name })) : ENGINE_BREAKS;
44236
+ }
44237
+ function currentBreakFromView(view) {
44238
+ var _a2;
44239
+ return ((_a2 = view.snapshot) == null ? void 0 : _a2.leg.break) ?? breaksFromView(view)[0];
44240
+ }
44241
+ function pauseCommand(breakId) {
44242
+ return typeof breakId === "number" ? { name: "pause", breakId } : { name: "pause" };
44243
+ }
44222
44244
  function toCallQualification(q) {
44223
44245
  return { id: q.id, name: q.name, isSystemQualification: false, systemQualificationType: 0 };
44224
44246
  }
@@ -44351,7 +44373,7 @@ function operatorStateFromView(view, call) {
44351
44373
  case "afterCall":
44352
44374
  return { state: "afterCall" };
44353
44375
  case "onBreak":
44354
- return { state: "onBreak", break: ENGINE_BREAKS[0] };
44376
+ return { state: "onBreak", break: currentBreakFromView(view) };
44355
44377
  case "offline":
44356
44378
  return { state: "offline" };
44357
44379
  case "error":
@@ -44434,7 +44456,7 @@ function useEngineControls(client2) {
44434
44456
  if (status === "onBreak") client2.command({ name: "resume" });
44435
44457
  },
44436
44458
  goOffline: () => void 0,
44437
- enterOnBreak: () => client2.command({ name: "pause" }),
44459
+ enterOnBreak: (breakId) => client2.command(pauseCommand(breakId)),
44438
44460
  makeManualCall: (phoneNumber) => client2.command({ name: "dial", phone: phoneNumber }),
44439
44461
  finishAfterCall: (data) => {
44440
44462
  if (typeof data.qualificationId === "number") client2.command({ name: "qualify", qualificationId: data.qualificationId, result: data.result === "failure" ? "discard" : "success" });
@@ -44488,7 +44510,8 @@ const operators = /* @__PURE__ */ new WeakMap();
44488
44510
  function engineOperator(client2) {
44489
44511
  let operator = operators.get(client2);
44490
44512
  if (!operator) {
44491
- const breaks = new EngineSignal(ENGINE_BREAKS);
44513
+ const breaks = new EngineSignal(breaksFromView(client2.getState().view));
44514
+ client2.subscribe(() => breaks.set(breaksFromView(client2.getState().view)));
44492
44515
  operator = {
44493
44516
  breaks,
44494
44517
  user: client2.userSignal,
@@ -44503,7 +44526,7 @@ function engineOperator(client2) {
44503
44526
  var _a2, _b;
44504
44527
  if (((_b = (_a2 = client2.getState().view) == null ? void 0 : _a2.snapshot) == null ? void 0 : _b.leg.status) === "onBreak") client2.command({ name: "resume" });
44505
44528
  },
44506
- enterOnBreak: () => client2.command({ name: "pause" }),
44529
+ enterOnBreak: (breakId) => client2.command(pauseCommand(breakId)),
44507
44530
  makeManualCall: (phoneNumber) => client2.command({ name: "dial", phone: phoneNumber }),
44508
44531
  finishAfterCall: (data) => {
44509
44532
  if (typeof data.qualificationId === "number") client2.command({ name: "qualify", qualificationId: data.qualificationId, result: data.result === "failure" ? "discard" : "success" });
@@ -58687,7 +58710,7 @@ function AuthenticatedMobileDialer({
58687
58710
  showClientInfoModal = false,
58688
58711
  density
58689
58712
  }) {
58690
- var _a2, _b, _c, _d;
58713
+ var _a2, _b, _c, _d, _e;
58691
58714
  const { skipManualQualification } = useDialerConfig();
58692
58715
  const [dialValue, setDialValue] = useState("");
58693
58716
  const [activeScreen, setActiveScreen] = useState("dialer");
@@ -59400,11 +59423,12 @@ function AuthenticatedMobileDialer({
59400
59423
  if (isOnBreak) return "paused";
59401
59424
  return "available";
59402
59425
  }, [isError, isOnBreak]);
59426
+ const activeBreakName = (operatorState == null ? void 0 : operatorState.state) === "onBreak" ? (_a2 = operatorState.break) == null ? void 0 : _a2.name : void 0;
59403
59427
  const statusBadgeText = useMemo(() => {
59404
59428
  if (isError) return (dialerNotice == null ? void 0 : dialerNotice.source) === "device" ? dialerNotice.title : "Erro";
59405
- if (isOnBreak) return currentBreakName || "Em pausa";
59429
+ if (isOnBreak) return currentBreakName || activeBreakName || "Em pausa";
59406
59430
  return "Disponível";
59407
- }, [dialerNotice, isError, isOnBreak, currentBreakName]);
59431
+ }, [dialerNotice, isError, isOnBreak, currentBreakName, activeBreakName]);
59408
59432
  const pauseDurationLabel = useMemo(() => {
59409
59433
  const hours = Math.floor(pauseDurationSeconds / 3600);
59410
59434
  const minutes = Math.floor(pauseDurationSeconds % 3600 / 60).toString().padStart(2, "0");
@@ -59542,15 +59566,15 @@ function AuthenticatedMobileDialer({
59542
59566
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "client-card-header", children: [
59543
59567
  /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-user-circle client-avatar" }),
59544
59568
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "client-main-info", children: [
59545
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-name", id: "clientName", children: findValue(contactData.finalData, ["DECISOR", "NOME", "CLIENTE", "PROSPECT"]) ?? ((_a2 = callInfo.info.campaignContact) == null ? void 0 : _a2.label) ?? "--" }),
59546
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-company", id: "clientCompany", children: findValue(contactData.finalData, ["EMPRESA", "RAZAO SOCIAL", "RAZÃO SOCIAL", "RAZAO_SOCIAL"]) ?? ((_b = callInfo.info.campaign) == null ? void 0 : _b.name) ?? "--" })
59569
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-name", id: "clientName", children: findValue(contactData.finalData, ["DECISOR", "NOME", "CLIENTE", "PROSPECT"]) ?? ((_b = callInfo.info.campaignContact) == null ? void 0 : _b.label) ?? "--" }),
59570
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-company", id: "clientCompany", children: findValue(contactData.finalData, ["EMPRESA", "RAZAO SOCIAL", "RAZÃO SOCIAL", "RAZAO_SOCIAL"]) ?? ((_c = callInfo.info.campaign) == null ? void 0 : _c.name) ?? "--" })
59547
59571
  ] })
59548
59572
  ] }),
59549
59573
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "client-card-divider" }),
59550
59574
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "client-info-list", children: [
59551
59575
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "client-info-row", children: [
59552
59576
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-info-label", children: "Socio" }),
59553
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-info-value", children: findValue(contactData.finalData, ["SOCIO", "PROSPECT", "DECISOR", "NOME", "CLIENTE"]) ?? ((_c = callInfo.info.campaignContact) == null ? void 0 : _c.label) ?? "--" })
59577
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-info-value", children: findValue(contactData.finalData, ["SOCIO", "PROSPECT", "DECISOR", "NOME", "CLIENTE"]) ?? ((_d = callInfo.info.campaignContact) == null ? void 0 : _d.label) ?? "--" })
59554
59578
  ] }),
59555
59579
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "client-info-row", children: [
59556
59580
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-info-label", children: "Empresa" }),
@@ -59747,7 +59771,7 @@ function AuthenticatedMobileDialer({
59747
59771
  {
59748
59772
  isOpen: isClientInfoModalOpen,
59749
59773
  campaignCallInfo,
59750
- campaignContactPhoneId: ((_d = currentCall == null ? void 0 : currentCall.data) == null ? void 0 : _d.campaignContactPhoneId) ?? null,
59774
+ campaignContactPhoneId: ((_e = currentCall == null ? void 0 : currentCall.data) == null ? void 0 : _e.campaignContactPhoneId) ?? null,
59751
59775
  callDuration: callDurationSeconds,
59752
59776
  isCallActive: isInCall || isConnecting,
59753
59777
  onClose: () => setIsClientInfoModalOpen(false)
@@ -60731,7 +60755,7 @@ function ClickToCallAgent({ enabled = true, pollIntervalMs, sessionToken, onTask
60731
60755
  }, [enabled, pollIntervalMs, sessionToken]);
60732
60756
  return null;
60733
60757
  }
60734
- const WIDGET_VERSION = "2.8.0";
60758
+ const WIDGET_VERSION = "2.8.1";
60735
60759
  let currentSipWebSocket = null;
60736
60760
  function sendSipUnregisterIfPossible(ws) {
60737
60761
  if (ws.readyState !== WebSocket.OPEN) return;
@@ -61131,6 +61155,7 @@ function DialerWrapper({ options, containerEl }) {
61131
61155
  const client2 = new EngineClient({
61132
61156
  url: options.engineUrl ?? "",
61133
61157
  token: options.engineToken || void 0,
61158
+ version: WIDGET_VERSION,
61134
61159
  // credencial da aba: o token da sessão do Callix guardado neste navegador (lido a cada
61135
61160
  // hello, para a reconexão depois de uma troca de sessão pegar o token novo)
61136
61161
  sessionToken: () => readStoredToken(user),