callix-dialer-widget 1.5.4 → 1.6.0
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-widget/callix-dialer.css +1 -0
- package/dist-widget/callix-dialer.es.js +1407 -226
- package/dist-widget/callix-dialer.es.js.map +1 -1
- package/dist-widget/callix-dialer.umd.js +5 -5
- package/dist-widget/callix-dialer.umd.js.map +1 -1
- package/dist-widget/package.json +61 -0
- package/dist-widget/test-single-widget.html +324 -0
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
6
6
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
7
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
8
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
9
|
-
import React, { useEffect, useState,
|
|
9
|
+
import React, { useEffect, useState, useMemo, useRef, useCallback, createContext, StrictMode, useContext } from "react";
|
|
10
10
|
import require$$0$2, { createPortal } from "react-dom";
|
|
11
11
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
12
12
|
function getAugmentedNamespace(n) {
|
|
@@ -48284,6 +48284,12 @@ function FiAlertCircle(props) {
|
|
|
48284
48284
|
function FiAlertTriangle(props) {
|
|
48285
48285
|
return GenIcon({ "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "d": "M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" }, "child": [] }, { "tag": "line", "attr": { "x1": "12", "y1": "9", "x2": "12", "y2": "13" }, "child": [] }, { "tag": "line", "attr": { "x1": "12", "y1": "17", "x2": "12.01", "y2": "17" }, "child": [] }] })(props);
|
|
48286
48286
|
}
|
|
48287
|
+
function FiArrowLeft(props) {
|
|
48288
|
+
return GenIcon({ "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "line", "attr": { "x1": "19", "y1": "12", "x2": "5", "y2": "12" }, "child": [] }, { "tag": "polyline", "attr": { "points": "12 19 5 12 12 5" }, "child": [] }] })(props);
|
|
48289
|
+
}
|
|
48290
|
+
function FiBriefcase(props) {
|
|
48291
|
+
return GenIcon({ "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "rect", "attr": { "x": "2", "y": "7", "width": "20", "height": "14", "rx": "2", "ry": "2" }, "child": [] }, { "tag": "path", "attr": { "d": "M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16" }, "child": [] }] })(props);
|
|
48292
|
+
}
|
|
48287
48293
|
function FiCheckCircle(props) {
|
|
48288
48294
|
return GenIcon({ "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "d": "M22 11.08V12a10 10 0 1 1-5.93-9.14" }, "child": [] }, { "tag": "polyline", "attr": { "points": "22 4 12 14.01 9 11.01" }, "child": [] }] })(props);
|
|
48289
48295
|
}
|
|
@@ -48293,6 +48299,9 @@ function FiClock(props) {
|
|
|
48293
48299
|
function FiDelete(props) {
|
|
48294
48300
|
return GenIcon({ "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "d": "M21 4H8l-7 8 7 8h13a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2z" }, "child": [] }, { "tag": "line", "attr": { "x1": "18", "y1": "9", "x2": "12", "y2": "15" }, "child": [] }, { "tag": "line", "attr": { "x1": "12", "y1": "9", "x2": "18", "y2": "15" }, "child": [] }] })(props);
|
|
48295
48301
|
}
|
|
48302
|
+
function FiHash(props) {
|
|
48303
|
+
return GenIcon({ "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "line", "attr": { "x1": "4", "y1": "9", "x2": "20", "y2": "9" }, "child": [] }, { "tag": "line", "attr": { "x1": "4", "y1": "15", "x2": "20", "y2": "15" }, "child": [] }, { "tag": "line", "attr": { "x1": "10", "y1": "3", "x2": "8", "y2": "21" }, "child": [] }, { "tag": "line", "attr": { "x1": "16", "y1": "3", "x2": "14", "y2": "21" }, "child": [] }] })(props);
|
|
48304
|
+
}
|
|
48296
48305
|
function FiHeadphones(props) {
|
|
48297
48306
|
return GenIcon({ "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "d": "M3 18v-6a9 9 0 0 1 18 0v6" }, "child": [] }, { "tag": "path", "attr": { "d": "M21 19a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3zM3 19a2 2 0 0 0 2 2h1a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2H3z" }, "child": [] }] })(props);
|
|
48298
48307
|
}
|
|
@@ -48329,6 +48338,9 @@ function FiPlus(props) {
|
|
|
48329
48338
|
function FiSettings(props) {
|
|
48330
48339
|
return GenIcon({ "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "circle", "attr": { "cx": "12", "cy": "12", "r": "3" }, "child": [] }, { "tag": "path", "attr": { "d": "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" }, "child": [] }] })(props);
|
|
48331
48340
|
}
|
|
48341
|
+
function FiSmartphone(props) {
|
|
48342
|
+
return GenIcon({ "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "rect", "attr": { "x": "5", "y": "2", "width": "14", "height": "20", "rx": "2", "ry": "2" }, "child": [] }, { "tag": "line", "attr": { "x1": "12", "y1": "18", "x2": "12.01", "y2": "18" }, "child": [] }] })(props);
|
|
48343
|
+
}
|
|
48332
48344
|
function FiUser(props) {
|
|
48333
48345
|
return GenIcon({ "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "d": "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" }, "child": [] }, { "tag": "circle", "attr": { "cx": "12", "cy": "7", "r": "4" }, "child": [] }] })(props);
|
|
48334
48346
|
}
|
|
@@ -52815,7 +52827,9 @@ if (!globalTwind.__twindInitialized) {
|
|
|
52815
52827
|
const config = {
|
|
52816
52828
|
presets: [
|
|
52817
52829
|
presetTailwind({
|
|
52818
|
-
|
|
52830
|
+
// IMPORTANTE: Desabilitar preflight para evitar conflitos com CSS do MobileDialer
|
|
52831
|
+
// e outros estilos do host. Preflight reseta margin, padding, box-sizing etc.
|
|
52832
|
+
disablePreflight: true
|
|
52819
52833
|
})
|
|
52820
52834
|
],
|
|
52821
52835
|
theme: {
|
|
@@ -52831,8 +52845,8 @@ if (!globalTwind.__twindInitialized) {
|
|
|
52831
52845
|
setup(config);
|
|
52832
52846
|
globalTwind.__twindInitialized = true;
|
|
52833
52847
|
}
|
|
52834
|
-
const API_BASE_URL$
|
|
52835
|
-
function getSessionToken$
|
|
52848
|
+
const API_BASE_URL$2 = typeof window !== "undefined" ? window.__CALLIX_API_BASE_URL__ || (window.location.origin.includes("localhost") ? window.location.origin : "https://callix-zeta.vercel.app") : "";
|
|
52849
|
+
function getSessionToken$2() {
|
|
52836
52850
|
if (typeof window === "undefined") return null;
|
|
52837
52851
|
const lastUsername = localStorage.getItem("callix_dialer_last_username");
|
|
52838
52852
|
if (lastUsername) {
|
|
@@ -52853,8 +52867,8 @@ function getSessionToken$1() {
|
|
|
52853
52867
|
}
|
|
52854
52868
|
return null;
|
|
52855
52869
|
}
|
|
52856
|
-
function getAuthHeaders$
|
|
52857
|
-
const token = getSessionToken$
|
|
52870
|
+
function getAuthHeaders$2() {
|
|
52871
|
+
const token = getSessionToken$2();
|
|
52858
52872
|
const headers = {
|
|
52859
52873
|
"Content-Type": "application/json"
|
|
52860
52874
|
};
|
|
@@ -52864,19 +52878,18 @@ function getAuthHeaders$1() {
|
|
|
52864
52878
|
} else {
|
|
52865
52879
|
try {
|
|
52866
52880
|
const keys = Array.from({ length: localStorage.length }, (_4, i2) => localStorage.key(i2)).filter(Boolean);
|
|
52867
|
-
console.warn("[CallInfoDisplay] Nenhum token encontrado no localStorage. Chaves
|
|
52881
|
+
console.warn("[CallInfoDisplay] Nenhum token encontrado no localStorage. Chaves:", keys);
|
|
52868
52882
|
} catch {
|
|
52869
52883
|
}
|
|
52870
52884
|
}
|
|
52871
52885
|
return headers;
|
|
52872
52886
|
}
|
|
52873
|
-
async function getCampaignConfig$
|
|
52874
|
-
const url = `${API_BASE_URL$
|
|
52887
|
+
async function getCampaignConfig$2(contactId) {
|
|
52888
|
+
const url = `${API_BASE_URL$2}/api/campaign-config/${contactId}`;
|
|
52875
52889
|
const response = await fetch(url, {
|
|
52876
52890
|
method: "GET",
|
|
52877
|
-
headers: getAuthHeaders$
|
|
52891
|
+
headers: getAuthHeaders$2(),
|
|
52878
52892
|
credentials: "omit"
|
|
52879
|
-
// API usa localStorage, não cookies
|
|
52880
52893
|
});
|
|
52881
52894
|
if (!response.ok) {
|
|
52882
52895
|
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
@@ -52885,11 +52898,11 @@ async function getCampaignConfig$1(contactId) {
|
|
|
52885
52898
|
const json = await response.json();
|
|
52886
52899
|
return json;
|
|
52887
52900
|
}
|
|
52888
|
-
async function getCodeToNameMapping(campaignModelId) {
|
|
52889
|
-
const url = `${API_BASE_URL$
|
|
52901
|
+
async function getCodeToNameMapping$1(campaignModelId) {
|
|
52902
|
+
const url = `${API_BASE_URL$2}/api/campaign-fields/${campaignModelId}`;
|
|
52890
52903
|
const response = await fetch(url, {
|
|
52891
52904
|
method: "GET",
|
|
52892
|
-
headers: getAuthHeaders$
|
|
52905
|
+
headers: getAuthHeaders$2(),
|
|
52893
52906
|
credentials: "omit"
|
|
52894
52907
|
});
|
|
52895
52908
|
if (!response.ok) {
|
|
@@ -52899,11 +52912,11 @@ async function getCodeToNameMapping(campaignModelId) {
|
|
|
52899
52912
|
const json = await response.json();
|
|
52900
52913
|
return json;
|
|
52901
52914
|
}
|
|
52902
|
-
async function getCustomerCodeToNameMapping(formId) {
|
|
52903
|
-
const url = `${API_BASE_URL$
|
|
52915
|
+
async function getCustomerCodeToNameMapping$1(formId) {
|
|
52916
|
+
const url = `${API_BASE_URL$2}/api/campaign-contact/0?source=customer&formId=${encodeURIComponent(String(formId))}`;
|
|
52904
52917
|
const response = await fetch(url, {
|
|
52905
52918
|
method: "GET",
|
|
52906
|
-
headers: getAuthHeaders$
|
|
52919
|
+
headers: getAuthHeaders$2(),
|
|
52907
52920
|
credentials: "omit"
|
|
52908
52921
|
});
|
|
52909
52922
|
if (!response.ok) {
|
|
@@ -52923,11 +52936,11 @@ async function getCustomerCodeToNameMapping(formId) {
|
|
|
52923
52936
|
}
|
|
52924
52937
|
return mapping;
|
|
52925
52938
|
}
|
|
52926
|
-
async function getContactValues$
|
|
52927
|
-
const url = `${API_BASE_URL$
|
|
52939
|
+
async function getContactValues$2(contactId) {
|
|
52940
|
+
const url = `${API_BASE_URL$2}/api/campaign-contact/${contactId}`;
|
|
52928
52941
|
const response = await fetch(url, {
|
|
52929
52942
|
method: "GET",
|
|
52930
|
-
headers: getAuthHeaders$
|
|
52943
|
+
headers: getAuthHeaders$2(),
|
|
52931
52944
|
credentials: "omit"
|
|
52932
52945
|
});
|
|
52933
52946
|
if (!response.ok) {
|
|
@@ -52937,11 +52950,11 @@ async function getContactValues$1(contactId) {
|
|
|
52937
52950
|
const json = await response.json();
|
|
52938
52951
|
return json;
|
|
52939
52952
|
}
|
|
52940
|
-
async function getCustomerContactValues$
|
|
52941
|
-
const url = `${API_BASE_URL$
|
|
52953
|
+
async function getCustomerContactValues$2(customerId) {
|
|
52954
|
+
const url = `${API_BASE_URL$2}/api/campaign-fields/0?source=customer&customerId=${encodeURIComponent(String(customerId))}`;
|
|
52942
52955
|
const response = await fetch(url, {
|
|
52943
52956
|
method: "GET",
|
|
52944
|
-
headers: getAuthHeaders$
|
|
52957
|
+
headers: getAuthHeaders$2(),
|
|
52945
52958
|
credentials: "omit"
|
|
52946
52959
|
});
|
|
52947
52960
|
if (!response.ok) {
|
|
@@ -52951,6 +52964,28 @@ async function getCustomerContactValues$1(customerId) {
|
|
|
52951
52964
|
const json = await response.json();
|
|
52952
52965
|
return json;
|
|
52953
52966
|
}
|
|
52967
|
+
function findValue$1(finalData, candidates) {
|
|
52968
|
+
const entries = Object.entries(finalData);
|
|
52969
|
+
const lowerCandidates = candidates.map((item) => item.toLowerCase());
|
|
52970
|
+
for (const [key, value] of entries) {
|
|
52971
|
+
if (lowerCandidates.includes(key.toLowerCase())) {
|
|
52972
|
+
return value;
|
|
52973
|
+
}
|
|
52974
|
+
}
|
|
52975
|
+
return void 0;
|
|
52976
|
+
}
|
|
52977
|
+
function formatPhoneValue(raw) {
|
|
52978
|
+
if (!raw) return "-";
|
|
52979
|
+
const digits = raw.replace(/\D/g, "");
|
|
52980
|
+
if (digits.length >= 10) {
|
|
52981
|
+
const ddd = digits.slice(0, 2);
|
|
52982
|
+
const core2 = digits.slice(2, digits.length - 4);
|
|
52983
|
+
const tail2 = digits.slice(-4);
|
|
52984
|
+
const formattedCore = core2.length > 5 ? `${core2.slice(0, core2.length - 4)} ${core2.slice(core2.length - 4)}` : core2;
|
|
52985
|
+
return `(${ddd}) ${formattedCore}-${tail2}`.replace(/\s+/g, " ").trim();
|
|
52986
|
+
}
|
|
52987
|
+
return raw.trim();
|
|
52988
|
+
}
|
|
52954
52989
|
function CallInfoDisplay() {
|
|
52955
52990
|
const callInfo = clientSdkReactExports.useCallOperatorCurrentCallInfo();
|
|
52956
52991
|
useEffect(() => {
|
|
@@ -52966,12 +53001,12 @@ function CallInfoDisplay() {
|
|
|
52966
53001
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(CampaignCallInfoDisplay, { campaignCallInfo: callInfo.info });
|
|
52967
53002
|
}
|
|
52968
53003
|
if (callInfo) {
|
|
52969
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "
|
|
53004
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs font-semibold text-amber-700", children: "Chamada manual (sem informações de campanha)" }) });
|
|
52970
53005
|
}
|
|
52971
53006
|
return null;
|
|
52972
53007
|
}
|
|
52973
53008
|
function CampaignCallInfoDisplay(props) {
|
|
52974
|
-
const { campaign,
|
|
53009
|
+
const { campaign, campaignContact } = props.campaignCallInfo;
|
|
52975
53010
|
const [contactData, setContactData] = useState({
|
|
52976
53011
|
finalData: {},
|
|
52977
53012
|
isLoading: false,
|
|
@@ -52990,30 +53025,23 @@ function CampaignCallInfoDisplay(props) {
|
|
|
52990
53025
|
setContactData({ finalData: {}, isLoading: true, error: null });
|
|
52991
53026
|
try {
|
|
52992
53027
|
const customer = campaignContact.customer;
|
|
52993
|
-
console.log("[CampaignCallInfoDisplay] 1. Verificando customer no campaignContact:", customer);
|
|
52994
53028
|
let codeToNameMap = {};
|
|
52995
53029
|
let contactValues = {};
|
|
52996
53030
|
if ((customer == null ? void 0 : customer.id) && (customer == null ? void 0 : customer.formId)) {
|
|
52997
|
-
console.log("[CampaignCallInfoDisplay] 2a. Modo CUSTOMER: buscando rows (formId) e dados (customerId)...");
|
|
52998
53031
|
[codeToNameMap, contactValues] = await Promise.all([
|
|
52999
|
-
getCustomerCodeToNameMapping(customer.formId),
|
|
53000
|
-
getCustomerContactValues$
|
|
53032
|
+
getCustomerCodeToNameMapping$1(customer.formId),
|
|
53033
|
+
getCustomerContactValues$2(customer.id)
|
|
53001
53034
|
]);
|
|
53002
53035
|
} else {
|
|
53003
|
-
|
|
53004
|
-
const config = await getCampaignConfig$1(campaignContact.id);
|
|
53005
|
-
console.log("[CampaignCallInfoDisplay] 2b. Config recebida:", config);
|
|
53036
|
+
const config = await getCampaignConfig$2(campaignContact.id);
|
|
53006
53037
|
if (!config.campaignModelId) {
|
|
53007
53038
|
throw new Error("campaignModelId não encontrado");
|
|
53008
53039
|
}
|
|
53009
|
-
console.log("[CampaignCallInfoDisplay] 3. Buscando mapeamento e valores em paralelo...");
|
|
53010
53040
|
[codeToNameMap, contactValues] = await Promise.all([
|
|
53011
|
-
getCodeToNameMapping(config.campaignModelId),
|
|
53012
|
-
getContactValues$
|
|
53041
|
+
getCodeToNameMapping$1(config.campaignModelId),
|
|
53042
|
+
getContactValues$2(campaignContact.id)
|
|
53013
53043
|
]);
|
|
53014
53044
|
}
|
|
53015
|
-
console.log("[CampaignCallInfoDisplay] 4. Mapeamento recebido:", codeToNameMap);
|
|
53016
|
-
console.log("[CampaignCallInfoDisplay] 5. Valores recebidos:", contactValues);
|
|
53017
53045
|
const finalData = {};
|
|
53018
53046
|
Object.entries(contactValues).forEach(([code, value]) => {
|
|
53019
53047
|
if (code in codeToNameMap) {
|
|
@@ -53021,7 +53049,6 @@ function CampaignCallInfoDisplay(props) {
|
|
|
53021
53049
|
}
|
|
53022
53050
|
});
|
|
53023
53051
|
if (!cancelled) {
|
|
53024
|
-
console.log("[CampaignCallInfoDisplay] ✅ Dados finais mapeados:", finalData);
|
|
53025
53052
|
setContactData({
|
|
53026
53053
|
finalData,
|
|
53027
53054
|
isLoading: false,
|
|
@@ -53031,7 +53058,7 @@ function CampaignCallInfoDisplay(props) {
|
|
|
53031
53058
|
}
|
|
53032
53059
|
} catch (error2) {
|
|
53033
53060
|
if (!cancelled) {
|
|
53034
|
-
console.error("[CampaignCallInfoDisplay]
|
|
53061
|
+
console.error("[CampaignCallInfoDisplay] Erro ao buscar dados:", error2);
|
|
53035
53062
|
const errorMessage = error2 instanceof Error ? error2.message : "Erro ao buscar dados do contato";
|
|
53036
53063
|
setContactData({
|
|
53037
53064
|
finalData: {},
|
|
@@ -53045,73 +53072,76 @@ function CampaignCallInfoDisplay(props) {
|
|
|
53045
53072
|
return () => {
|
|
53046
53073
|
cancelled = true;
|
|
53047
53074
|
};
|
|
53048
|
-
}, [campaignContact == null ? void 0 : campaignContact.id, fetchedContactId]);
|
|
53049
|
-
const
|
|
53050
|
-
|
|
53051
|
-
|
|
53052
|
-
|
|
53053
|
-
|
|
53054
|
-
|
|
53055
|
-
|
|
53056
|
-
|
|
53057
|
-
|
|
53058
|
-
|
|
53059
|
-
|
|
53060
|
-
|
|
53061
|
-
|
|
53062
|
-
|
|
53063
|
-
|
|
53064
|
-
|
|
53065
|
-
|
|
53066
|
-
|
|
53067
|
-
|
|
53068
|
-
|
|
53069
|
-
|
|
53070
|
-
|
|
53071
|
-
|
|
53075
|
+
}, [campaignContact, campaignContact == null ? void 0 : campaignContact.id, fetchedContactId]);
|
|
53076
|
+
const prioritizedFields = useMemo(
|
|
53077
|
+
() => [
|
|
53078
|
+
{ label: "Decisor", keys: ["DECISOR"], icon: /* @__PURE__ */ jsxRuntimeExports.jsx(FiUser, { className: "text-sm" }) },
|
|
53079
|
+
{ label: "Empresa", keys: ["EMPRESA", "RAZAO SOCIAL"], icon: /* @__PURE__ */ jsxRuntimeExports.jsx(FiBriefcase, { className: "text-sm" }) },
|
|
53080
|
+
{ label: "Dívida ativa", keys: ["DIVIDA ATIVA", "DÍVIDA ATIVA"], icon: /* @__PURE__ */ jsxRuntimeExports.jsx(FiHash, { className: "text-sm" }) },
|
|
53081
|
+
{ label: "Telefone", keys: ["TELEFONE", "CELULAR", "WHATSAPP"], icon: /* @__PURE__ */ jsxRuntimeExports.jsx(FiSmartphone, { className: "text-sm" }) }
|
|
53082
|
+
],
|
|
53083
|
+
[]
|
|
53084
|
+
);
|
|
53085
|
+
const highlightData = useMemo(() => {
|
|
53086
|
+
return prioritizedFields.map((field) => {
|
|
53087
|
+
const rawValue = (field.label === "Telefone" ? findValue$1(contactData.finalData, field.keys) ?? (campaignContact == null ? void 0 : campaignContact.phoneNumber) : findValue$1(contactData.finalData, field.keys)) || "";
|
|
53088
|
+
const display2 = field.label === "Telefone" ? formatPhoneValue(rawValue) : (rawValue || "-").toString().trim() || "-";
|
|
53089
|
+
return {
|
|
53090
|
+
...field,
|
|
53091
|
+
value: display2,
|
|
53092
|
+
isEmpty: !rawValue
|
|
53093
|
+
};
|
|
53094
|
+
});
|
|
53095
|
+
}, [campaignContact == null ? void 0 : campaignContact.phoneNumber, contactData.finalData, prioritizedFields]);
|
|
53096
|
+
const hasData = highlightData.some((item) => !item.isEmpty);
|
|
53097
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4 rounded-2xl border border-slate-200 bg-white/90 p-3 shadow-sm", children: [
|
|
53098
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-3 flex items-center justify-between gap-2", children: [
|
|
53099
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
53100
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "inline-flex h-9 w-9 items-center justify-center rounded-2xl bg-emerald-500 text-white shadow-inner", children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiPhoneCall, { className: "text-base" }) }),
|
|
53101
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", children: [
|
|
53102
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[10px] font-semibold uppercase tracking-[0.15em] text-slate-500", children: "Campanha" }),
|
|
53103
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "truncate text-sm font-bold text-slate-900", children: (campaign == null ? void 0 : campaign.name) || "Chamada de campanha" })
|
|
53104
|
+
] })
|
|
53105
|
+
] }),
|
|
53106
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-1 text-[10px] font-bold uppercase text-emerald-700", children: [
|
|
53107
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "h-1.5 w-1.5 rounded-full bg-emerald-500" }),
|
|
53108
|
+
"Em chamada"
|
|
53109
|
+
] })
|
|
53072
53110
|
] }),
|
|
53073
|
-
contactData.isLoading && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "
|
|
53074
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "inline-block h-
|
|
53075
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-slate-600
|
|
53111
|
+
contactData.isLoading && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-xl border border-slate-200 bg-slate-50 p-4 text-center", children: [
|
|
53112
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mx-auto mb-2 inline-block h-7 w-7 animate-spin rounded-full border-2 border-emerald-500 border-t-transparent" }),
|
|
53113
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs font-medium text-slate-600", children: "Carregando dados do contato..." })
|
|
53076
53114
|
] }),
|
|
53077
|
-
contactData.error && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "
|
|
53078
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2
|
|
53079
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
53080
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-
|
|
53115
|
+
contactData.error && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-xl border border-rose-200 bg-rose-50 p-3", children: [
|
|
53116
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-1 flex items-center gap-2", children: [
|
|
53117
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiAlertTriangle, { className: "text-sm text-rose-600" }),
|
|
53118
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs font-semibold text-rose-700", children: "Erro ao carregar dados" })
|
|
53081
53119
|
] }),
|
|
53082
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[
|
|
53120
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "ml-6 text-[11px] text-rose-600", children: contactData.error }),
|
|
53083
53121
|
contactData.error.includes("Muitas requisições") && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
53084
53122
|
"button",
|
|
53085
53123
|
{
|
|
53086
53124
|
onClick: () => setFetchedContactId(null),
|
|
53087
|
-
className: "mt-2 ml-6 text-[
|
|
53125
|
+
className: "mt-2 ml-6 text-[11px] font-semibold text-rose-700 underline hover:text-rose-800",
|
|
53088
53126
|
children: "Tentar novamente"
|
|
53089
53127
|
}
|
|
53090
53128
|
)
|
|
53091
53129
|
] }),
|
|
53092
|
-
!contactData.isLoading && !contactData.error &&
|
|
53093
|
-
|
|
53094
|
-
|
|
53095
|
-
|
|
53096
|
-
|
|
53097
|
-
|
|
53098
|
-
|
|
53099
|
-
|
|
53100
|
-
|
|
53101
|
-
|
|
53102
|
-
|
|
53103
|
-
|
|
53104
|
-
|
|
53105
|
-
|
|
53106
|
-
|
|
53107
|
-
] }),
|
|
53108
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-4 gap-1.5", children: [
|
|
53109
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Field2, { fieldName: "CORRESPONSABILIDADE SOCIO", label: "CORRESP. SÓCIO" }),
|
|
53110
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Field2, { fieldName: "EXECUÇÃO FISCAL", label: "EXECUÇÃO FISCAL" }),
|
|
53111
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Field2, { fieldName: "TRANSAÇÃO COM BENEFICIO", label: "TRANSAÇÃO BENEFÍCIO" }),
|
|
53112
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Field2, { fieldName: "REGIME TRIBUTARIO", label: "REGIME TRIBUTÁRIO" })
|
|
53113
|
-
] })
|
|
53114
|
-
] })
|
|
53130
|
+
!contactData.isLoading && !contactData.error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-2 gap-2 sm:grid-cols-4", children: highlightData.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
53131
|
+
"div",
|
|
53132
|
+
{
|
|
53133
|
+
className: "flex flex-col gap-1 rounded-xl border border-slate-200 bg-slate-50 p-2.5 shadow-[inset_0_1px_0_rgba(255,255,255,0.6)]",
|
|
53134
|
+
children: [
|
|
53135
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-slate-500", children: [
|
|
53136
|
+
item.icon,
|
|
53137
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate", children: item.label })
|
|
53138
|
+
] }),
|
|
53139
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "break-words text-sm font-bold leading-tight text-slate-900", children: item.value || "-" })
|
|
53140
|
+
]
|
|
53141
|
+
},
|
|
53142
|
+
item.label
|
|
53143
|
+
)) }),
|
|
53144
|
+
!contactData.isLoading && !contactData.error && !hasData && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-xl border border-slate-200 bg-slate-50 p-3 text-xs font-medium text-slate-600", children: "Nenhuma informação de campanha disponível para este contato." })
|
|
53115
53145
|
] });
|
|
53116
53146
|
}
|
|
53117
53147
|
function useSignal(signal) {
|
|
@@ -53211,6 +53241,29 @@ function normalizePhoneNumberPaste(pastedText) {
|
|
|
53211
53241
|
}
|
|
53212
53242
|
return cleaned;
|
|
53213
53243
|
}
|
|
53244
|
+
function formatPhoneForDisplay(phoneNumber) {
|
|
53245
|
+
const cleaned = phoneNumber.replace(/\D/g, "");
|
|
53246
|
+
if (cleaned.length === 11) {
|
|
53247
|
+
const ddd = cleaned.substring(0, 2);
|
|
53248
|
+
const part1 = cleaned.substring(2, 7);
|
|
53249
|
+
const part2 = cleaned.substring(7);
|
|
53250
|
+
return `(${ddd}) ${part1}-${part2}`;
|
|
53251
|
+
}
|
|
53252
|
+
if (cleaned.length === 10) {
|
|
53253
|
+
const ddd = cleaned.substring(0, 2);
|
|
53254
|
+
const part1 = cleaned.substring(2, 6);
|
|
53255
|
+
const part2 = cleaned.substring(6);
|
|
53256
|
+
if (["2", "3", "4"].some((prefix) => cleaned.startsWith(prefix))) {
|
|
53257
|
+
return `(${ddd}) ${part1}-${part2}`;
|
|
53258
|
+
}
|
|
53259
|
+
return `(${ddd}) 9${part1}-${part2}`;
|
|
53260
|
+
}
|
|
53261
|
+
return phoneNumber;
|
|
53262
|
+
}
|
|
53263
|
+
function isValidPhoneFormat(phoneNumber) {
|
|
53264
|
+
const cleaned = phoneNumber.replace(/\D/g, "");
|
|
53265
|
+
return cleaned.length === 10 || cleaned.length === 11;
|
|
53266
|
+
}
|
|
53214
53267
|
const DEFAULT_COUNTRY_PREFIX = "+55";
|
|
53215
53268
|
const MAX_DIAL_LENGTH = 32;
|
|
53216
53269
|
const DEFAULT_DIALER_DIMENSIONS = { width: 448, height: 640 };
|
|
@@ -53257,7 +53310,8 @@ function FloatingDialer({
|
|
|
53257
53310
|
onLogout,
|
|
53258
53311
|
isLoadingSession,
|
|
53259
53312
|
sessionError,
|
|
53260
|
-
variant = "default"
|
|
53313
|
+
variant = "default",
|
|
53314
|
+
portalTarget = null
|
|
53261
53315
|
}) {
|
|
53262
53316
|
const containerRef = useRef(null);
|
|
53263
53317
|
const cardRef = useRef(null);
|
|
@@ -53576,7 +53630,9 @@ function FloatingDialer({
|
|
|
53576
53630
|
dialValue,
|
|
53577
53631
|
setDialValue: updateDialValue,
|
|
53578
53632
|
onLogout,
|
|
53579
|
-
variant
|
|
53633
|
+
variant,
|
|
53634
|
+
onRequestClose: () => setIsOpen(false),
|
|
53635
|
+
portalTarget
|
|
53580
53636
|
}
|
|
53581
53637
|
) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
53582
53638
|
LoginForm,
|
|
@@ -53771,17 +53827,32 @@ function LoginForm({ defaultValue, onSubmit, isLoading, error: error2 }) {
|
|
|
53771
53827
|
)
|
|
53772
53828
|
] });
|
|
53773
53829
|
}
|
|
53774
|
-
function AuthenticatedDialer({
|
|
53830
|
+
function AuthenticatedDialer({
|
|
53831
|
+
username,
|
|
53832
|
+
dialValue,
|
|
53833
|
+
setDialValue,
|
|
53834
|
+
onLogout,
|
|
53835
|
+
variant,
|
|
53836
|
+
onRequestClose,
|
|
53837
|
+
portalTarget = null
|
|
53838
|
+
}) {
|
|
53775
53839
|
var _a2, _b;
|
|
53776
|
-
const operator = clientSdkReactExports.useCallOperator();
|
|
53777
53840
|
const isMiniMode = variant === "min";
|
|
53778
53841
|
const { skipManualQualification } = useDialerConfig();
|
|
53779
53842
|
console.log("[FloatingDialer/AuthenticatedDialer] 🔧 skipManualQualification:", skipManualQualification);
|
|
53843
|
+
const operator = clientSdkReactExports.useCallOperator();
|
|
53780
53844
|
const operatorState = clientSdkReactExports.useCallOperatorState();
|
|
53781
53845
|
const currentCall = clientSdkReactExports.useCallOperatorCurrentCall();
|
|
53782
53846
|
const currentCallInfo = clientSdkReactExports.useCallOperatorCurrentCallInfo();
|
|
53783
|
-
const
|
|
53784
|
-
const
|
|
53847
|
+
const rawSuccessQualifications = clientSdkReactExports.useCallOperatorSuccessQualifications();
|
|
53848
|
+
const rawDiscardQualifications = clientSdkReactExports.useCallOperatorDiscardQualifications();
|
|
53849
|
+
const successQualifications = useMemo(() => rawSuccessQualifications ?? [], [rawSuccessQualifications]);
|
|
53850
|
+
const discardQualifications = useMemo(() => rawDiscardQualifications ?? [], [rawDiscardQualifications]);
|
|
53851
|
+
const { makeManualCall, becomeAvailable, finishAfterCall } = clientSdkReactExports.useCallOperatorControls();
|
|
53852
|
+
const { hangup, answer, reject } = clientSdkReactExports.useCallOperatorCurrentCallControls();
|
|
53853
|
+
const [inputMuted, setInputMuted] = clientSdkReactExports.useCallOperatorAudioInputMuted();
|
|
53854
|
+
const [outputMuted, setOutputMuted] = clientSdkReactExports.useCallOperatorAudioOutputMuted();
|
|
53855
|
+
const [outputVolume, setOutputVolume] = clientSdkReactExports.useCallOperatorAudioOutputVolume();
|
|
53785
53856
|
useEffect(() => {
|
|
53786
53857
|
console.log("[FloatingDialer] Estado do operador mudou:", {
|
|
53787
53858
|
state: operatorState == null ? void 0 : operatorState.state,
|
|
@@ -53791,7 +53862,7 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
53791
53862
|
});
|
|
53792
53863
|
}, [operatorState, currentCall]);
|
|
53793
53864
|
useEffect(() => {
|
|
53794
|
-
console.log("[FloatingDialer]
|
|
53865
|
+
console.log("[FloatingDialer] Qualificações:", {
|
|
53795
53866
|
success: successQualifications,
|
|
53796
53867
|
discard: discardQualifications,
|
|
53797
53868
|
callState: operatorState == null ? void 0 : operatorState.state
|
|
@@ -53799,7 +53870,7 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
53799
53870
|
}, [successQualifications, discardQualifications, operatorState == null ? void 0 : operatorState.state]);
|
|
53800
53871
|
useEffect(() => {
|
|
53801
53872
|
if ((currentCall == null ? void 0 : currentCall.direction) === "incoming") {
|
|
53802
|
-
console.log("[FloatingDialer]
|
|
53873
|
+
console.log("[FloatingDialer] 📞 CHAMADA RECEBIDA:", {
|
|
53803
53874
|
call: currentCall,
|
|
53804
53875
|
direction: currentCall.direction,
|
|
53805
53876
|
state: operatorState == null ? void 0 : operatorState.state,
|
|
@@ -53807,8 +53878,6 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
53807
53878
|
});
|
|
53808
53879
|
}
|
|
53809
53880
|
}, [currentCall, operatorState == null ? void 0 : operatorState.state]);
|
|
53810
|
-
const { makeManualCall, becomeAvailable, finishAfterCall } = clientSdkReactExports.useCallOperatorControls();
|
|
53811
|
-
const { hangup, answer, reject } = clientSdkReactExports.useCallOperatorCurrentCallControls();
|
|
53812
53881
|
const [isDialerFocused, setIsDialerFocused] = useState(false);
|
|
53813
53882
|
const dialerCardRef = useRef(null);
|
|
53814
53883
|
const dialDisplayRef = useRef(null);
|
|
@@ -53826,9 +53895,6 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
53826
53895
|
const [audioMetric, setAudioMetric] = useState(INITIAL_AUDIO_METRIC);
|
|
53827
53896
|
const toneContextRef = useRef(null);
|
|
53828
53897
|
const hasRequestedAvailabilityRef = useRef(false);
|
|
53829
|
-
const [inputMuted, setInputMuted] = clientSdkReactExports.useCallOperatorAudioInputMuted();
|
|
53830
|
-
const [outputMuted, setOutputMuted] = clientSdkReactExports.useCallOperatorAudioOutputMuted();
|
|
53831
|
-
const [outputVolume, setOutputVolume] = clientSdkReactExports.useCallOperatorAudioOutputVolume();
|
|
53832
53898
|
const [audioDevices, setAudioDevices] = useState({
|
|
53833
53899
|
inputs: [],
|
|
53834
53900
|
outputs: []
|
|
@@ -53841,6 +53907,11 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
53841
53907
|
const [lastDialedNumber, setLastDialedNumber] = useState(null);
|
|
53842
53908
|
const [isBreakModalOpen, setIsBreakModalOpen] = useState(false);
|
|
53843
53909
|
const [breakError, setBreakError] = useState(null);
|
|
53910
|
+
const [isMobileViewport, setIsMobileViewport] = useState(
|
|
53911
|
+
typeof window !== "undefined" ? window.innerWidth <= 640 : false
|
|
53912
|
+
);
|
|
53913
|
+
const isMobileVariant = variant === "mobile";
|
|
53914
|
+
const isMobileLayout = isMobileVariant || isMobileViewport;
|
|
53844
53915
|
const breaks = useSignal(operator == null ? void 0 : operator.breaks) || [];
|
|
53845
53916
|
const { goOnBreak, goOffBreak } = useOperatorBreak();
|
|
53846
53917
|
const sanitizedDialValue = useMemo(() => dialValue.slice(0, MAX_DIAL_LENGTH), [dialValue]);
|
|
@@ -53883,6 +53954,19 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
53883
53954
|
setCallError(null);
|
|
53884
53955
|
}
|
|
53885
53956
|
}, [callState]);
|
|
53957
|
+
useEffect(() => {
|
|
53958
|
+
if (typeof window === "undefined") {
|
|
53959
|
+
return;
|
|
53960
|
+
}
|
|
53961
|
+
const updateViewport = () => setIsMobileViewport(window.innerWidth <= 640);
|
|
53962
|
+
updateViewport();
|
|
53963
|
+
window.addEventListener("resize", updateViewport);
|
|
53964
|
+
window.addEventListener("orientationchange", updateViewport);
|
|
53965
|
+
return () => {
|
|
53966
|
+
window.removeEventListener("resize", updateViewport);
|
|
53967
|
+
window.removeEventListener("orientationchange", updateViewport);
|
|
53968
|
+
};
|
|
53969
|
+
}, []);
|
|
53886
53970
|
useEffect(() => {
|
|
53887
53971
|
if (callState === "offline") {
|
|
53888
53972
|
setAvailabilityError("Conexao perdida. Tentando reconectar...");
|
|
@@ -54003,9 +54087,6 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
54003
54087
|
}, []);
|
|
54004
54088
|
useEffect(() => {
|
|
54005
54089
|
if (!currentCall || callState !== "callInProgress") {
|
|
54006
|
-
if (callDurationSeconds > 0) {
|
|
54007
|
-
console.log("[FloatingDialer] ?? Timer resetado (chamada n�o est� em progresso)");
|
|
54008
|
-
}
|
|
54009
54090
|
setCallDurationSeconds(0);
|
|
54010
54091
|
setNetworkMetric(INITIAL_NETWORK_METRIC);
|
|
54011
54092
|
setAudioMetric(INITIAL_AUDIO_METRIC);
|
|
@@ -54366,13 +54447,16 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
54366
54447
|
try {
|
|
54367
54448
|
setCallError(null);
|
|
54368
54449
|
setLastDialedNumber(e164Number);
|
|
54369
|
-
|
|
54450
|
+
if (makeManualCall) {
|
|
54451
|
+
void makeManualCall(e164Number);
|
|
54452
|
+
}
|
|
54370
54453
|
} catch (error2) {
|
|
54371
54454
|
console.error("Erro ao iniciar chamada", error2);
|
|
54372
54455
|
setCallError("Nao foi possivel iniciar a ligacao.");
|
|
54373
54456
|
}
|
|
54374
54457
|
}, [isIdle, isOnBreak, sanitizedDialValue, makeManualCall]);
|
|
54375
54458
|
const handleGoOnBreak = useCallback(async (breakId) => {
|
|
54459
|
+
if (!goOnBreak) return;
|
|
54376
54460
|
try {
|
|
54377
54461
|
setBreakError(null);
|
|
54378
54462
|
await goOnBreak(breakId);
|
|
@@ -54384,6 +54468,7 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
54384
54468
|
}
|
|
54385
54469
|
}, [goOnBreak]);
|
|
54386
54470
|
const handleGoOffBreak = useCallback(async () => {
|
|
54471
|
+
if (!goOffBreak) return;
|
|
54387
54472
|
try {
|
|
54388
54473
|
await goOffBreak();
|
|
54389
54474
|
console.log("[FloatingDialer] Saiu da pausa com sucesso");
|
|
@@ -54459,6 +54544,7 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
54459
54544
|
};
|
|
54460
54545
|
}, [isMiniMode, isDialerFocused, handleBackspace, handleClear, handleDial, handleCall, isIdle]);
|
|
54461
54546
|
const handleHangup = useCallback(async () => {
|
|
54547
|
+
if (!hangup) return;
|
|
54462
54548
|
try {
|
|
54463
54549
|
await hangup();
|
|
54464
54550
|
} catch (error2) {
|
|
@@ -54467,6 +54553,7 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
54467
54553
|
}
|
|
54468
54554
|
}, [hangup]);
|
|
54469
54555
|
const handleAnswer = useCallback(async () => {
|
|
54556
|
+
if (!answer) return;
|
|
54470
54557
|
try {
|
|
54471
54558
|
await answer();
|
|
54472
54559
|
} catch (error2) {
|
|
@@ -54475,6 +54562,7 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
54475
54562
|
}
|
|
54476
54563
|
}, [answer]);
|
|
54477
54564
|
const handleReject = useCallback(async () => {
|
|
54565
|
+
if (!reject) return;
|
|
54478
54566
|
try {
|
|
54479
54567
|
await reject();
|
|
54480
54568
|
} catch (error2) {
|
|
@@ -54584,11 +54672,14 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
54584
54672
|
onSubmit: handleFinishAfterCall,
|
|
54585
54673
|
isSubmitting: isSubmittingAfterCall,
|
|
54586
54674
|
errorMessage: afterCallError,
|
|
54587
|
-
onLogout
|
|
54675
|
+
onLogout,
|
|
54676
|
+
isMobile: isMobileLayout,
|
|
54677
|
+
onClose: onRequestClose
|
|
54588
54678
|
}
|
|
54589
54679
|
);
|
|
54590
54680
|
}
|
|
54591
|
-
const
|
|
54681
|
+
const modalOverlayClass = portalTarget ? tw`absolute inset-0 z-50 flex items-center justify-center bg-black/50 p-4` : tw`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`;
|
|
54682
|
+
const breakModalContent = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: modalOverlayClass, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`bg-white rounded-2xl shadow-2xl max-w-md w-full p-6 space-y-4`, children: [
|
|
54592
54683
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center justify-between`, children: [
|
|
54593
54684
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: tw`text-lg font-bold text-slate-800`, children: "Selecione uma Pausa" }),
|
|
54594
54685
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -54639,7 +54730,308 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
54639
54730
|
children: "Cancelar"
|
|
54640
54731
|
}
|
|
54641
54732
|
)
|
|
54642
|
-
] }) })
|
|
54733
|
+
] }) });
|
|
54734
|
+
const breakModal = isBreakModalOpen ? portalTarget ? createPortal(breakModalContent, portalTarget) : breakModalContent : null;
|
|
54735
|
+
const showActiveSummary = isInCall || isConnecting;
|
|
54736
|
+
if (isMobileLayout && !isMiniMode) {
|
|
54737
|
+
const mobileCanUseKeypad = !availabilityError && (canUseKeypad || isIdle || isOnBreak);
|
|
54738
|
+
const displayNumber = dialDisplayText || sanitizedDialValue || "Digite ou cole um numero";
|
|
54739
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54740
|
+
"div",
|
|
54741
|
+
{
|
|
54742
|
+
ref: dialerCardRef,
|
|
54743
|
+
tabIndex: 0,
|
|
54744
|
+
role: "application",
|
|
54745
|
+
"aria-label": "Discador mobile",
|
|
54746
|
+
onFocusCapture: handleFocusWithin,
|
|
54747
|
+
onBlurCapture: handleBlurWithin,
|
|
54748
|
+
className: tw`callix mobile flex min-h-[calc(100vh-3rem)] w-full max-w-full flex-col gap-4 rounded-3xl border border-slate-200 bg-gradient-to-b from-white via-slate-50 to-white p-4 shadow-xl outline-none`,
|
|
54749
|
+
children: [
|
|
54750
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center justify-between gap-2`, children: [
|
|
54751
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54752
|
+
"button",
|
|
54753
|
+
{
|
|
54754
|
+
type: "button",
|
|
54755
|
+
onClick: () => {
|
|
54756
|
+
if (onRequestClose) {
|
|
54757
|
+
onRequestClose();
|
|
54758
|
+
} else {
|
|
54759
|
+
handleClear();
|
|
54760
|
+
}
|
|
54761
|
+
},
|
|
54762
|
+
className: tw`inline-flex items-center gap-2 rounded-full border border-slate-200 bg-white px-3 py-2 text-sm font-semibold text-slate-700 shadow-sm transition hover:border-slate-300 hover:shadow-md`,
|
|
54763
|
+
children: [
|
|
54764
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiArrowLeft, { className: tw`text-base` }),
|
|
54765
|
+
"Voltar"
|
|
54766
|
+
]
|
|
54767
|
+
}
|
|
54768
|
+
),
|
|
54769
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54770
|
+
"div",
|
|
54771
|
+
{
|
|
54772
|
+
className: tw`${statusVisual.badgeClass} inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-[11px] font-bold`,
|
|
54773
|
+
children: [
|
|
54774
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(statusVisual.Icon, { className: tw`text-xs` }),
|
|
54775
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: statusLabel })
|
|
54776
|
+
]
|
|
54777
|
+
}
|
|
54778
|
+
),
|
|
54779
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54780
|
+
"button",
|
|
54781
|
+
{
|
|
54782
|
+
type: "button",
|
|
54783
|
+
onClick: isOnBreak ? handleGoOffBreak : () => setIsBreakModalOpen(true),
|
|
54784
|
+
className: tw`inline-flex items-center gap-1.5 rounded-full border ${isOnBreak ? "border-green-200 bg-green-50 text-green-700" : "border-amber-200 bg-amber-50 text-amber-700"} px-3 py-2 text-sm font-semibold transition hover:shadow-md`,
|
|
54785
|
+
children: [
|
|
54786
|
+
isOnBreak ? /* @__PURE__ */ jsxRuntimeExports.jsx(FiCheckCircle, { className: tw`text-sm` }) : /* @__PURE__ */ jsxRuntimeExports.jsx(FiPauseCircle, { className: tw`text-sm` }),
|
|
54787
|
+
isOnBreak ? "Voltar" : "Pausa"
|
|
54788
|
+
]
|
|
54789
|
+
}
|
|
54790
|
+
)
|
|
54791
|
+
] }),
|
|
54792
|
+
showActiveSummary ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`space-y-3`, children: [
|
|
54793
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(ActiveCallSummary, { statusLabel, callTarget, durationSeconds: callDurationSeconds }),
|
|
54794
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CallInfoDisplay, {})
|
|
54795
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`space-y-2 rounded-2xl border border-slate-200 bg-white px-3 py-3 shadow-inner`, children: [
|
|
54796
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center justify-between`, children: [
|
|
54797
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`text-[11px] font-semibold uppercase tracking-wide text-slate-500`, children: "Número" }),
|
|
54798
|
+
formattedHintNumber && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`text-[11px] font-semibold text-primary`, children: formattedHintNumber })
|
|
54799
|
+
] }),
|
|
54800
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center gap-3`, children: [
|
|
54801
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
54802
|
+
"input",
|
|
54803
|
+
{
|
|
54804
|
+
ref: visibleInputRef,
|
|
54805
|
+
type: "text",
|
|
54806
|
+
inputMode: "tel",
|
|
54807
|
+
value: sanitizedDialValue,
|
|
54808
|
+
onChange: (e) => {
|
|
54809
|
+
const input = e.target;
|
|
54810
|
+
setCursorPosition(input.selectionStart || 0);
|
|
54811
|
+
},
|
|
54812
|
+
onClick: (e) => setCursorPosition(e.target.selectionStart || 0),
|
|
54813
|
+
onKeyUp: (e) => setCursorPosition(e.target.selectionStart || 0),
|
|
54814
|
+
onSelect: (e) => setCursorPosition(e.target.selectionStart || 0),
|
|
54815
|
+
onKeyDown: (e) => {
|
|
54816
|
+
if (!mobileCanUseKeypad) {
|
|
54817
|
+
e.preventDefault();
|
|
54818
|
+
return;
|
|
54819
|
+
}
|
|
54820
|
+
const key = e.key;
|
|
54821
|
+
const input = e.target;
|
|
54822
|
+
const currentPos = input.selectionStart || 0;
|
|
54823
|
+
setCursorPosition(currentPos);
|
|
54824
|
+
if (key === "Backspace") {
|
|
54825
|
+
e.preventDefault();
|
|
54826
|
+
handleBackspace();
|
|
54827
|
+
return;
|
|
54828
|
+
}
|
|
54829
|
+
if (key === "Delete") {
|
|
54830
|
+
e.preventDefault();
|
|
54831
|
+
const capturedPos = currentPos;
|
|
54832
|
+
setDialValue((prevValue) => {
|
|
54833
|
+
if (capturedPos < prevValue.length) {
|
|
54834
|
+
const newValue = prevValue.slice(0, capturedPos) + prevValue.slice(capturedPos + 1);
|
|
54835
|
+
setTimeout(() => {
|
|
54836
|
+
if (visibleInputRef.current) {
|
|
54837
|
+
visibleInputRef.current.setSelectionRange(capturedPos, capturedPos);
|
|
54838
|
+
setCursorPosition(capturedPos);
|
|
54839
|
+
}
|
|
54840
|
+
}, 0);
|
|
54841
|
+
return newValue;
|
|
54842
|
+
}
|
|
54843
|
+
return prevValue;
|
|
54844
|
+
});
|
|
54845
|
+
return;
|
|
54846
|
+
}
|
|
54847
|
+
if (key === "Enter") {
|
|
54848
|
+
e.preventDefault();
|
|
54849
|
+
void handleCall();
|
|
54850
|
+
return;
|
|
54851
|
+
}
|
|
54852
|
+
if (["ArrowLeft", "ArrowRight", "Home", "End"].includes(key)) {
|
|
54853
|
+
return;
|
|
54854
|
+
}
|
|
54855
|
+
if ((e.ctrlKey || e.metaKey) && ["a", "c", "v", "x"].includes(key.toLowerCase())) {
|
|
54856
|
+
return;
|
|
54857
|
+
}
|
|
54858
|
+
if (/^[0-9*#]$/.test(key)) {
|
|
54859
|
+
e.preventDefault();
|
|
54860
|
+
handleDial(key);
|
|
54861
|
+
return;
|
|
54862
|
+
}
|
|
54863
|
+
e.preventDefault();
|
|
54864
|
+
},
|
|
54865
|
+
onPaste: handlePaste,
|
|
54866
|
+
disabled: !mobileCanUseKeypad,
|
|
54867
|
+
placeholder: "Digite ou cole um numero",
|
|
54868
|
+
className: tw`flex-1 bg-transparent text-3xl font-bold text-slate-900 outline-none placeholder:text-slate-300 disabled:opacity-60`
|
|
54869
|
+
}
|
|
54870
|
+
),
|
|
54871
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center gap-2`, children: [
|
|
54872
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
54873
|
+
"button",
|
|
54874
|
+
{
|
|
54875
|
+
type: "button",
|
|
54876
|
+
onClick: handleBackspace,
|
|
54877
|
+
disabled: !mobileCanUseKeypad,
|
|
54878
|
+
className: tw`inline-flex h-10 w-10 items-center justify-center rounded-full border border-slate-200 bg-white text-slate-700 shadow-sm transition hover:border-slate-300 hover:shadow-md disabled:opacity-40`,
|
|
54879
|
+
"aria-label": "Apagar último digito",
|
|
54880
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiDelete, { className: tw`text-lg` })
|
|
54881
|
+
}
|
|
54882
|
+
),
|
|
54883
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
54884
|
+
"button",
|
|
54885
|
+
{
|
|
54886
|
+
type: "button",
|
|
54887
|
+
onClick: handleClear,
|
|
54888
|
+
disabled: !mobileCanUseKeypad,
|
|
54889
|
+
className: tw`inline-flex h-10 w-10 items-center justify-center rounded-full border border-rose-300 bg-rose-50 text-rose-600 shadow-sm transition hover:border-rose-400 hover:bg-rose-100 hover:shadow-md disabled:opacity-40`,
|
|
54890
|
+
"aria-label": "Limpar número",
|
|
54891
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiX, { className: tw`text-lg` })
|
|
54892
|
+
}
|
|
54893
|
+
)
|
|
54894
|
+
] })
|
|
54895
|
+
] }),
|
|
54896
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: tw`text-[11px] font-medium text-slate-500`, children: [
|
|
54897
|
+
"Formatação automática: ",
|
|
54898
|
+
displayNumber
|
|
54899
|
+
] })
|
|
54900
|
+
] }),
|
|
54901
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`grid grid-cols-3 gap-2`, children: keypadKeys.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54902
|
+
"button",
|
|
54903
|
+
{
|
|
54904
|
+
type: "button",
|
|
54905
|
+
onClick: () => handleDial(item.value),
|
|
54906
|
+
disabled: !mobileCanUseKeypad,
|
|
54907
|
+
className: tw`flex h-14 flex-col items-center justify-center rounded-xl border border-slate-200 bg-white text-xl font-bold text-slate-900 shadow-sm transition active:scale-95 hover:border-slate-300 hover:shadow-md disabled:cursor-not-allowed disabled:opacity-40`,
|
|
54908
|
+
children: [
|
|
54909
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: item.value }),
|
|
54910
|
+
item.detail && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`text-[9px] font-semibold uppercase tracking-widest text-slate-400`, children: item.detail })
|
|
54911
|
+
]
|
|
54912
|
+
},
|
|
54913
|
+
item.value
|
|
54914
|
+
)) }),
|
|
54915
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`grid grid-cols-3 gap-2`, children: [
|
|
54916
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54917
|
+
"button",
|
|
54918
|
+
{
|
|
54919
|
+
type: "button",
|
|
54920
|
+
onClick: () => setInputMuted(!inputMuted),
|
|
54921
|
+
className: tw`${inputMuted ? "border-rose-300 bg-rose-50 text-rose-700" : "border-slate-200 bg-white text-slate-700"} flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm font-semibold shadow-sm transition hover:border-slate-300 hover:shadow-md`,
|
|
54922
|
+
children: [
|
|
54923
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(MicIcon, { className: tw`text-base` }),
|
|
54924
|
+
inputMuted ? "Mudo" : "Áudio"
|
|
54925
|
+
]
|
|
54926
|
+
}
|
|
54927
|
+
),
|
|
54928
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54929
|
+
"button",
|
|
54930
|
+
{
|
|
54931
|
+
type: "button",
|
|
54932
|
+
onClick: () => setOutputMuted(!outputMuted),
|
|
54933
|
+
className: tw`${outputMuted ? "border-amber-300 bg-amber-50 text-amber-700" : "border-slate-200 bg-white text-slate-700"} flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm font-semibold shadow-sm transition hover:border-slate-300 hover:shadow-md`,
|
|
54934
|
+
children: [
|
|
54935
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SpeakerIcon, { className: tw`text-base` }),
|
|
54936
|
+
outputMuted ? "Saída off" : `${volumePercent}%`
|
|
54937
|
+
]
|
|
54938
|
+
}
|
|
54939
|
+
),
|
|
54940
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54941
|
+
"button",
|
|
54942
|
+
{
|
|
54943
|
+
type: "button",
|
|
54944
|
+
onClick: isOnBreak ? handleGoOffBreak : () => setIsBreakModalOpen(true),
|
|
54945
|
+
className: tw`${isOnBreak ? "border-green-300 bg-green-50 text-green-700" : "border-amber-300 bg-amber-50 text-amber-700"} flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm font-semibold shadow-sm transition hover:shadow-md`,
|
|
54946
|
+
children: [
|
|
54947
|
+
isOnBreak ? /* @__PURE__ */ jsxRuntimeExports.jsx(FiCheckCircle, { className: tw`text-base` }) : /* @__PURE__ */ jsxRuntimeExports.jsx(FiPauseCircle, { className: tw`text-base` }),
|
|
54948
|
+
isOnBreak ? "Voltar" : "Pausa"
|
|
54949
|
+
]
|
|
54950
|
+
}
|
|
54951
|
+
)
|
|
54952
|
+
] }),
|
|
54953
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex flex-wrap items-center gap-2`, children: [
|
|
54954
|
+
isIdle || isOnBreak ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54955
|
+
"button",
|
|
54956
|
+
{
|
|
54957
|
+
type: "button",
|
|
54958
|
+
onClick: handleCall,
|
|
54959
|
+
disabled: !isNumberValid,
|
|
54960
|
+
className: tw`flex flex-1 min-w-[8rem] items-center justify-center gap-2 rounded-xl bg-green-500 px-4 py-3 text-base font-bold text-white shadow-lg transition hover:bg-green-600 hover:shadow-xl disabled:cursor-not-allowed disabled:opacity-60`,
|
|
54961
|
+
children: [
|
|
54962
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiPhone, { className: tw`text-lg` }),
|
|
54963
|
+
"Ligar"
|
|
54964
|
+
]
|
|
54965
|
+
}
|
|
54966
|
+
) : isIncoming ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
54967
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54968
|
+
"button",
|
|
54969
|
+
{
|
|
54970
|
+
type: "button",
|
|
54971
|
+
onClick: handleReject,
|
|
54972
|
+
className: tw`flex flex-1 min-w-[7rem] items-center justify-center gap-2 rounded-xl bg-rose-500 px-4 py-3 text-sm font-bold text-white shadow-lg transition hover:bg-rose-600`,
|
|
54973
|
+
children: [
|
|
54974
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiPhoneOff, { className: tw`text-base` }),
|
|
54975
|
+
"Recusar"
|
|
54976
|
+
]
|
|
54977
|
+
}
|
|
54978
|
+
),
|
|
54979
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54980
|
+
"button",
|
|
54981
|
+
{
|
|
54982
|
+
type: "button",
|
|
54983
|
+
onClick: handleAnswer,
|
|
54984
|
+
className: tw`flex flex-1 min-w-[7rem] items-center justify-center gap-2 rounded-xl bg-green-500 px-4 py-3 text-sm font-bold text-white shadow-lg transition hover:bg-green-600`,
|
|
54985
|
+
children: [
|
|
54986
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiPhoneIncoming, { className: tw`text-base` }),
|
|
54987
|
+
"Atender"
|
|
54988
|
+
]
|
|
54989
|
+
}
|
|
54990
|
+
)
|
|
54991
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54992
|
+
"button",
|
|
54993
|
+
{
|
|
54994
|
+
type: "button",
|
|
54995
|
+
onClick: handleHangup,
|
|
54996
|
+
className: tw`flex flex-1 min-w-[8rem] items-center justify-center gap-2 rounded-xl bg-rose-500 px-4 py-3 text-base font-bold text-white shadow-lg transition hover:bg-rose-600 hover:shadow-xl`,
|
|
54997
|
+
children: [
|
|
54998
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiPhoneOff, { className: tw`text-lg` }),
|
|
54999
|
+
"Encerrar"
|
|
55000
|
+
]
|
|
55001
|
+
}
|
|
55002
|
+
),
|
|
55003
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
55004
|
+
"button",
|
|
55005
|
+
{
|
|
55006
|
+
type: "button",
|
|
55007
|
+
onClick: onLogout,
|
|
55008
|
+
className: tw`inline-flex items-center justify-center gap-2 rounded-xl border border-slate-200 bg-white px-4 py-3 text-sm font-semibold text-slate-700 shadow-sm transition hover:border-red-400 hover:text-red-500`,
|
|
55009
|
+
children: [
|
|
55010
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiLogOut, { className: tw`text-base` }),
|
|
55011
|
+
"Sair"
|
|
55012
|
+
]
|
|
55013
|
+
}
|
|
55014
|
+
)
|
|
55015
|
+
] }),
|
|
55016
|
+
(callError || availabilityError || audioDeviceError) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`space-y-1.5`, children: [
|
|
55017
|
+
callError && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-start gap-2 rounded-xl border border-rose-200 bg-rose-50 px-2.5 py-2 text-[11px] text-rose-700`, children: [
|
|
55018
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiAlertTriangle, { className: tw`mt-0.5 text-xs` }),
|
|
55019
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: callError })
|
|
55020
|
+
] }),
|
|
55021
|
+
availabilityError && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-start gap-2 rounded-xl border border-amber-200 bg-amber-50 px-2.5 py-2 text-[11px] text-amber-700`, children: [
|
|
55022
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiAlertTriangle, { className: tw`mt-0.5 text-xs` }),
|
|
55023
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: availabilityError })
|
|
55024
|
+
] }),
|
|
55025
|
+
audioDeviceError && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-start gap-2 rounded-xl border border-sky-200 bg-sky-50 px-2.5 py-2 text-[11px] text-sky-700`, children: [
|
|
55026
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiAlertTriangle, { className: tw`mt-0.5 text-xs` }),
|
|
55027
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: audioDeviceError })
|
|
55028
|
+
] })
|
|
55029
|
+
] }),
|
|
55030
|
+
breakModal
|
|
55031
|
+
]
|
|
55032
|
+
}
|
|
55033
|
+
);
|
|
55034
|
+
}
|
|
54643
55035
|
if (isMiniMode) {
|
|
54644
55036
|
const isCallActive = isInCall || isConnecting;
|
|
54645
55037
|
const hasNumber = sanitizedDialValue.length > 0;
|
|
@@ -54949,7 +55341,6 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, vari
|
|
|
54949
55341
|
}
|
|
54950
55342
|
);
|
|
54951
55343
|
}
|
|
54952
|
-
const showActiveSummary = isInCall || isConnecting;
|
|
54953
55344
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54954
55345
|
"div",
|
|
54955
55346
|
{
|
|
@@ -55549,84 +55940,110 @@ function AfterCallPanel({
|
|
|
55549
55940
|
onSubmit,
|
|
55550
55941
|
isSubmitting,
|
|
55551
55942
|
errorMessage,
|
|
55552
|
-
onLogout
|
|
55943
|
+
onLogout,
|
|
55944
|
+
isMobile = false,
|
|
55945
|
+
onClose
|
|
55553
55946
|
}) {
|
|
55554
55947
|
const options = result2 === "success" ? successQualifications : discardQualifications;
|
|
55555
55948
|
const hasOptions = options.length > 0;
|
|
55556
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
55557
|
-
|
|
55558
|
-
|
|
55559
|
-
|
|
55560
|
-
|
|
55561
|
-
|
|
55562
|
-
|
|
55563
|
-
|
|
55564
|
-
|
|
55565
|
-
|
|
55566
|
-
|
|
55567
|
-
|
|
55568
|
-
|
|
55949
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
55950
|
+
"div",
|
|
55951
|
+
{
|
|
55952
|
+
className: tw`${isMobile ? "min-h-[70vh] rounded-3xl border border-slate-200 bg-white p-4 shadow-xl" : "space-y-5"}`,
|
|
55953
|
+
children: [
|
|
55954
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`mb-3 flex items-center justify-between`, children: [
|
|
55955
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-xs uppercase tracking-wide text-slate-500`, children: "Logado como" }),
|
|
55956
|
+
onClose && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
55957
|
+
"button",
|
|
55958
|
+
{
|
|
55959
|
+
type: "button",
|
|
55960
|
+
onClick: onClose,
|
|
55961
|
+
className: tw`inline-flex items-center gap-1 rounded-full border border-slate-200 bg-slate-50 px-3 py-1 text-xs font-semibold text-slate-600 transition hover:border-slate-300`,
|
|
55962
|
+
children: [
|
|
55963
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiArrowLeft, { className: tw`text-xs` }),
|
|
55964
|
+
"Voltar"
|
|
55965
|
+
]
|
|
55966
|
+
}
|
|
55967
|
+
)
|
|
55968
|
+
] }),
|
|
55969
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`${isMobile ? "space-y-3" : "space-y-1"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-sm font-semibold text-slate-800`, children: username }) }),
|
|
55970
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
55971
|
+
"div",
|
|
55569
55972
|
{
|
|
55570
|
-
|
|
55571
|
-
|
|
55572
|
-
|
|
55573
|
-
|
|
55973
|
+
className: tw`space-y-4 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-5 ${isMobile ? "shadow-inner" : ""}`,
|
|
55974
|
+
children: [
|
|
55975
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
55976
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-sm font-semibold text-slate-700`, children: "Qualifique a chamada" }),
|
|
55977
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-xs text-slate-500`, children: "Esta etapa e obrigatoria para registrar o desfecho do atendimento." })
|
|
55978
|
+
] }),
|
|
55979
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`${isMobile ? "grid grid-cols-1 gap-2" : "grid grid-cols-2 gap-2"}`, children: [
|
|
55980
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
55981
|
+
"button",
|
|
55982
|
+
{
|
|
55983
|
+
type: "button",
|
|
55984
|
+
onClick: () => onChangeResult("success"),
|
|
55985
|
+
className: tw`${result2 === "success" ? "bg-green-500 text-white shadow-lg" : "bg-white text-slate-600"} rounded-xl border border-slate-200 px-3 py-3 text-sm font-semibold transition hover:border-green-400`,
|
|
55986
|
+
children: "Atendimento concluido"
|
|
55987
|
+
}
|
|
55988
|
+
),
|
|
55989
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
55990
|
+
"button",
|
|
55991
|
+
{
|
|
55992
|
+
type: "button",
|
|
55993
|
+
onClick: () => onChangeResult("failure"),
|
|
55994
|
+
className: tw`${result2 === "failure" ? "bg-rose-500 text-white shadow-lg" : "bg-white text-slate-600"} rounded-xl border border-slate-200 px-3 py-3 text-sm font-semibold transition hover:border-rose-400`,
|
|
55995
|
+
children: "Atendimento descartado"
|
|
55996
|
+
}
|
|
55997
|
+
)
|
|
55998
|
+
] }),
|
|
55999
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`space-y-2`, children: [
|
|
56000
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-sm font-medium text-slate-700`, children: "Selecione uma qualificacao" }),
|
|
56001
|
+
hasOptions ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`${isMobile ? "max-h-64" : "max-h-52"} space-y-2 overflow-y-auto pr-1`, children: options.map((qualification) => {
|
|
56002
|
+
const isSelected = selectedQualificationId === qualification.id;
|
|
56003
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
56004
|
+
"button",
|
|
56005
|
+
{
|
|
56006
|
+
type: "button",
|
|
56007
|
+
onClick: () => onSelectQualification(qualification.id),
|
|
56008
|
+
className: tw`${isSelected ? "ring-2 ring-primary bg-primary/5 border-primary" : "border-slate-200 bg-white"} w-full rounded-xl border px-3 py-3 text-left text-sm font-semibold transition hover:border-primary`,
|
|
56009
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-sm font-semibold text-slate-800`, children: qualification.name })
|
|
56010
|
+
},
|
|
56011
|
+
qualification.id
|
|
56012
|
+
);
|
|
56013
|
+
}) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-700`, children: "Nenhuma qualificacao disponivel para este tipo de resultado." })
|
|
56014
|
+
] }),
|
|
56015
|
+
errorMessage && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-xs text-red-500`, children: errorMessage }),
|
|
56016
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
56017
|
+
"button",
|
|
56018
|
+
{
|
|
56019
|
+
type: "button",
|
|
56020
|
+
onClick: onSubmit,
|
|
56021
|
+
disabled: !hasOptions || !selectedQualificationId || isSubmitting,
|
|
56022
|
+
className: tw`flex w-full items-center justify-center gap-2 rounded-xl bg-primary px-4 py-2 text-sm font-semibold text-white shadow-lg transition hover:bg-primaryDark disabled:cursor-not-allowed disabled:opacity-60`,
|
|
56023
|
+
children: [
|
|
56024
|
+
isSubmitting && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`inline-flex h-4 w-4 animate-spin rounded-full border-2 border-white/40 border-t-white` }),
|
|
56025
|
+
"Finalizar atendimento"
|
|
56026
|
+
]
|
|
56027
|
+
}
|
|
56028
|
+
)
|
|
56029
|
+
]
|
|
55574
56030
|
}
|
|
55575
56031
|
),
|
|
55576
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
56032
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
55577
56033
|
"button",
|
|
55578
56034
|
{
|
|
55579
56035
|
type: "button",
|
|
55580
|
-
onClick:
|
|
55581
|
-
className: tw
|
|
55582
|
-
children:
|
|
56036
|
+
onClick: onLogout,
|
|
56037
|
+
className: tw`flex w-full items-center justify-center gap-2 rounded-xl border border-slate-200 bg-white px-4 py-2 text-sm font-semibold text-slate-600 transition hover:border-red-400 hover:text-red-500`,
|
|
56038
|
+
children: [
|
|
56039
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiLogOut, { className: tw`text-base` }),
|
|
56040
|
+
"Sair"
|
|
56041
|
+
]
|
|
55583
56042
|
}
|
|
55584
56043
|
)
|
|
55585
|
-
]
|
|
55586
|
-
|
|
55587
|
-
|
|
55588
|
-
hasOptions ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`max-h-52 space-y-2 overflow-y-auto pr-1`, children: options.map((qualification) => {
|
|
55589
|
-
const isSelected = selectedQualificationId === qualification.id;
|
|
55590
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
55591
|
-
"button",
|
|
55592
|
-
{
|
|
55593
|
-
type: "button",
|
|
55594
|
-
onClick: () => onSelectQualification(qualification.id),
|
|
55595
|
-
className: tw`${isSelected ? "ring-2 ring-primary bg-primary/5 border-primary" : "border-slate-200 bg-white"} w-full rounded-xl border px-3 py-2 text-left transition hover:border-primary`,
|
|
55596
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-sm font-semibold text-slate-800`, children: qualification.name })
|
|
55597
|
-
},
|
|
55598
|
-
qualification.id
|
|
55599
|
-
);
|
|
55600
|
-
}) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-700`, children: "Nenhuma qualificacao disponivel para este tipo de resultado." })
|
|
55601
|
-
] }),
|
|
55602
|
-
errorMessage && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-xs text-red-500`, children: errorMessage }),
|
|
55603
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
55604
|
-
"button",
|
|
55605
|
-
{
|
|
55606
|
-
type: "button",
|
|
55607
|
-
onClick: onSubmit,
|
|
55608
|
-
disabled: !hasOptions || !selectedQualificationId || isSubmitting,
|
|
55609
|
-
className: tw`flex w-full items-center justify-center gap-2 rounded-xl bg-primary px-4 py-2 text-sm font-semibold text-white shadow-lg transition hover:bg-primaryDark disabled:cursor-not-allowed disabled:opacity-60`,
|
|
55610
|
-
children: [
|
|
55611
|
-
isSubmitting && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`inline-flex h-4 w-4 animate-spin rounded-full border-2 border-white/40 border-t-white` }),
|
|
55612
|
-
"Finalizar atendimento"
|
|
55613
|
-
]
|
|
55614
|
-
}
|
|
55615
|
-
)
|
|
55616
|
-
] }),
|
|
55617
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
55618
|
-
"button",
|
|
55619
|
-
{
|
|
55620
|
-
type: "button",
|
|
55621
|
-
onClick: onLogout,
|
|
55622
|
-
className: tw`flex w-full items-center justify-center gap-2 rounded-xl border border-slate-200 bg-white px-4 py-2 text-sm font-semibold text-slate-600 transition hover:border-red-400 hover:text-red-500`,
|
|
55623
|
-
children: [
|
|
55624
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(FiLogOut, { className: tw`text-base` }),
|
|
55625
|
-
"Sair"
|
|
55626
|
-
]
|
|
55627
|
-
}
|
|
55628
|
-
)
|
|
55629
|
-
] });
|
|
56044
|
+
]
|
|
56045
|
+
}
|
|
56046
|
+
);
|
|
55630
56047
|
}
|
|
55631
56048
|
function ActiveCallSummary({
|
|
55632
56049
|
statusLabel,
|
|
@@ -55649,6 +56066,770 @@ function ActiveCallSummary({
|
|
|
55649
56066
|
] })
|
|
55650
56067
|
] }) });
|
|
55651
56068
|
}
|
|
56069
|
+
const API_BASE_URL$1 = typeof window !== "undefined" ? window.__CALLIX_API_BASE_URL__ || (window.location.origin.includes("localhost") ? window.location.origin : "https://callix-zeta.vercel.app") : "";
|
|
56070
|
+
function getSessionToken$1() {
|
|
56071
|
+
if (typeof window === "undefined") return null;
|
|
56072
|
+
const lastUsername = localStorage.getItem("callix_dialer_last_username");
|
|
56073
|
+
if (lastUsername) {
|
|
56074
|
+
const sessionKey = `callix_dialer_${lastUsername}_session_token`;
|
|
56075
|
+
const token = localStorage.getItem(sessionKey);
|
|
56076
|
+
if (token) return token;
|
|
56077
|
+
}
|
|
56078
|
+
for (let i2 = 0; i2 < localStorage.length; i2++) {
|
|
56079
|
+
const key = localStorage.key(i2);
|
|
56080
|
+
if (key && key.match(/^callix_dialer_.*_session_token$/)) {
|
|
56081
|
+
const token = localStorage.getItem(key);
|
|
56082
|
+
if (token) return token;
|
|
56083
|
+
}
|
|
56084
|
+
}
|
|
56085
|
+
return null;
|
|
56086
|
+
}
|
|
56087
|
+
function getAuthHeaders$1() {
|
|
56088
|
+
const token = getSessionToken$1();
|
|
56089
|
+
const headers = { "Content-Type": "application/json" };
|
|
56090
|
+
if (token) {
|
|
56091
|
+
headers["x-session-token"] = token;
|
|
56092
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
56093
|
+
}
|
|
56094
|
+
return headers;
|
|
56095
|
+
}
|
|
56096
|
+
async function getCampaignConfig$1(contactId) {
|
|
56097
|
+
const url = `${API_BASE_URL$1}/api/campaign-config/${contactId}`;
|
|
56098
|
+
const response = await fetch(url, { method: "GET", headers: getAuthHeaders$1(), credentials: "omit" });
|
|
56099
|
+
if (!response.ok) {
|
|
56100
|
+
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
56101
|
+
throw new Error(error2.error || `Falha ao buscar config: ${response.status}`);
|
|
56102
|
+
}
|
|
56103
|
+
return response.json();
|
|
56104
|
+
}
|
|
56105
|
+
async function getCodeToNameMapping(campaignModelId) {
|
|
56106
|
+
const url = `${API_BASE_URL$1}/api/campaign-fields/${campaignModelId}`;
|
|
56107
|
+
const response = await fetch(url, { method: "GET", headers: getAuthHeaders$1(), credentials: "omit" });
|
|
56108
|
+
if (!response.ok) {
|
|
56109
|
+
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
56110
|
+
throw new Error(error2.error || `Falha ao buscar mapeamento: ${response.status}`);
|
|
56111
|
+
}
|
|
56112
|
+
return response.json();
|
|
56113
|
+
}
|
|
56114
|
+
async function getCustomerCodeToNameMapping(formId) {
|
|
56115
|
+
const url = `${API_BASE_URL$1}/api/campaign-contact/0?source=customer&formId=${encodeURIComponent(String(formId))}`;
|
|
56116
|
+
const response = await fetch(url, { method: "GET", headers: getAuthHeaders$1(), credentials: "omit" });
|
|
56117
|
+
if (!response.ok) {
|
|
56118
|
+
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
56119
|
+
throw new Error(error2.error || `Falha ao buscar campos (cliente): ${response.status}`);
|
|
56120
|
+
}
|
|
56121
|
+
const json = await response.json();
|
|
56122
|
+
const mapping = {};
|
|
56123
|
+
if (json && Array.isArray(json.rows)) {
|
|
56124
|
+
for (const row of json.rows) {
|
|
56125
|
+
for (const field of row) {
|
|
56126
|
+
if (field && field.code && field.name) {
|
|
56127
|
+
mapping[field.code] = field.name;
|
|
56128
|
+
}
|
|
56129
|
+
}
|
|
56130
|
+
}
|
|
56131
|
+
}
|
|
56132
|
+
return mapping;
|
|
56133
|
+
}
|
|
56134
|
+
async function getContactValues$1(contactId) {
|
|
56135
|
+
const url = `${API_BASE_URL$1}/api/campaign-contact/${contactId}`;
|
|
56136
|
+
const response = await fetch(url, { method: "GET", headers: getAuthHeaders$1(), credentials: "omit" });
|
|
56137
|
+
if (!response.ok) {
|
|
56138
|
+
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
56139
|
+
throw new Error(error2.error || `Falha ao buscar valores: ${response.status}`);
|
|
56140
|
+
}
|
|
56141
|
+
return response.json();
|
|
56142
|
+
}
|
|
56143
|
+
async function getCustomerContactValues$1(customerId) {
|
|
56144
|
+
const url = `${API_BASE_URL$1}/api/campaign-fields/0?source=customer&customerId=${encodeURIComponent(String(customerId))}`;
|
|
56145
|
+
const response = await fetch(url, { method: "GET", headers: getAuthHeaders$1(), credentials: "omit" });
|
|
56146
|
+
if (!response.ok) {
|
|
56147
|
+
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
56148
|
+
throw new Error(error2.error || `Falha ao buscar valores (cliente): ${response.status}`);
|
|
56149
|
+
}
|
|
56150
|
+
return response.json();
|
|
56151
|
+
}
|
|
56152
|
+
function findValue(finalData, candidates) {
|
|
56153
|
+
const entries = Object.entries(finalData);
|
|
56154
|
+
const lowerCandidates = candidates.map((item) => item.toLowerCase());
|
|
56155
|
+
for (const [key, value] of entries) {
|
|
56156
|
+
if (lowerCandidates.includes(key.toLowerCase())) {
|
|
56157
|
+
return value;
|
|
56158
|
+
}
|
|
56159
|
+
}
|
|
56160
|
+
return void 0;
|
|
56161
|
+
}
|
|
56162
|
+
function MobileDialer(props) {
|
|
56163
|
+
useEffect(() => {
|
|
56164
|
+
const existing = document.querySelector('link[data-mobile-dialer-fa="true"]');
|
|
56165
|
+
if (!existing) {
|
|
56166
|
+
const link = document.createElement("link");
|
|
56167
|
+
link.rel = "stylesheet";
|
|
56168
|
+
link.href = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css";
|
|
56169
|
+
link.dataset.mobileDialerFa = "true";
|
|
56170
|
+
document.head.appendChild(link);
|
|
56171
|
+
}
|
|
56172
|
+
}, []);
|
|
56173
|
+
if (!props.isAuthenticated) {
|
|
56174
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(MobileDialerLogin, { ...props });
|
|
56175
|
+
}
|
|
56176
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(AuthenticatedMobileDialer, { ...props });
|
|
56177
|
+
}
|
|
56178
|
+
function MobileDialerLogin({
|
|
56179
|
+
username,
|
|
56180
|
+
onLogin,
|
|
56181
|
+
isLoadingSession,
|
|
56182
|
+
sessionError
|
|
56183
|
+
}) {
|
|
56184
|
+
const [loginInput, setLoginInput] = useState(username ?? "");
|
|
56185
|
+
const [loginError, setLoginError] = useState(null);
|
|
56186
|
+
const handleLogin = useCallback(async () => {
|
|
56187
|
+
if (!loginInput.trim()) {
|
|
56188
|
+
setLoginError("Informe o usuário Callix.");
|
|
56189
|
+
return;
|
|
56190
|
+
}
|
|
56191
|
+
setLoginError(null);
|
|
56192
|
+
try {
|
|
56193
|
+
await Promise.resolve(onLogin(loginInput.trim()));
|
|
56194
|
+
} catch (error2) {
|
|
56195
|
+
setLoginError("Falha ao autenticar.");
|
|
56196
|
+
console.error("Erro login", error2);
|
|
56197
|
+
}
|
|
56198
|
+
}, [loginInput, onLogin]);
|
|
56199
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "phone-container", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "screen dialer-screen active", id: "dialerScreen", children: [
|
|
56200
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "dialer-header", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "status-container", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { className: "status-badge available", children: [
|
|
56201
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "status-dot" }),
|
|
56202
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "status-text", children: "Login" })
|
|
56203
|
+
] }) }) }),
|
|
56204
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "phone-number-display", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
56205
|
+
"input",
|
|
56206
|
+
{
|
|
56207
|
+
type: "text",
|
|
56208
|
+
className: "phone-input",
|
|
56209
|
+
placeholder: "Digite seu usuário Callix",
|
|
56210
|
+
value: loginInput,
|
|
56211
|
+
onChange: (e) => setLoginInput(e.target.value),
|
|
56212
|
+
onKeyDown: (e) => e.key === "Enter" && handleLogin(),
|
|
56213
|
+
disabled: isLoadingSession
|
|
56214
|
+
}
|
|
56215
|
+
) }),
|
|
56216
|
+
loginError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "input-error", children: loginError }),
|
|
56217
|
+
sessionError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "input-error", children: sessionError }),
|
|
56218
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "call-actions", children: [
|
|
56219
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "empty-space" }),
|
|
56220
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "call-button", onClick: handleLogin, disabled: isLoadingSession, children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-sign-in-alt" }) }),
|
|
56221
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "empty-space" })
|
|
56222
|
+
] })
|
|
56223
|
+
] }) });
|
|
56224
|
+
}
|
|
56225
|
+
function AuthenticatedMobileDialer({
|
|
56226
|
+
username
|
|
56227
|
+
}) {
|
|
56228
|
+
var _a2, _b;
|
|
56229
|
+
const [dialValue, setDialValue] = useState("");
|
|
56230
|
+
const [activeScreen, setActiveScreen] = useState("dialer");
|
|
56231
|
+
const [isPauseModalOpen, setIsPauseModalOpen] = useState(false);
|
|
56232
|
+
const [isQualificationOpen, setIsQualificationOpen] = useState(false);
|
|
56233
|
+
const [qualificationResult, setQualificationResult] = useState("success");
|
|
56234
|
+
const [selectedQualificationId, setSelectedQualificationId] = useState(null);
|
|
56235
|
+
const [qualificationError, setQualificationError] = useState(null);
|
|
56236
|
+
const [callDurationSeconds, setCallDurationSeconds] = useState(0);
|
|
56237
|
+
const [callError, setCallError] = useState(null);
|
|
56238
|
+
const [currentBreakName, setCurrentBreakName] = useState(null);
|
|
56239
|
+
const [pauseStartTime, setPauseStartTime] = useState(null);
|
|
56240
|
+
const [pauseDurationSeconds, setPauseDurationSeconds] = useState(0);
|
|
56241
|
+
const [contactData, setContactData] = useState({
|
|
56242
|
+
finalData: {},
|
|
56243
|
+
isLoading: false,
|
|
56244
|
+
error: null
|
|
56245
|
+
});
|
|
56246
|
+
const [fetchedContactId, setFetchedContactId] = useState(null);
|
|
56247
|
+
const operator = clientSdkReactExports.useCallOperator();
|
|
56248
|
+
const operatorState = clientSdkReactExports.useCallOperatorState();
|
|
56249
|
+
const currentCall = clientSdkReactExports.useCallOperatorCurrentCall();
|
|
56250
|
+
const currentCallControls = clientSdkReactExports.useCallOperatorCurrentCallControls();
|
|
56251
|
+
const callInfo = clientSdkReactExports.useCallOperatorCurrentCallInfo();
|
|
56252
|
+
const rawSuccessQualifications = clientSdkReactExports.useCallOperatorSuccessQualifications();
|
|
56253
|
+
const rawDiscardQualifications = clientSdkReactExports.useCallOperatorDiscardQualifications();
|
|
56254
|
+
const successQualifications = useMemo(() => rawSuccessQualifications ?? [], [rawSuccessQualifications]);
|
|
56255
|
+
const discardQualifications = useMemo(() => rawDiscardQualifications ?? [], [rawDiscardQualifications]);
|
|
56256
|
+
const { makeManualCall, finishAfterCall, becomeAvailable } = clientSdkReactExports.useCallOperatorControls();
|
|
56257
|
+
const { goOnBreak, goOffBreak } = useOperatorBreak();
|
|
56258
|
+
const breaks = useSignal(operator == null ? void 0 : operator.breaks) || [];
|
|
56259
|
+
const isOnBreak = (operatorState == null ? void 0 : operatorState.state) === "onBreak";
|
|
56260
|
+
const [inputMuted, setInputMuted] = clientSdkReactExports.useCallOperatorAudioInputMuted();
|
|
56261
|
+
const INITIAL_BREAK_ID = 5;
|
|
56262
|
+
const INITIAL_BREAK_NAME = "Reunião";
|
|
56263
|
+
const callState = operatorState == null ? void 0 : operatorState.state;
|
|
56264
|
+
const hasEnteredInitialBreakRef = useRef(false);
|
|
56265
|
+
useEffect(() => {
|
|
56266
|
+
if (breaks.length === 0 || callState !== "idle" || hasEnteredInitialBreakRef.current || isOnBreak) {
|
|
56267
|
+
return;
|
|
56268
|
+
}
|
|
56269
|
+
if (!goOnBreak) {
|
|
56270
|
+
return;
|
|
56271
|
+
}
|
|
56272
|
+
hasEnteredInitialBreakRef.current = true;
|
|
56273
|
+
const reuniaoBreak = breaks.find(
|
|
56274
|
+
(b) => b.id === INITIAL_BREAK_ID || b.name.toLowerCase() === INITIAL_BREAK_NAME.toLowerCase()
|
|
56275
|
+
);
|
|
56276
|
+
if (reuniaoBreak) {
|
|
56277
|
+
console.log("[MobileDialer] Operador conectado (idle), entrando em pausa inicial:", reuniaoBreak.name);
|
|
56278
|
+
Promise.resolve(goOnBreak(reuniaoBreak.id)).then(() => {
|
|
56279
|
+
console.log("[MobileDialer] Pausa inicial aplicada com sucesso:", reuniaoBreak.name);
|
|
56280
|
+
setCurrentBreakName(reuniaoBreak.name);
|
|
56281
|
+
setPauseStartTime(Date.now());
|
|
56282
|
+
}).catch((err) => {
|
|
56283
|
+
console.error("[MobileDialer] Falha ao entrar em pausa:", err);
|
|
56284
|
+
hasEnteredInitialBreakRef.current = false;
|
|
56285
|
+
});
|
|
56286
|
+
} else {
|
|
56287
|
+
const firstBreak = breaks[0];
|
|
56288
|
+
console.log('[MobileDialer] Pausa "Reunião" não encontrada, usando:', firstBreak.name);
|
|
56289
|
+
Promise.resolve(goOnBreak(firstBreak.id)).then(() => {
|
|
56290
|
+
console.log("[MobileDialer] Pausa inicial aplicada com sucesso:", firstBreak.name);
|
|
56291
|
+
setCurrentBreakName(firstBreak.name);
|
|
56292
|
+
setPauseStartTime(Date.now());
|
|
56293
|
+
}).catch((err) => {
|
|
56294
|
+
console.error("[MobileDialer] Falha ao entrar em pausa:", err);
|
|
56295
|
+
hasEnteredInitialBreakRef.current = false;
|
|
56296
|
+
});
|
|
56297
|
+
}
|
|
56298
|
+
}, [breaks, callState, isOnBreak, goOnBreak]);
|
|
56299
|
+
useEffect(() => {
|
|
56300
|
+
console.log("[MobileDialer] Breaks loaded:", breaks);
|
|
56301
|
+
}, [breaks]);
|
|
56302
|
+
useEffect(() => {
|
|
56303
|
+
console.log("[MobileDialer] Call state changed:", callState);
|
|
56304
|
+
}, [callState]);
|
|
56305
|
+
useEffect(() => {
|
|
56306
|
+
if (callInfo) {
|
|
56307
|
+
console.log("[MobileDialer] Call info atualizado:", {
|
|
56308
|
+
type: callInfo == null ? void 0 : callInfo.type,
|
|
56309
|
+
info: (callInfo == null ? void 0 : callInfo.type) === "campaign" ? {
|
|
56310
|
+
campaign: callInfo.info.campaign,
|
|
56311
|
+
campaignContact: callInfo.info.campaignContact
|
|
56312
|
+
} : callInfo
|
|
56313
|
+
});
|
|
56314
|
+
}
|
|
56315
|
+
}, [callInfo]);
|
|
56316
|
+
const campaignContact = (callInfo == null ? void 0 : callInfo.type) === "campaign" ? callInfo.info.campaignContact : null;
|
|
56317
|
+
const campaignContactId = campaignContact == null ? void 0 : campaignContact.id;
|
|
56318
|
+
useEffect(() => {
|
|
56319
|
+
if (!campaignContactId) {
|
|
56320
|
+
setContactData({ finalData: {}, isLoading: false, error: null });
|
|
56321
|
+
setFetchedContactId(null);
|
|
56322
|
+
return;
|
|
56323
|
+
}
|
|
56324
|
+
if (fetchedContactId === campaignContactId) {
|
|
56325
|
+
return;
|
|
56326
|
+
}
|
|
56327
|
+
let cancelled = false;
|
|
56328
|
+
const fetchContactData = async () => {
|
|
56329
|
+
console.log("[MobileDialer] Buscando dados do contato:", campaignContactId);
|
|
56330
|
+
setContactData({ finalData: {}, isLoading: true, error: null });
|
|
56331
|
+
try {
|
|
56332
|
+
const customer = campaignContact == null ? void 0 : campaignContact.customer;
|
|
56333
|
+
let codeToNameMap = {};
|
|
56334
|
+
let contactValues = {};
|
|
56335
|
+
if ((customer == null ? void 0 : customer.id) && (customer == null ? void 0 : customer.formId)) {
|
|
56336
|
+
console.log("[MobileDialer] Usando modo cliente:", customer);
|
|
56337
|
+
[codeToNameMap, contactValues] = await Promise.all([
|
|
56338
|
+
getCustomerCodeToNameMapping(customer.formId),
|
|
56339
|
+
getCustomerContactValues$1(customer.id)
|
|
56340
|
+
]);
|
|
56341
|
+
} else {
|
|
56342
|
+
const config = await getCampaignConfig$1(campaignContactId);
|
|
56343
|
+
console.log("[MobileDialer] Config recebida:", config);
|
|
56344
|
+
if (!config.campaignModelId) {
|
|
56345
|
+
throw new Error("campaignModelId não encontrado");
|
|
56346
|
+
}
|
|
56347
|
+
[codeToNameMap, contactValues] = await Promise.all([
|
|
56348
|
+
getCodeToNameMapping(config.campaignModelId),
|
|
56349
|
+
getContactValues$1(campaignContactId)
|
|
56350
|
+
]);
|
|
56351
|
+
}
|
|
56352
|
+
console.log("[MobileDialer] Mapeamento:", codeToNameMap);
|
|
56353
|
+
console.log("[MobileDialer] Valores:", contactValues);
|
|
56354
|
+
const finalData = {};
|
|
56355
|
+
Object.entries(contactValues).forEach(([code, value]) => {
|
|
56356
|
+
if (code in codeToNameMap) {
|
|
56357
|
+
finalData[codeToNameMap[code]] = value;
|
|
56358
|
+
}
|
|
56359
|
+
});
|
|
56360
|
+
console.log("[MobileDialer] Final data:", finalData);
|
|
56361
|
+
if (!cancelled) {
|
|
56362
|
+
setContactData({ finalData, isLoading: false, error: null });
|
|
56363
|
+
setFetchedContactId(campaignContactId);
|
|
56364
|
+
}
|
|
56365
|
+
} catch (error2) {
|
|
56366
|
+
if (!cancelled) {
|
|
56367
|
+
console.error("[MobileDialer] Erro ao buscar dados:", error2);
|
|
56368
|
+
const errorMessage = error2 instanceof Error ? error2.message : "Erro ao buscar dados";
|
|
56369
|
+
setContactData({ finalData: {}, isLoading: false, error: errorMessage });
|
|
56370
|
+
setFetchedContactId(campaignContactId);
|
|
56371
|
+
}
|
|
56372
|
+
}
|
|
56373
|
+
};
|
|
56374
|
+
void fetchContactData();
|
|
56375
|
+
return () => {
|
|
56376
|
+
cancelled = true;
|
|
56377
|
+
};
|
|
56378
|
+
}, [campaignContactId, fetchedContactId]);
|
|
56379
|
+
const callStateStr = callState;
|
|
56380
|
+
const isError = callStateStr === "startup.error" || callStateStr === "offline";
|
|
56381
|
+
const isIdle = !callStateStr || callStateStr === "starting" || callStateStr === "idle" || callStateStr === "manualCallSetup" || callStateStr === "onBreak";
|
|
56382
|
+
const isConnecting = callState === "manualCallSetup" || callState === "manualCallRinging" || callState === "callRinging";
|
|
56383
|
+
const isInCall = callState === "callInProgress";
|
|
56384
|
+
const isAfterCall = callState === "afterCall";
|
|
56385
|
+
useEffect(() => {
|
|
56386
|
+
if (!isInCall) {
|
|
56387
|
+
setCallDurationSeconds(0);
|
|
56388
|
+
return;
|
|
56389
|
+
}
|
|
56390
|
+
const interval = setInterval(() => {
|
|
56391
|
+
setCallDurationSeconds((prev) => prev + 1);
|
|
56392
|
+
}, 1e3);
|
|
56393
|
+
return () => clearInterval(interval);
|
|
56394
|
+
}, [isInCall]);
|
|
56395
|
+
useEffect(() => {
|
|
56396
|
+
if (!isOnBreak || !pauseStartTime) {
|
|
56397
|
+
return;
|
|
56398
|
+
}
|
|
56399
|
+
const interval = setInterval(() => {
|
|
56400
|
+
const elapsed = Math.floor((Date.now() - pauseStartTime) / 1e3);
|
|
56401
|
+
setPauseDurationSeconds(elapsed);
|
|
56402
|
+
}, 1e3);
|
|
56403
|
+
return () => clearInterval(interval);
|
|
56404
|
+
}, [isOnBreak, pauseStartTime]);
|
|
56405
|
+
useEffect(() => {
|
|
56406
|
+
if (!isOnBreak && currentBreakName) {
|
|
56407
|
+
setCurrentBreakName(null);
|
|
56408
|
+
setPauseStartTime(null);
|
|
56409
|
+
setPauseDurationSeconds(0);
|
|
56410
|
+
}
|
|
56411
|
+
}, [isOnBreak, currentBreakName]);
|
|
56412
|
+
useEffect(() => {
|
|
56413
|
+
if (isInCall || isConnecting) {
|
|
56414
|
+
setActiveScreen("call");
|
|
56415
|
+
} else if (isAfterCall) {
|
|
56416
|
+
setActiveScreen("dialer");
|
|
56417
|
+
}
|
|
56418
|
+
}, [isInCall, isConnecting, isAfterCall]);
|
|
56419
|
+
useEffect(() => {
|
|
56420
|
+
if (isAfterCall) {
|
|
56421
|
+
const hasSuccess = successQualifications.length > 0;
|
|
56422
|
+
setQualificationResult(hasSuccess ? "success" : "failure");
|
|
56423
|
+
setSelectedQualificationId(null);
|
|
56424
|
+
setQualificationError(null);
|
|
56425
|
+
setIsQualificationOpen(true);
|
|
56426
|
+
} else {
|
|
56427
|
+
setIsQualificationOpen(false);
|
|
56428
|
+
}
|
|
56429
|
+
}, [isAfterCall, successQualifications]);
|
|
56430
|
+
const formattedDial = useMemo(() => formatPhoneForDisplay(dialValue), [dialValue]);
|
|
56431
|
+
const sanitizeInput = useCallback((input) => normalizePhoneNumberPaste(input), []);
|
|
56432
|
+
const handleDigit = useCallback(
|
|
56433
|
+
(digit) => {
|
|
56434
|
+
if (isInCall || isConnecting) {
|
|
56435
|
+
if (currentCall && typeof currentCall.sendDtmf === "function") {
|
|
56436
|
+
try {
|
|
56437
|
+
currentCall.sendDtmf(digit);
|
|
56438
|
+
} catch (error2) {
|
|
56439
|
+
console.error("Falha ao enviar DTMF", error2);
|
|
56440
|
+
}
|
|
56441
|
+
}
|
|
56442
|
+
return;
|
|
56443
|
+
}
|
|
56444
|
+
setDialValue((prev) => (prev + digit).slice(0, 32));
|
|
56445
|
+
},
|
|
56446
|
+
[currentCall, isInCall, isConnecting]
|
|
56447
|
+
);
|
|
56448
|
+
const handleBackspace = useCallback(() => {
|
|
56449
|
+
setDialValue((prev) => prev.slice(0, -1));
|
|
56450
|
+
}, []);
|
|
56451
|
+
const handleCall = useCallback(async () => {
|
|
56452
|
+
console.log("[MobileDialer] handleCall triggered, dialValue:", dialValue);
|
|
56453
|
+
const sanitized = sanitizeInput(dialValue);
|
|
56454
|
+
console.log("[MobileDialer] Sanitized number:", sanitized);
|
|
56455
|
+
if (!sanitized || !isValidPhoneFormat(sanitized)) {
|
|
56456
|
+
console.log("[MobileDialer] Invalid phone format");
|
|
56457
|
+
setCallError("Número inválido.");
|
|
56458
|
+
return;
|
|
56459
|
+
}
|
|
56460
|
+
setCallError(null);
|
|
56461
|
+
if (!makeManualCall) {
|
|
56462
|
+
console.error("[MobileDialer] makeManualCall is not available");
|
|
56463
|
+
setCallError("Função de chamada não disponível.");
|
|
56464
|
+
return;
|
|
56465
|
+
}
|
|
56466
|
+
const e164Number = `+55${sanitized}`;
|
|
56467
|
+
console.log("[MobileDialer] Calling makeManualCall with E.164:", e164Number);
|
|
56468
|
+
try {
|
|
56469
|
+
void makeManualCall(e164Number);
|
|
56470
|
+
console.log("[MobileDialer] makeManualCall called successfully");
|
|
56471
|
+
} catch (error2) {
|
|
56472
|
+
console.error("[MobileDialer] Erro ao iniciar chamada manual:", error2);
|
|
56473
|
+
setCallError("Erro ao iniciar chamada.");
|
|
56474
|
+
}
|
|
56475
|
+
}, [dialValue, makeManualCall, sanitizeInput]);
|
|
56476
|
+
const handleHangup = useCallback(() => {
|
|
56477
|
+
if (!(currentCallControls == null ? void 0 : currentCallControls.hangup)) return;
|
|
56478
|
+
try {
|
|
56479
|
+
currentCallControls.hangup();
|
|
56480
|
+
} catch (error2) {
|
|
56481
|
+
console.error("Erro ao desligar", error2);
|
|
56482
|
+
}
|
|
56483
|
+
}, [currentCallControls]);
|
|
56484
|
+
const toggleMute = useCallback(() => {
|
|
56485
|
+
setInputMuted(!inputMuted);
|
|
56486
|
+
}, [inputMuted, setInputMuted]);
|
|
56487
|
+
const toggleSpeaker = useCallback(() => {
|
|
56488
|
+
console.warn("Alto-falante não suportado no SDK web. Apenas UI.");
|
|
56489
|
+
}, []);
|
|
56490
|
+
const handleGoOnBreak = useCallback(
|
|
56491
|
+
async (breakId) => {
|
|
56492
|
+
if (!goOnBreak) return;
|
|
56493
|
+
try {
|
|
56494
|
+
const selectedBreak = breaks.find((b) => b.id === breakId);
|
|
56495
|
+
await goOnBreak(breakId);
|
|
56496
|
+
setCurrentBreakName((selectedBreak == null ? void 0 : selectedBreak.name) ?? "Em pausa");
|
|
56497
|
+
setPauseStartTime(Date.now());
|
|
56498
|
+
setPauseDurationSeconds(0);
|
|
56499
|
+
setIsPauseModalOpen(false);
|
|
56500
|
+
} catch (error2) {
|
|
56501
|
+
console.error("Erro ao entrar em pausa", error2);
|
|
56502
|
+
}
|
|
56503
|
+
},
|
|
56504
|
+
[goOnBreak, breaks]
|
|
56505
|
+
);
|
|
56506
|
+
const handleGoOffBreak = useCallback(async () => {
|
|
56507
|
+
if (!goOffBreak) return;
|
|
56508
|
+
try {
|
|
56509
|
+
await goOffBreak();
|
|
56510
|
+
setCurrentBreakName(null);
|
|
56511
|
+
setPauseStartTime(null);
|
|
56512
|
+
setPauseDurationSeconds(0);
|
|
56513
|
+
setIsPauseModalOpen(false);
|
|
56514
|
+
} catch (error2) {
|
|
56515
|
+
console.error("Erro ao sair de pausa", error2);
|
|
56516
|
+
}
|
|
56517
|
+
}, [goOffBreak]);
|
|
56518
|
+
const handleQualificationConfirm = useCallback(async () => {
|
|
56519
|
+
if (!finishAfterCall) return;
|
|
56520
|
+
const list = qualificationResult === "success" ? successQualifications : discardQualifications;
|
|
56521
|
+
if (!list.length) {
|
|
56522
|
+
setQualificationError("Nenhuma qualificação disponível.");
|
|
56523
|
+
return;
|
|
56524
|
+
}
|
|
56525
|
+
if (!selectedQualificationId) {
|
|
56526
|
+
setQualificationError("Selecione uma qualificação.");
|
|
56527
|
+
return;
|
|
56528
|
+
}
|
|
56529
|
+
setQualificationError(null);
|
|
56530
|
+
try {
|
|
56531
|
+
await Promise.resolve(
|
|
56532
|
+
finishAfterCall({
|
|
56533
|
+
result: qualificationResult,
|
|
56534
|
+
qualificationId: selectedQualificationId
|
|
56535
|
+
})
|
|
56536
|
+
);
|
|
56537
|
+
setIsQualificationOpen(false);
|
|
56538
|
+
} catch (error2) {
|
|
56539
|
+
setQualificationError("Erro ao enviar qualificação.");
|
|
56540
|
+
console.error("Erro finishAfterCall", error2);
|
|
56541
|
+
}
|
|
56542
|
+
}, [discardQualifications, finishAfterCall, qualificationResult, selectedQualificationId, successQualifications]);
|
|
56543
|
+
const formattedCallNumber = useMemo(() => {
|
|
56544
|
+
var _a3;
|
|
56545
|
+
if ((callInfo == null ? void 0 : callInfo.type) === "campaign" && ((_a3 = callInfo.info.campaignContact) == null ? void 0 : _a3.phoneNumber)) {
|
|
56546
|
+
return formatPhoneForDisplay(callInfo.info.campaignContact.phoneNumber);
|
|
56547
|
+
}
|
|
56548
|
+
return formattedDial || "(--) ----- ----";
|
|
56549
|
+
}, [callInfo, formattedDial]);
|
|
56550
|
+
const callStatusLabel = useMemo(() => {
|
|
56551
|
+
if (isConnecting) return "Ligando...";
|
|
56552
|
+
if (isInCall) return "Em chamada";
|
|
56553
|
+
if (isAfterCall) return "Encerrando...";
|
|
56554
|
+
if (isError) return "Erro de conexão";
|
|
56555
|
+
if (isOnBreak) return "Em pausa";
|
|
56556
|
+
return "Disponível";
|
|
56557
|
+
}, [isAfterCall, isConnecting, isError, isInCall, isOnBreak]);
|
|
56558
|
+
const statusBadgeClass = useMemo(() => {
|
|
56559
|
+
if (isError) return "error";
|
|
56560
|
+
if (isOnBreak) return "paused";
|
|
56561
|
+
return "available";
|
|
56562
|
+
}, [isError, isOnBreak]);
|
|
56563
|
+
const statusBadgeText = useMemo(() => {
|
|
56564
|
+
if (isError) return "Erro";
|
|
56565
|
+
if (isOnBreak) return currentBreakName || "Em pausa";
|
|
56566
|
+
return "Disponível";
|
|
56567
|
+
}, [isError, isOnBreak, currentBreakName]);
|
|
56568
|
+
const pauseDurationLabel = useMemo(() => {
|
|
56569
|
+
const hours = Math.floor(pauseDurationSeconds / 3600);
|
|
56570
|
+
const minutes = Math.floor(pauseDurationSeconds % 3600 / 60).toString().padStart(2, "0");
|
|
56571
|
+
const seconds = (pauseDurationSeconds % 60).toString().padStart(2, "0");
|
|
56572
|
+
if (hours > 0) {
|
|
56573
|
+
return `${hours}:${minutes}:${seconds}`;
|
|
56574
|
+
}
|
|
56575
|
+
return `${minutes}:${seconds}`;
|
|
56576
|
+
}, [pauseDurationSeconds]);
|
|
56577
|
+
const callDurationLabel = useMemo(() => {
|
|
56578
|
+
const m = Math.floor(callDurationSeconds / 60).toString().padStart(2, "0");
|
|
56579
|
+
const s = (callDurationSeconds % 60).toString().padStart(2, "0");
|
|
56580
|
+
return `${m}:${s}`;
|
|
56581
|
+
}, [callDurationSeconds]);
|
|
56582
|
+
const renderKey = (value, letters) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "key", "data-value": value, onClick: () => handleDigit(value), children: [
|
|
56583
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "number", children: value }),
|
|
56584
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "letters", children: letters || " " })
|
|
56585
|
+
] }, value);
|
|
56586
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "phone-container", children: [
|
|
56587
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `screen dialer-screen ${activeScreen === "dialer" ? "active" : ""}`, id: "dialerScreen", children: [
|
|
56588
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "dialer-header", children: [
|
|
56589
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "status-container", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { className: `status-badge ${statusBadgeClass}`, id: "statusBadge", children: [
|
|
56590
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "status-dot" }),
|
|
56591
|
+
isOnBreak ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "status-info", children: [
|
|
56592
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "status-text", children: statusBadgeText }),
|
|
56593
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "pause-timer", children: pauseDurationLabel })
|
|
56594
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "status-text", children: statusBadgeText })
|
|
56595
|
+
] }) }),
|
|
56596
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "status-actions", children: isOnBreak ? /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { className: "resume-btn", id: "resumeBtn", onClick: handleGoOffBreak, children: [
|
|
56597
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-play" }),
|
|
56598
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Voltar" })
|
|
56599
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { className: "pause-btn", id: "pauseBtn", onClick: () => setIsPauseModalOpen(true), children: [
|
|
56600
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-pause" }),
|
|
56601
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Pausa" })
|
|
56602
|
+
] }) })
|
|
56603
|
+
] }),
|
|
56604
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "phone-number-display", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
56605
|
+
"input",
|
|
56606
|
+
{
|
|
56607
|
+
type: "tel",
|
|
56608
|
+
id: "phoneNumber",
|
|
56609
|
+
className: "phone-input",
|
|
56610
|
+
placeholder: "",
|
|
56611
|
+
autoComplete: "off",
|
|
56612
|
+
inputMode: "tel",
|
|
56613
|
+
value: formattedDial,
|
|
56614
|
+
onChange: (e) => setDialValue(sanitizeInput(e.target.value)),
|
|
56615
|
+
onPaste: (e) => {
|
|
56616
|
+
var _a3;
|
|
56617
|
+
e.preventDefault();
|
|
56618
|
+
const text = ((_a3 = e.clipboardData) == null ? void 0 : _a3.getData("text")) || "";
|
|
56619
|
+
setDialValue(sanitizeInput(text));
|
|
56620
|
+
}
|
|
56621
|
+
}
|
|
56622
|
+
) }),
|
|
56623
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "keypad", children: [
|
|
56624
|
+
renderKey("1", ""),
|
|
56625
|
+
renderKey("2", "ABC"),
|
|
56626
|
+
renderKey("3", "DEF"),
|
|
56627
|
+
renderKey("4", "GHI"),
|
|
56628
|
+
renderKey("5", "JKL"),
|
|
56629
|
+
renderKey("6", "MNO"),
|
|
56630
|
+
renderKey("7", "PQRS"),
|
|
56631
|
+
renderKey("8", "TUV"),
|
|
56632
|
+
renderKey("9", "WXYZ"),
|
|
56633
|
+
renderKey("*", ""),
|
|
56634
|
+
renderKey("0", "+"),
|
|
56635
|
+
renderKey("#", "")
|
|
56636
|
+
] }),
|
|
56637
|
+
callError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "input-error", children: callError }),
|
|
56638
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "call-actions", children: [
|
|
56639
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "empty-space" }),
|
|
56640
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "call-button", id: "callButton", onClick: handleCall, disabled: !formattedDial || !isIdle, children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-phone" }) }),
|
|
56641
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
56642
|
+
"button",
|
|
56643
|
+
{
|
|
56644
|
+
className: "delete-button",
|
|
56645
|
+
id: "deleteButton",
|
|
56646
|
+
style: { visibility: dialValue ? "visible" : "hidden" },
|
|
56647
|
+
onClick: handleBackspace,
|
|
56648
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-delete-left" })
|
|
56649
|
+
}
|
|
56650
|
+
)
|
|
56651
|
+
] })
|
|
56652
|
+
] }),
|
|
56653
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `screen call-screen ${activeScreen === "call" ? "active" : ""}`, id: "callScreen", children: [
|
|
56654
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "call-info", children: [
|
|
56655
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "call-status", children: [
|
|
56656
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "operator-badge-small", children: (username == null ? void 0 : username.slice(0, 2).toUpperCase()) || "OP" }),
|
|
56657
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { id: "callStatus", children: [
|
|
56658
|
+
callStatusLabel,
|
|
56659
|
+
" "
|
|
56660
|
+
] }),
|
|
56661
|
+
isInCall && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: callDurationLabel })
|
|
56662
|
+
] }),
|
|
56663
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "call-number", id: "callNumber", children: formattedCallNumber }),
|
|
56664
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "call-location", children: "Brasil" }),
|
|
56665
|
+
(callInfo == null ? void 0 : callInfo.type) === "campaign" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "client-card", id: "clientCard", children: contactData.isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "client-card-loading", children: [
|
|
56666
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-spinner fa-spin" }),
|
|
56667
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Carregando dados..." })
|
|
56668
|
+
] }) : contactData.error ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "client-card-error", children: [
|
|
56669
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-exclamation-circle" }),
|
|
56670
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: contactData.error })
|
|
56671
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
56672
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "client-card-header", children: [
|
|
56673
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-user-circle client-avatar" }),
|
|
56674
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "client-main-info", children: [
|
|
56675
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-name", id: "clientName", children: findValue(contactData.finalData, ["DECISOR", "NOME", "CLIENTE"]) ?? ((_a2 = callInfo.info.campaignContact) == null ? void 0 : _a2.label) ?? "--" }),
|
|
56676
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-company", id: "clientCompany", children: findValue(contactData.finalData, ["EMPRESA", "RAZAO SOCIAL", "RAZÃO SOCIAL"]) ?? ((_b = callInfo.info.campaign) == null ? void 0 : _b.name) ?? "--" })
|
|
56677
|
+
] })
|
|
56678
|
+
] }),
|
|
56679
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "client-card-divider" }),
|
|
56680
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "client-values-grid", children: [
|
|
56681
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "client-value-item", children: [
|
|
56682
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-value-label", children: "Dívida Ativa" }),
|
|
56683
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-value-amount debt", id: "clientDebt", children: findValue(contactData.finalData, ["DIVIDA_ATIVA", "DIVIDA ATIVA", "DÍVIDA ATIVA", "VALOR DIVIDA", "VALOR DÍVIDA"]) ?? "R$ 0,00" })
|
|
56684
|
+
] }),
|
|
56685
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "client-value-item", children: [
|
|
56686
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-value-label", children: "Valor Recuperado" }),
|
|
56687
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "client-value-amount recovered", id: "clientRecovered", children: findValue(contactData.finalData, ["BENEFICIO", "BENEFÍCIO", "VALOR RECUPERADO"]) ?? "R$ 0,00" })
|
|
56688
|
+
] })
|
|
56689
|
+
] })
|
|
56690
|
+
] }) })
|
|
56691
|
+
] }),
|
|
56692
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "call-controls", children: [
|
|
56693
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "control-row", children: [
|
|
56694
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("button", { className: "control-button", id: "speakerBtn", onClick: toggleSpeaker, children: [
|
|
56695
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "control-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-volume-high" }) }),
|
|
56696
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Alto-falante" })
|
|
56697
|
+
] }),
|
|
56698
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("button", { className: `control-button ${inputMuted ? "active" : ""}`, id: "muteBtn", onClick: toggleMute, children: [
|
|
56699
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "control-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: `fas ${inputMuted ? "fa-microphone-slash" : "fa-microphone"}` }) }),
|
|
56700
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: inputMuted ? "Mudo" : "Mudo" })
|
|
56701
|
+
] }),
|
|
56702
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("button", { className: "control-button", id: "keypadBtn", onClick: () => setActiveScreen("incallKeypad"), children: [
|
|
56703
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "control-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-th" }) }),
|
|
56704
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Teclado" })
|
|
56705
|
+
] })
|
|
56706
|
+
] }),
|
|
56707
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "control-row control-row-center", children: [
|
|
56708
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("button", { className: "control-button whatsapp-btn", id: "whatsappBtn", onClick: () => window.open("https://wa.me/", "_blank"), children: [
|
|
56709
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "control-icon whatsapp-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fab fa-whatsapp" }) }),
|
|
56710
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "WhatsApp" })
|
|
56711
|
+
] }),
|
|
56712
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "end-call-wrapper", children: [
|
|
56713
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "end-call-button", id: "endCallButton", onClick: handleHangup, children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-phone-slash" }) }),
|
|
56714
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "end-call-label", children: "Desligar" })
|
|
56715
|
+
] })
|
|
56716
|
+
] })
|
|
56717
|
+
] })
|
|
56718
|
+
] }),
|
|
56719
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `screen incall-keypad-screen ${activeScreen === "incallKeypad" ? "active" : ""}`, id: "incallKeypadScreen", children: [
|
|
56720
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "incall-header", children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "hide-keypad-btn", id: "hideKeypadBtn", onClick: () => setActiveScreen("call"), children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Ocultar" }) }) }),
|
|
56721
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "incall-number-display", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { id: "incallPhoneNumber", children: formattedCallNumber }) }),
|
|
56722
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "keypad incall-keypad", children: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "*", "0", "#"].map((digit) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "key incall-key", "data-value": digit, onClick: () => handleDigit(digit), children: [
|
|
56723
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "number", children: digit }),
|
|
56724
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "letters", children: " " })
|
|
56725
|
+
] }, digit)) }),
|
|
56726
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "incall-actions", children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "end-call-button", id: "endCallButton2", onClick: handleHangup, children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-phone-slash" }) }) })
|
|
56727
|
+
] }),
|
|
56728
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `screen call-history-screen ${activeScreen === "history" ? "active" : ""}`, id: "callHistoryScreen", children: [
|
|
56729
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "history-header", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "header-title", children: "Ligações" }) }),
|
|
56730
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "call-history-list", id: "callHistoryList", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "history-empty", children: "Histórico indisponível nesta versão." }) })
|
|
56731
|
+
] }),
|
|
56732
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("nav", { className: "bottom-nav", id: "bottomNav", children: [
|
|
56733
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
56734
|
+
"div",
|
|
56735
|
+
{
|
|
56736
|
+
className: `nav-item ${activeScreen === "history" ? "active" : ""}`,
|
|
56737
|
+
id: "navCalls",
|
|
56738
|
+
onClick: () => setActiveScreen("history"),
|
|
56739
|
+
children: [
|
|
56740
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "nav-icon", children: [
|
|
56741
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-clock-rotate-left" }),
|
|
56742
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "badge", id: "callsBadge", children: "0" })
|
|
56743
|
+
] }),
|
|
56744
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Ligações" })
|
|
56745
|
+
]
|
|
56746
|
+
}
|
|
56747
|
+
),
|
|
56748
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
56749
|
+
"div",
|
|
56750
|
+
{
|
|
56751
|
+
className: `nav-item ${activeScreen === "dialer" || activeScreen === "call" || activeScreen === "incallKeypad" ? "active" : ""}`,
|
|
56752
|
+
id: "navKeypad",
|
|
56753
|
+
onClick: () => setActiveScreen("dialer"),
|
|
56754
|
+
children: [
|
|
56755
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nav-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-th" }) }),
|
|
56756
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Teclado" })
|
|
56757
|
+
]
|
|
56758
|
+
}
|
|
56759
|
+
)
|
|
56760
|
+
] }),
|
|
56761
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `modal-overlay ${isPauseModalOpen ? "active" : ""}`, id: "pauseModal", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "modal-content", children: [
|
|
56762
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "modal-header", children: [
|
|
56763
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "modal-title", children: "Selecionar Pausa" }),
|
|
56764
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "modal-close", id: "closePauseModal", onClick: () => setIsPauseModalOpen(false), children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-xmark" }) })
|
|
56765
|
+
] }),
|
|
56766
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "pause-options", id: "pauseOptions", children: [
|
|
56767
|
+
breaks.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "pause-option", onClick: () => handleGoOnBreak(item.id), children: [
|
|
56768
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "pause-option-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: `fas ${item.icon || "fa-circle-pause"}` }) }),
|
|
56769
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "pause-option-info", children: [
|
|
56770
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "pause-option-name", children: item.name }),
|
|
56771
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "pause-option-id", children: [
|
|
56772
|
+
"ID: ",
|
|
56773
|
+
item.id
|
|
56774
|
+
] })
|
|
56775
|
+
] })
|
|
56776
|
+
] }, item.id)),
|
|
56777
|
+
!breaks.length && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "history-empty", children: "Nenhuma pausa configurada." })
|
|
56778
|
+
] }),
|
|
56779
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "modal-cancel-btn", id: "cancelPauseBtn", onClick: () => setIsPauseModalOpen(false), children: "Cancelar" })
|
|
56780
|
+
] }) }),
|
|
56781
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `modal-overlay qualification-modal ${isQualificationOpen ? "active" : ""}`, id: "qualificationModal", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "qualification-sheet", children: [
|
|
56782
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sheet-handle" }),
|
|
56783
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sheet-header", children: [
|
|
56784
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sheet-title", children: "Qualificar Chamada" }),
|
|
56785
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sheet-subtitle", children: "Registre o resultado do atendimento" })
|
|
56786
|
+
] }),
|
|
56787
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "result-segmented", children: [
|
|
56788
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
56789
|
+
"button",
|
|
56790
|
+
{
|
|
56791
|
+
className: `segment ${qualificationResult === "success" ? "active" : ""}`,
|
|
56792
|
+
id: "resultSuccess",
|
|
56793
|
+
"data-type": "success",
|
|
56794
|
+
onClick: () => {
|
|
56795
|
+
setQualificationResult("success");
|
|
56796
|
+
setSelectedQualificationId(null);
|
|
56797
|
+
},
|
|
56798
|
+
children: "Sucesso"
|
|
56799
|
+
}
|
|
56800
|
+
),
|
|
56801
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
56802
|
+
"button",
|
|
56803
|
+
{
|
|
56804
|
+
className: `segment ${qualificationResult === "failure" ? "active" : ""}`,
|
|
56805
|
+
id: "resultFailure",
|
|
56806
|
+
"data-type": "failure",
|
|
56807
|
+
onClick: () => {
|
|
56808
|
+
setQualificationResult("failure");
|
|
56809
|
+
setSelectedQualificationId(null);
|
|
56810
|
+
},
|
|
56811
|
+
children: "Falha"
|
|
56812
|
+
}
|
|
56813
|
+
),
|
|
56814
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "segment-indicator" })
|
|
56815
|
+
] }),
|
|
56816
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "qualifications-container", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "qualification-list", id: "qualificationList", children: [
|
|
56817
|
+
(qualificationResult === "success" ? successQualifications : discardQualifications).map((q) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
56818
|
+
"button",
|
|
56819
|
+
{
|
|
56820
|
+
className: `qualification-item ${selectedQualificationId === q.id ? "selected" : ""}`,
|
|
56821
|
+
onClick: () => setSelectedQualificationId(q.id),
|
|
56822
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: q.name })
|
|
56823
|
+
},
|
|
56824
|
+
q.id
|
|
56825
|
+
)),
|
|
56826
|
+
!(qualificationResult === "success" ? successQualifications : discardQualifications).length && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "history-empty", children: "Nenhuma qualificação configurada." })
|
|
56827
|
+
] }) }),
|
|
56828
|
+
qualificationError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "input-error", children: qualificationError }),
|
|
56829
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sheet-footer", children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "confirm-btn", id: "confirmQualificationBtn", onClick: handleQualificationConfirm, disabled: !selectedQualificationId, children: "Confirmar" }) })
|
|
56830
|
+
] }) })
|
|
56831
|
+
] });
|
|
56832
|
+
}
|
|
55652
56833
|
const VIEWPORT_MARGIN$1 = 16;
|
|
55653
56834
|
function clamp$1(value, min2, max2) {
|
|
55654
56835
|
return Math.min(Math.max(value, min2), max2);
|
|
@@ -55916,7 +57097,7 @@ function DraggableClientInfoModal({
|
|
|
55916
57097
|
return () => {
|
|
55917
57098
|
cancelled = true;
|
|
55918
57099
|
};
|
|
55919
|
-
}, [campaignContact == null ? void 0 : campaignContact.id, fetchedContactId]);
|
|
57100
|
+
}, [campaignContact, campaignContact == null ? void 0 : campaignContact.id, fetchedContactId]);
|
|
55920
57101
|
useEffect(() => {
|
|
55921
57102
|
if (!isDragging) {
|
|
55922
57103
|
return;
|
|
@@ -56119,7 +57300,8 @@ function DraggableQualificationModal({
|
|
|
56119
57300
|
onSelectQualification,
|
|
56120
57301
|
onSubmit,
|
|
56121
57302
|
isSubmitting,
|
|
56122
|
-
errorMessage
|
|
57303
|
+
errorMessage,
|
|
57304
|
+
portalTarget = null
|
|
56123
57305
|
}) {
|
|
56124
57306
|
const containerRef = useRef(null);
|
|
56125
57307
|
const pointerRef = useRef({ pointerId: null, offsetX: 0, offsetY: 0 });
|
|
@@ -56352,14 +57534,17 @@ function DraggableQualificationModal({
|
|
|
56352
57534
|
}
|
|
56353
57535
|
);
|
|
56354
57536
|
if (typeof document !== "undefined") {
|
|
56355
|
-
return createPortal(modalContent, document.body);
|
|
57537
|
+
return createPortal(modalContent, portalTarget ?? document.body);
|
|
56356
57538
|
}
|
|
56357
57539
|
return null;
|
|
56358
57540
|
}
|
|
56359
|
-
function InlineDialer({ variant = "default", isAuthenticated, ...props }) {
|
|
57541
|
+
function InlineDialer({ variant = "default", portalTarget, isAuthenticated, ...props }) {
|
|
56360
57542
|
const isMiniMode = variant === "min";
|
|
57543
|
+
if (variant === "mobile") {
|
|
57544
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(MobileDialer, { isAuthenticated, ...props });
|
|
57545
|
+
}
|
|
56361
57546
|
if (!isAuthenticated || !isMiniMode) {
|
|
56362
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingDialer, { variant, isAuthenticated, ...props });
|
|
57547
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingDialer, { variant, portalTarget, isAuthenticated, ...props });
|
|
56363
57548
|
}
|
|
56364
57549
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(AuthenticatedMiniDialer, { ...props });
|
|
56365
57550
|
}
|
|
@@ -56372,10 +57557,11 @@ function AuthenticatedMiniDialer({
|
|
|
56372
57557
|
}) {
|
|
56373
57558
|
const { skipManualQualification } = useDialerConfig();
|
|
56374
57559
|
const operatorState = clientSdkReactExports.useCallOperatorState();
|
|
56375
|
-
const currentCall = clientSdkReactExports.useCallOperatorCurrentCall();
|
|
56376
57560
|
const currentCallInfo = clientSdkReactExports.useCallOperatorCurrentCallInfo();
|
|
56377
|
-
const
|
|
56378
|
-
const
|
|
57561
|
+
const rawSuccessQualifications = clientSdkReactExports.useCallOperatorSuccessQualifications();
|
|
57562
|
+
const rawDiscardQualifications = clientSdkReactExports.useCallOperatorDiscardQualifications();
|
|
57563
|
+
const successQualifications = useMemo(() => rawSuccessQualifications ?? [], [rawSuccessQualifications]);
|
|
57564
|
+
const discardQualifications = useMemo(() => rawDiscardQualifications ?? [], [rawDiscardQualifications]);
|
|
56379
57565
|
const { finishAfterCall } = clientSdkReactExports.useCallOperatorControls();
|
|
56380
57566
|
const [isClientInfoModalOpen, setIsClientInfoModalOpen] = useState(false);
|
|
56381
57567
|
const [isQualificationModalOpen, setIsQualificationModalOpen] = useState(false);
|
|
@@ -56388,7 +57574,6 @@ function AuthenticatedMiniDialer({
|
|
|
56388
57574
|
const isInCall = callState === "callInProgress";
|
|
56389
57575
|
const isRinging = callState === "manualCallRinging" || callState === "callRinging";
|
|
56390
57576
|
const isConnecting = callState === "manualCallSetup" || isRinging;
|
|
56391
|
-
(currentCall == null ? void 0 : currentCall.direction) === "incoming";
|
|
56392
57577
|
const isAfterCall = callState === "afterCall";
|
|
56393
57578
|
useEffect(() => {
|
|
56394
57579
|
if (!isInCall) {
|
|
@@ -56709,7 +57894,7 @@ class CallixDialerWidget {
|
|
|
56709
57894
|
}
|
|
56710
57895
|
this.root = clientExports.createRoot(this.container);
|
|
56711
57896
|
this.root.render(
|
|
56712
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(DialerWrapper, { options: this.options }) })
|
|
57897
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(DialerWrapper, { options: this.options, containerEl: this.container }) })
|
|
56713
57898
|
);
|
|
56714
57899
|
if (this.options.onReady) {
|
|
56715
57900
|
this.options.onReady();
|
|
@@ -56739,8 +57924,7 @@ const getStorageKeys = (username) => ({
|
|
|
56739
57924
|
SKIP_MANUAL_QUALIFICATION: `callix_dialer_${username}_skip_manual_qualification`
|
|
56740
57925
|
});
|
|
56741
57926
|
const LAST_USERNAME_KEY = "callix_dialer_last_username";
|
|
56742
|
-
|
|
56743
|
-
function DialerWrapper({ options }) {
|
|
57927
|
+
function DialerWrapper({ options, containerEl }) {
|
|
56744
57928
|
const [username, setUsername] = useState(null);
|
|
56745
57929
|
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
56746
57930
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -56751,6 +57935,7 @@ function DialerWrapper({ options }) {
|
|
|
56751
57935
|
const [skipManualQualification, setSkipManualQualification] = useState(false);
|
|
56752
57936
|
const presetUsername = options.presetUsername ? options.presetUsername.trim() : null;
|
|
56753
57937
|
const uiVariant = options.uiVariant ?? "default";
|
|
57938
|
+
const portalTarget = useMemo(() => options.portalTarget ?? containerEl ?? null, [options.portalTarget, containerEl]);
|
|
56754
57939
|
const autoLoginAttemptedRef = useRef(false);
|
|
56755
57940
|
const lastPresetRef = useRef(presetUsername);
|
|
56756
57941
|
useEffect(() => {
|
|
@@ -56761,6 +57946,7 @@ function DialerWrapper({ options }) {
|
|
|
56761
57946
|
try {
|
|
56762
57947
|
const storedLastUsername = localStorage.getItem(LAST_USERNAME_KEY);
|
|
56763
57948
|
if (!storedLastUsername) {
|
|
57949
|
+
console.log("[Callix Dialer] Nenhum username salvo, aguardando login manual");
|
|
56764
57950
|
setIsRestoringSession(false);
|
|
56765
57951
|
return;
|
|
56766
57952
|
}
|
|
@@ -56769,37 +57955,19 @@ function DialerWrapper({ options }) {
|
|
|
56769
57955
|
setIsRestoringSession(false);
|
|
56770
57956
|
return;
|
|
56771
57957
|
}
|
|
57958
|
+
console.log("[Callix Dialer] Username encontrado, irá fazer novo login:", storedLastUsername);
|
|
57959
|
+
setUsername(storedLastUsername);
|
|
56772
57960
|
const STORAGE_KEYS = getStorageKeys(storedLastUsername);
|
|
56773
|
-
const
|
|
56774
|
-
|
|
56775
|
-
|
|
56776
|
-
if (storedLastUsername && storedToken && storedDomain && storedTimestamp) {
|
|
56777
|
-
const timestamp = parseInt(storedTimestamp, 10);
|
|
56778
|
-
const now = Date.now();
|
|
56779
|
-
if (now - timestamp < SESSION_EXPIRATION_MS) {
|
|
56780
|
-
console.log("[Callix Dialer] Restaurando sessão salva:", storedLastUsername);
|
|
56781
|
-
setUsername(storedLastUsername);
|
|
56782
|
-
setSessionToken(storedToken);
|
|
56783
|
-
setCallixDomain(storedDomain);
|
|
56784
|
-
setIsAuthenticated(true);
|
|
56785
|
-
const storedSkipQualification = localStorage.getItem(STORAGE_KEYS.SKIP_MANUAL_QUALIFICATION);
|
|
56786
|
-
if (storedSkipQualification) {
|
|
56787
|
-
setSkipManualQualification(storedSkipQualification === "true");
|
|
56788
|
-
}
|
|
56789
|
-
} else {
|
|
56790
|
-
console.log("[Callix Dialer] Sessão expirada, limpando...");
|
|
56791
|
-
localStorage.removeItem(LAST_USERNAME_KEY);
|
|
56792
|
-
localStorage.removeItem(STORAGE_KEYS.SESSION_TOKEN);
|
|
56793
|
-
localStorage.removeItem(STORAGE_KEYS.DOMAIN);
|
|
56794
|
-
localStorage.removeItem(STORAGE_KEYS.TIMESTAMP);
|
|
56795
|
-
}
|
|
57961
|
+
const storedSkipQualification = localStorage.getItem(STORAGE_KEYS.SKIP_MANUAL_QUALIFICATION);
|
|
57962
|
+
if (storedSkipQualification) {
|
|
57963
|
+
setSkipManualQualification(storedSkipQualification === "true");
|
|
56796
57964
|
}
|
|
56797
57965
|
} catch (err) {
|
|
56798
|
-
console.error("[Callix Dialer] Erro ao
|
|
57966
|
+
console.error("[Callix Dialer] Erro ao verificar sessão:", err);
|
|
56799
57967
|
} finally {
|
|
56800
57968
|
setIsRestoringSession(false);
|
|
56801
57969
|
}
|
|
56802
|
-
}, []);
|
|
57970
|
+
}, [presetUsername]);
|
|
56803
57971
|
useEffect(() => {
|
|
56804
57972
|
if (presetUsername && username !== presetUsername) {
|
|
56805
57973
|
setUsername(presetUsername);
|
|
@@ -56897,6 +58065,14 @@ function DialerWrapper({ options }) {
|
|
|
56897
58065
|
autoLoginAttemptedRef.current = true;
|
|
56898
58066
|
void handleLogin(presetUsername);
|
|
56899
58067
|
}, [presetUsername, isAuthenticated, isLoading, isRestoringSession, handleLogin]);
|
|
58068
|
+
useEffect(() => {
|
|
58069
|
+
if (presetUsername || !username || isAuthenticated || isLoading || isRestoringSession || autoLoginAttemptedRef.current) {
|
|
58070
|
+
return;
|
|
58071
|
+
}
|
|
58072
|
+
console.log("[Callix Dialer] Auto-login com username restaurado:", username);
|
|
58073
|
+
autoLoginAttemptedRef.current = true;
|
|
58074
|
+
void handleLogin(username);
|
|
58075
|
+
}, [presetUsername, username, isAuthenticated, isLoading, isRestoringSession, handleLogin]);
|
|
56900
58076
|
const handleLogout = () => {
|
|
56901
58077
|
const currentUsername = username;
|
|
56902
58078
|
setUsername(presetUsername ?? null);
|
|
@@ -56919,9 +58095,9 @@ function DialerWrapper({ options }) {
|
|
|
56919
58095
|
}
|
|
56920
58096
|
}
|
|
56921
58097
|
};
|
|
56922
|
-
const DialerComponent = options.mode === "inline" ? InlineDialer : FloatingDialer;
|
|
58098
|
+
const DialerComponent = options.mode === "inline" || uiVariant === "mobile" ? InlineDialer : FloatingDialer;
|
|
56923
58099
|
if (!isAuthenticated || !sessionToken || !callixDomain) {
|
|
56924
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
58100
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(DialerConfigContext.Provider, { value: { skipManualQualification }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
56925
58101
|
DialerComponent,
|
|
56926
58102
|
{
|
|
56927
58103
|
isAuthenticated: false,
|
|
@@ -56930,9 +58106,10 @@ function DialerWrapper({ options }) {
|
|
|
56930
58106
|
onLogout: handleLogout,
|
|
56931
58107
|
isLoadingSession: isLoading || isRestoringSession,
|
|
56932
58108
|
sessionError: error2,
|
|
56933
|
-
variant: uiVariant
|
|
58109
|
+
variant: uiVariant,
|
|
58110
|
+
portalTarget
|
|
56934
58111
|
}
|
|
56935
|
-
);
|
|
58112
|
+
) });
|
|
56936
58113
|
}
|
|
56937
58114
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(DialerConfigContext.Provider, { value: { skipManualQualification }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
56938
58115
|
clientSdkReactExports.CallixClientProvider,
|
|
@@ -56948,7 +58125,8 @@ function DialerWrapper({ options }) {
|
|
|
56948
58125
|
onLogout: handleLogout,
|
|
56949
58126
|
isLoadingSession: isLoading,
|
|
56950
58127
|
sessionError: error2,
|
|
56951
|
-
variant: uiVariant
|
|
58128
|
+
variant: uiVariant,
|
|
58129
|
+
portalTarget
|
|
56952
58130
|
}
|
|
56953
58131
|
)
|
|
56954
58132
|
}
|
|
@@ -56961,13 +58139,16 @@ function init(options) {
|
|
|
56961
58139
|
}
|
|
56962
58140
|
const CallixDialer = {
|
|
56963
58141
|
CallixDialerWidget,
|
|
56964
|
-
init
|
|
58142
|
+
init,
|
|
58143
|
+
version: "1.0.0"
|
|
56965
58144
|
};
|
|
56966
58145
|
if (typeof window !== "undefined") {
|
|
56967
58146
|
window.CallixDialer = CallixDialer;
|
|
56968
58147
|
}
|
|
56969
58148
|
export {
|
|
58149
|
+
CallixDialerWidget,
|
|
56970
58150
|
CallixDialer as default,
|
|
58151
|
+
init,
|
|
56971
58152
|
useDialerConfig
|
|
56972
58153
|
};
|
|
56973
58154
|
//# sourceMappingURL=callix-dialer.es.js.map
|