callix-dialer-widget 1.5.2 → 1.5.4
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.
|
@@ -52937,7 +52937,7 @@ async function getContactValues$1(contactId) {
|
|
|
52937
52937
|
const json = await response.json();
|
|
52938
52938
|
return json;
|
|
52939
52939
|
}
|
|
52940
|
-
async function getCustomerContactValues(customerId) {
|
|
52940
|
+
async function getCustomerContactValues$1(customerId) {
|
|
52941
52941
|
const url = `${API_BASE_URL$1}/api/campaign-fields/0?source=customer&customerId=${encodeURIComponent(String(customerId))}`;
|
|
52942
52942
|
const response = await fetch(url, {
|
|
52943
52943
|
method: "GET",
|
|
@@ -52997,7 +52997,7 @@ function CampaignCallInfoDisplay(props) {
|
|
|
52997
52997
|
console.log("[CampaignCallInfoDisplay] 2a. Modo CUSTOMER: buscando rows (formId) e dados (customerId)...");
|
|
52998
52998
|
[codeToNameMap, contactValues] = await Promise.all([
|
|
52999
52999
|
getCustomerCodeToNameMapping(customer.formId),
|
|
53000
|
-
getCustomerContactValues(customer.id)
|
|
53000
|
+
getCustomerContactValues$1(customer.id)
|
|
53001
53001
|
]);
|
|
53002
53002
|
} else {
|
|
53003
53003
|
console.log("[CampaignCallInfoDisplay] 2b. Modo CAMPANHA: buscando config, rows e dados...");
|
|
@@ -55706,36 +55706,59 @@ function getAuthHeaders() {
|
|
|
55706
55706
|
};
|
|
55707
55707
|
if (token) {
|
|
55708
55708
|
headers["x-session-token"] = token;
|
|
55709
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
55709
55710
|
}
|
|
55710
55711
|
return headers;
|
|
55711
55712
|
}
|
|
55713
|
+
async function fetchWithRetry(url, options, retries = 3, backoff = 1e3) {
|
|
55714
|
+
console.log(`[DraggableClientInfoModal] 🚀 Iniciando fetch: ${url}`);
|
|
55715
|
+
for (let i2 = 0; i2 < retries; i2++) {
|
|
55716
|
+
try {
|
|
55717
|
+
console.log(`[DraggableClientInfoModal] 📡 Tentativa ${i2 + 1}/${retries}`);
|
|
55718
|
+
const startTime = Date.now();
|
|
55719
|
+
const response = await fetch(url, options);
|
|
55720
|
+
const duration = Date.now() - startTime;
|
|
55721
|
+
console.log(`[DraggableClientInfoModal] ⏱️ Resposta em ${duration}ms - Status: ${response.status}`);
|
|
55722
|
+
if (!response.ok) {
|
|
55723
|
+
if (response.status >= 400 && response.status < 500) {
|
|
55724
|
+
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
55725
|
+
console.error(`[DraggableClientInfoModal] ❌ Erro do cliente (${response.status}):`, error2);
|
|
55726
|
+
throw new Error(error2.error || `Falha: ${response.status}`);
|
|
55727
|
+
}
|
|
55728
|
+
console.warn(`[DraggableClientInfoModal] ⚠️ Erro do servidor (${response.status}), tentando novamente...`);
|
|
55729
|
+
throw new Error(`HTTP ${response.status}`);
|
|
55730
|
+
}
|
|
55731
|
+
const json = await response.json();
|
|
55732
|
+
console.log(`[DraggableClientInfoModal] ✅ Dados recebidos com sucesso`);
|
|
55733
|
+
return json;
|
|
55734
|
+
} catch (error2) {
|
|
55735
|
+
const isLastAttempt = i2 === retries - 1;
|
|
55736
|
+
if (isLastAttempt) {
|
|
55737
|
+
console.error(`[DraggableClientInfoModal] 💥 Falha final após ${retries} tentativas:`, error2);
|
|
55738
|
+
throw error2;
|
|
55739
|
+
}
|
|
55740
|
+
const delay = backoff * Math.pow(2, i2);
|
|
55741
|
+
console.warn(`[DraggableClientInfoModal] ⏳ Aguardando ${delay}ms antes da próxima tentativa...`);
|
|
55742
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
55743
|
+
}
|
|
55744
|
+
}
|
|
55745
|
+
throw new Error("Todas as tentativas falharam");
|
|
55746
|
+
}
|
|
55712
55747
|
async function getCampaignConfig(contactId) {
|
|
55713
55748
|
const url = `${API_BASE_URL}/api/campaign-config/${contactId}`;
|
|
55714
|
-
|
|
55749
|
+
return fetchWithRetry(url, {
|
|
55715
55750
|
method: "GET",
|
|
55716
55751
|
headers: getAuthHeaders(),
|
|
55717
55752
|
credentials: "omit"
|
|
55718
|
-
// API usa localStorage, não cookies
|
|
55719
55753
|
});
|
|
55720
|
-
if (!response.ok) {
|
|
55721
|
-
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
55722
|
-
throw new Error(error2.error || `Falha ao buscar config: ${response.status}`);
|
|
55723
|
-
}
|
|
55724
|
-
const json = await response.json();
|
|
55725
|
-
return json;
|
|
55726
55754
|
}
|
|
55727
55755
|
async function getCampaignFields(campaignModelId) {
|
|
55728
55756
|
const url = `${API_BASE_URL}/api/campaign-fields/${campaignModelId}`;
|
|
55729
|
-
const
|
|
55757
|
+
const json = await fetchWithRetry(url, {
|
|
55730
55758
|
method: "GET",
|
|
55731
55759
|
headers: getAuthHeaders(),
|
|
55732
55760
|
credentials: "omit"
|
|
55733
55761
|
});
|
|
55734
|
-
if (!response.ok) {
|
|
55735
|
-
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
55736
|
-
throw new Error(error2.error || `Falha ao buscar campos: ${response.status}`);
|
|
55737
|
-
}
|
|
55738
|
-
const json = await response.json();
|
|
55739
55762
|
console.log("[DraggableClientInfoModal] Estrutura de campos recebida:", json);
|
|
55740
55763
|
if (!json.rows || !Array.isArray(json.rows)) {
|
|
55741
55764
|
console.warn("[DraggableClientInfoModal] Estrutura de campos inválida, usando fallback");
|
|
@@ -55747,20 +55770,36 @@ async function getCampaignFields(campaignModelId) {
|
|
|
55747
55770
|
}
|
|
55748
55771
|
return json;
|
|
55749
55772
|
}
|
|
55750
|
-
async function
|
|
55751
|
-
const url = `${API_BASE_URL}/api/campaign-contact
|
|
55752
|
-
const
|
|
55773
|
+
async function getCustomerFields(formId) {
|
|
55774
|
+
const url = `${API_BASE_URL}/api/campaign-contact/0?source=customer&formId=${encodeURIComponent(String(formId))}`;
|
|
55775
|
+
const json = await fetchWithRetry(url, {
|
|
55753
55776
|
method: "GET",
|
|
55754
55777
|
headers: getAuthHeaders(),
|
|
55755
55778
|
credentials: "omit"
|
|
55756
55779
|
});
|
|
55757
|
-
|
|
55758
|
-
|
|
55759
|
-
|
|
55780
|
+
console.log("[DraggableClientInfoModal] (cliente) Estrutura de campos recebida:", json);
|
|
55781
|
+
if (!json.rows || !Array.isArray(json.rows)) {
|
|
55782
|
+
console.warn("[DraggableClientInfoModal] (cliente) Estrutura de campos inválida, usando fallback");
|
|
55783
|
+
return { rows: [], labelField: null, phoneFields: [] };
|
|
55760
55784
|
}
|
|
55761
|
-
const json = await response.json();
|
|
55762
55785
|
return json;
|
|
55763
55786
|
}
|
|
55787
|
+
async function getContactValues(contactId) {
|
|
55788
|
+
const url = `${API_BASE_URL}/api/campaign-contact/${contactId}`;
|
|
55789
|
+
return fetchWithRetry(url, {
|
|
55790
|
+
method: "GET",
|
|
55791
|
+
headers: getAuthHeaders(),
|
|
55792
|
+
credentials: "omit"
|
|
55793
|
+
});
|
|
55794
|
+
}
|
|
55795
|
+
async function getCustomerContactValues(customerId) {
|
|
55796
|
+
const url = `${API_BASE_URL}/api/campaign-fields/0?source=customer&customerId=${encodeURIComponent(String(customerId))}`;
|
|
55797
|
+
return fetchWithRetry(url, {
|
|
55798
|
+
method: "GET",
|
|
55799
|
+
headers: getAuthHeaders(),
|
|
55800
|
+
credentials: "omit"
|
|
55801
|
+
});
|
|
55802
|
+
}
|
|
55764
55803
|
function DraggableClientInfoModal({
|
|
55765
55804
|
isOpen,
|
|
55766
55805
|
campaignCallInfo,
|
|
@@ -55833,19 +55872,30 @@ function DraggableClientInfoModal({
|
|
|
55833
55872
|
setIsLoading(true);
|
|
55834
55873
|
setError(null);
|
|
55835
55874
|
try {
|
|
55836
|
-
|
|
55837
|
-
|
|
55838
|
-
|
|
55839
|
-
|
|
55840
|
-
|
|
55841
|
-
|
|
55842
|
-
|
|
55843
|
-
|
|
55844
|
-
|
|
55845
|
-
|
|
55846
|
-
|
|
55847
|
-
|
|
55848
|
-
|
|
55875
|
+
const customer = campaignContact.customer;
|
|
55876
|
+
console.log("[DraggableClientInfoModal] Verificando customer em campaignContact:", customer);
|
|
55877
|
+
let campaignFields;
|
|
55878
|
+
let contactValues;
|
|
55879
|
+
if ((customer == null ? void 0 : customer.id) && (customer == null ? void 0 : customer.formId)) {
|
|
55880
|
+
console.log("[DraggableClientInfoModal] Modo CUSTOMER: carregando form-rows (formId) e form-data (customerId)");
|
|
55881
|
+
[campaignFields, contactValues] = await Promise.all([
|
|
55882
|
+
getCustomerFields(customer.formId),
|
|
55883
|
+
getCustomerContactValues(customer.id)
|
|
55884
|
+
]);
|
|
55885
|
+
} else {
|
|
55886
|
+
console.log("[DraggableClientInfoModal] Modo CAMPANHA: buscando config, campos e valores");
|
|
55887
|
+
const config = await getCampaignConfig(campaignContact.id);
|
|
55888
|
+
console.log("[DraggableClientInfoModal] Config recebida:", config);
|
|
55889
|
+
if (!config.campaignModelId) {
|
|
55890
|
+
throw new Error("campaignModelId não encontrado");
|
|
55891
|
+
}
|
|
55892
|
+
[campaignFields, contactValues] = await Promise.all([
|
|
55893
|
+
getCampaignFields(config.campaignModelId),
|
|
55894
|
+
getContactValues(campaignContact.id)
|
|
55895
|
+
]);
|
|
55896
|
+
}
|
|
55897
|
+
console.log("[DraggableClientInfoModal] Campos recebidos:", campaignFields);
|
|
55898
|
+
console.log("[DraggableClientInfoModal] Valores recebidos:", contactValues);
|
|
55849
55899
|
if (!cancelled) {
|
|
55850
55900
|
console.log("[DraggableClientInfoModal] ✅ Dados carregados com sucesso");
|
|
55851
55901
|
setContactData(contactValues);
|
|
@@ -56338,7 +56388,7 @@ function AuthenticatedMiniDialer({
|
|
|
56338
56388
|
const isInCall = callState === "callInProgress";
|
|
56339
56389
|
const isRinging = callState === "manualCallRinging" || callState === "callRinging";
|
|
56340
56390
|
const isConnecting = callState === "manualCallSetup" || isRinging;
|
|
56341
|
-
|
|
56391
|
+
(currentCall == null ? void 0 : currentCall.direction) === "incoming";
|
|
56342
56392
|
const isAfterCall = callState === "afterCall";
|
|
56343
56393
|
useEffect(() => {
|
|
56344
56394
|
if (!isInCall) {
|
|
@@ -56351,10 +56401,10 @@ function AuthenticatedMiniDialer({
|
|
|
56351
56401
|
return () => clearInterval(interval);
|
|
56352
56402
|
}, [isInCall]);
|
|
56353
56403
|
useEffect(() => {
|
|
56354
|
-
if ((isInCall || isConnecting) &&
|
|
56404
|
+
if ((isInCall || isConnecting) && (currentCallInfo == null ? void 0 : currentCallInfo.type) === "campaign") {
|
|
56355
56405
|
setIsClientInfoModalOpen(true);
|
|
56356
56406
|
}
|
|
56357
|
-
}, [isInCall, isConnecting,
|
|
56407
|
+
}, [isInCall, isConnecting, currentCallInfo]);
|
|
56358
56408
|
useEffect(() => {
|
|
56359
56409
|
if (isAfterCall) {
|
|
56360
56410
|
const shouldSkipCampaignQualification = (currentCallInfo == null ? void 0 : currentCallInfo.type) === "campaign" && currentCallInfo.info.campaign.skipCallQualification === true;
|