callix-dialer-widget 1.5.3 → 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.
|
@@ -55710,33 +55710,55 @@ function getAuthHeaders() {
|
|
|
55710
55710
|
}
|
|
55711
55711
|
return headers;
|
|
55712
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
|
+
}
|
|
55713
55747
|
async function getCampaignConfig(contactId) {
|
|
55714
55748
|
const url = `${API_BASE_URL}/api/campaign-config/${contactId}`;
|
|
55715
|
-
|
|
55749
|
+
return fetchWithRetry(url, {
|
|
55716
55750
|
method: "GET",
|
|
55717
55751
|
headers: getAuthHeaders(),
|
|
55718
55752
|
credentials: "omit"
|
|
55719
|
-
// API usa localStorage, não cookies
|
|
55720
55753
|
});
|
|
55721
|
-
if (!response.ok) {
|
|
55722
|
-
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
55723
|
-
throw new Error(error2.error || `Falha ao buscar config: ${response.status}`);
|
|
55724
|
-
}
|
|
55725
|
-
const json = await response.json();
|
|
55726
|
-
return json;
|
|
55727
55754
|
}
|
|
55728
55755
|
async function getCampaignFields(campaignModelId) {
|
|
55729
55756
|
const url = `${API_BASE_URL}/api/campaign-fields/${campaignModelId}`;
|
|
55730
|
-
const
|
|
55757
|
+
const json = await fetchWithRetry(url, {
|
|
55731
55758
|
method: "GET",
|
|
55732
55759
|
headers: getAuthHeaders(),
|
|
55733
55760
|
credentials: "omit"
|
|
55734
55761
|
});
|
|
55735
|
-
if (!response.ok) {
|
|
55736
|
-
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
55737
|
-
throw new Error(error2.error || `Falha ao buscar campos: ${response.status}`);
|
|
55738
|
-
}
|
|
55739
|
-
const json = await response.json();
|
|
55740
55762
|
console.log("[DraggableClientInfoModal] Estrutura de campos recebida:", json);
|
|
55741
55763
|
if (!json.rows || !Array.isArray(json.rows)) {
|
|
55742
55764
|
console.warn("[DraggableClientInfoModal] Estrutura de campos inválida, usando fallback");
|
|
@@ -55750,16 +55772,11 @@ async function getCampaignFields(campaignModelId) {
|
|
|
55750
55772
|
}
|
|
55751
55773
|
async function getCustomerFields(formId) {
|
|
55752
55774
|
const url = `${API_BASE_URL}/api/campaign-contact/0?source=customer&formId=${encodeURIComponent(String(formId))}`;
|
|
55753
|
-
const
|
|
55775
|
+
const json = await fetchWithRetry(url, {
|
|
55754
55776
|
method: "GET",
|
|
55755
55777
|
headers: getAuthHeaders(),
|
|
55756
55778
|
credentials: "omit"
|
|
55757
55779
|
});
|
|
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
55780
|
console.log("[DraggableClientInfoModal] (cliente) Estrutura de campos recebida:", json);
|
|
55764
55781
|
if (!json.rows || !Array.isArray(json.rows)) {
|
|
55765
55782
|
console.warn("[DraggableClientInfoModal] (cliente) Estrutura de campos inválida, usando fallback");
|
|
@@ -55769,31 +55786,19 @@ async function getCustomerFields(formId) {
|
|
|
55769
55786
|
}
|
|
55770
55787
|
async function getContactValues(contactId) {
|
|
55771
55788
|
const url = `${API_BASE_URL}/api/campaign-contact/${contactId}`;
|
|
55772
|
-
|
|
55789
|
+
return fetchWithRetry(url, {
|
|
55773
55790
|
method: "GET",
|
|
55774
55791
|
headers: getAuthHeaders(),
|
|
55775
55792
|
credentials: "omit"
|
|
55776
55793
|
});
|
|
55777
|
-
if (!response.ok) {
|
|
55778
|
-
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
55779
|
-
throw new Error(error2.error || `Falha ao buscar valores: ${response.status}`);
|
|
55780
|
-
}
|
|
55781
|
-
const json = await response.json();
|
|
55782
|
-
return json;
|
|
55783
55794
|
}
|
|
55784
55795
|
async function getCustomerContactValues(customerId) {
|
|
55785
55796
|
const url = `${API_BASE_URL}/api/campaign-fields/0?source=customer&customerId=${encodeURIComponent(String(customerId))}`;
|
|
55786
|
-
|
|
55797
|
+
return fetchWithRetry(url, {
|
|
55787
55798
|
method: "GET",
|
|
55788
55799
|
headers: getAuthHeaders(),
|
|
55789
55800
|
credentials: "omit"
|
|
55790
55801
|
});
|
|
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
55802
|
}
|
|
55798
55803
|
function DraggableClientInfoModal({
|
|
55799
55804
|
isOpen,
|