callix-dialer-widget 1.5.1 → 1.5.3
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.
|
@@ -52860,6 +52860,13 @@ function getAuthHeaders$1() {
|
|
|
52860
52860
|
};
|
|
52861
52861
|
if (token) {
|
|
52862
52862
|
headers["x-session-token"] = token;
|
|
52863
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
52864
|
+
} else {
|
|
52865
|
+
try {
|
|
52866
|
+
const keys = Array.from({ length: localStorage.length }, (_4, i2) => localStorage.key(i2)).filter(Boolean);
|
|
52867
|
+
console.warn("[CallInfoDisplay] Nenhum token encontrado no localStorage. Chaves disponíveis:", keys);
|
|
52868
|
+
} catch {
|
|
52869
|
+
}
|
|
52863
52870
|
}
|
|
52864
52871
|
return headers;
|
|
52865
52872
|
}
|
|
@@ -52930,7 +52937,7 @@ async function getContactValues$1(contactId) {
|
|
|
52930
52937
|
const json = await response.json();
|
|
52931
52938
|
return json;
|
|
52932
52939
|
}
|
|
52933
|
-
async function getCustomerContactValues(customerId) {
|
|
52940
|
+
async function getCustomerContactValues$1(customerId) {
|
|
52934
52941
|
const url = `${API_BASE_URL$1}/api/campaign-fields/0?source=customer&customerId=${encodeURIComponent(String(customerId))}`;
|
|
52935
52942
|
const response = await fetch(url, {
|
|
52936
52943
|
method: "GET",
|
|
@@ -52990,7 +52997,7 @@ function CampaignCallInfoDisplay(props) {
|
|
|
52990
52997
|
console.log("[CampaignCallInfoDisplay] 2a. Modo CUSTOMER: buscando rows (formId) e dados (customerId)...");
|
|
52991
52998
|
[codeToNameMap, contactValues] = await Promise.all([
|
|
52992
52999
|
getCustomerCodeToNameMapping(customer.formId),
|
|
52993
|
-
getCustomerContactValues(customer.id)
|
|
53000
|
+
getCustomerContactValues$1(customer.id)
|
|
52994
53001
|
]);
|
|
52995
53002
|
} else {
|
|
52996
53003
|
console.log("[CampaignCallInfoDisplay] 2b. Modo CAMPANHA: buscando config, rows e dados...");
|
|
@@ -55699,6 +55706,7 @@ function getAuthHeaders() {
|
|
|
55699
55706
|
};
|
|
55700
55707
|
if (token) {
|
|
55701
55708
|
headers["x-session-token"] = token;
|
|
55709
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
55702
55710
|
}
|
|
55703
55711
|
return headers;
|
|
55704
55712
|
}
|
|
@@ -55740,6 +55748,25 @@ async function getCampaignFields(campaignModelId) {
|
|
|
55740
55748
|
}
|
|
55741
55749
|
return json;
|
|
55742
55750
|
}
|
|
55751
|
+
async function getCustomerFields(formId) {
|
|
55752
|
+
const url = `${API_BASE_URL}/api/campaign-contact/0?source=customer&formId=${encodeURIComponent(String(formId))}`;
|
|
55753
|
+
const response = await fetch(url, {
|
|
55754
|
+
method: "GET",
|
|
55755
|
+
headers: getAuthHeaders(),
|
|
55756
|
+
credentials: "omit"
|
|
55757
|
+
});
|
|
55758
|
+
if (!response.ok) {
|
|
55759
|
+
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
55760
|
+
throw new Error(error2.error || `Falha ao buscar campos (cliente): ${response.status}`);
|
|
55761
|
+
}
|
|
55762
|
+
const json = await response.json();
|
|
55763
|
+
console.log("[DraggableClientInfoModal] (cliente) Estrutura de campos recebida:", json);
|
|
55764
|
+
if (!json.rows || !Array.isArray(json.rows)) {
|
|
55765
|
+
console.warn("[DraggableClientInfoModal] (cliente) Estrutura de campos inválida, usando fallback");
|
|
55766
|
+
return { rows: [], labelField: null, phoneFields: [] };
|
|
55767
|
+
}
|
|
55768
|
+
return json;
|
|
55769
|
+
}
|
|
55743
55770
|
async function getContactValues(contactId) {
|
|
55744
55771
|
const url = `${API_BASE_URL}/api/campaign-contact/${contactId}`;
|
|
55745
55772
|
const response = await fetch(url, {
|
|
@@ -55754,6 +55781,20 @@ async function getContactValues(contactId) {
|
|
|
55754
55781
|
const json = await response.json();
|
|
55755
55782
|
return json;
|
|
55756
55783
|
}
|
|
55784
|
+
async function getCustomerContactValues(customerId) {
|
|
55785
|
+
const url = `${API_BASE_URL}/api/campaign-fields/0?source=customer&customerId=${encodeURIComponent(String(customerId))}`;
|
|
55786
|
+
const response = await fetch(url, {
|
|
55787
|
+
method: "GET",
|
|
55788
|
+
headers: getAuthHeaders(),
|
|
55789
|
+
credentials: "omit"
|
|
55790
|
+
});
|
|
55791
|
+
if (!response.ok) {
|
|
55792
|
+
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
55793
|
+
throw new Error(error2.error || `Falha ao buscar valores (cliente): ${response.status}`);
|
|
55794
|
+
}
|
|
55795
|
+
const json = await response.json();
|
|
55796
|
+
return json;
|
|
55797
|
+
}
|
|
55757
55798
|
function DraggableClientInfoModal({
|
|
55758
55799
|
isOpen,
|
|
55759
55800
|
campaignCallInfo,
|
|
@@ -55826,19 +55867,30 @@ function DraggableClientInfoModal({
|
|
|
55826
55867
|
setIsLoading(true);
|
|
55827
55868
|
setError(null);
|
|
55828
55869
|
try {
|
|
55829
|
-
|
|
55830
|
-
|
|
55831
|
-
|
|
55832
|
-
|
|
55833
|
-
|
|
55834
|
-
|
|
55835
|
-
|
|
55836
|
-
|
|
55837
|
-
|
|
55838
|
-
|
|
55839
|
-
|
|
55840
|
-
|
|
55841
|
-
|
|
55870
|
+
const customer = campaignContact.customer;
|
|
55871
|
+
console.log("[DraggableClientInfoModal] Verificando customer em campaignContact:", customer);
|
|
55872
|
+
let campaignFields;
|
|
55873
|
+
let contactValues;
|
|
55874
|
+
if ((customer == null ? void 0 : customer.id) && (customer == null ? void 0 : customer.formId)) {
|
|
55875
|
+
console.log("[DraggableClientInfoModal] Modo CUSTOMER: carregando form-rows (formId) e form-data (customerId)");
|
|
55876
|
+
[campaignFields, contactValues] = await Promise.all([
|
|
55877
|
+
getCustomerFields(customer.formId),
|
|
55878
|
+
getCustomerContactValues(customer.id)
|
|
55879
|
+
]);
|
|
55880
|
+
} else {
|
|
55881
|
+
console.log("[DraggableClientInfoModal] Modo CAMPANHA: buscando config, campos e valores");
|
|
55882
|
+
const config = await getCampaignConfig(campaignContact.id);
|
|
55883
|
+
console.log("[DraggableClientInfoModal] Config recebida:", config);
|
|
55884
|
+
if (!config.campaignModelId) {
|
|
55885
|
+
throw new Error("campaignModelId não encontrado");
|
|
55886
|
+
}
|
|
55887
|
+
[campaignFields, contactValues] = await Promise.all([
|
|
55888
|
+
getCampaignFields(config.campaignModelId),
|
|
55889
|
+
getContactValues(campaignContact.id)
|
|
55890
|
+
]);
|
|
55891
|
+
}
|
|
55892
|
+
console.log("[DraggableClientInfoModal] Campos recebidos:", campaignFields);
|
|
55893
|
+
console.log("[DraggableClientInfoModal] Valores recebidos:", contactValues);
|
|
55842
55894
|
if (!cancelled) {
|
|
55843
55895
|
console.log("[DraggableClientInfoModal] ✅ Dados carregados com sucesso");
|
|
55844
55896
|
setContactData(contactValues);
|
|
@@ -56331,7 +56383,7 @@ function AuthenticatedMiniDialer({
|
|
|
56331
56383
|
const isInCall = callState === "callInProgress";
|
|
56332
56384
|
const isRinging = callState === "manualCallRinging" || callState === "callRinging";
|
|
56333
56385
|
const isConnecting = callState === "manualCallSetup" || isRinging;
|
|
56334
|
-
|
|
56386
|
+
(currentCall == null ? void 0 : currentCall.direction) === "incoming";
|
|
56335
56387
|
const isAfterCall = callState === "afterCall";
|
|
56336
56388
|
useEffect(() => {
|
|
56337
56389
|
if (!isInCall) {
|
|
@@ -56344,10 +56396,10 @@ function AuthenticatedMiniDialer({
|
|
|
56344
56396
|
return () => clearInterval(interval);
|
|
56345
56397
|
}, [isInCall]);
|
|
56346
56398
|
useEffect(() => {
|
|
56347
|
-
if ((isInCall || isConnecting) &&
|
|
56399
|
+
if ((isInCall || isConnecting) && (currentCallInfo == null ? void 0 : currentCallInfo.type) === "campaign") {
|
|
56348
56400
|
setIsClientInfoModalOpen(true);
|
|
56349
56401
|
}
|
|
56350
|
-
}, [isInCall, isConnecting,
|
|
56402
|
+
}, [isInCall, isConnecting, currentCallInfo]);
|
|
56351
56403
|
useEffect(() => {
|
|
56352
56404
|
if (isAfterCall) {
|
|
56353
56405
|
const shouldSkipCampaignQualification = (currentCallInfo == null ? void 0 : currentCallInfo.type) === "campaign" && currentCallInfo.info.campaign.skipCallQualification === true;
|