callix-dialer-widget 1.5.0 → 1.5.2
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
|
}
|
|
@@ -52892,6 +52899,30 @@ async function getCodeToNameMapping(campaignModelId) {
|
|
|
52892
52899
|
const json = await response.json();
|
|
52893
52900
|
return json;
|
|
52894
52901
|
}
|
|
52902
|
+
async function getCustomerCodeToNameMapping(formId) {
|
|
52903
|
+
const url = `${API_BASE_URL$1}/api/campaign-contact/0?source=customer&formId=${encodeURIComponent(String(formId))}`;
|
|
52904
|
+
const response = await fetch(url, {
|
|
52905
|
+
method: "GET",
|
|
52906
|
+
headers: getAuthHeaders$1(),
|
|
52907
|
+
credentials: "omit"
|
|
52908
|
+
});
|
|
52909
|
+
if (!response.ok) {
|
|
52910
|
+
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
52911
|
+
throw new Error(error2.error || `Falha ao buscar campos (cliente): ${response.status}`);
|
|
52912
|
+
}
|
|
52913
|
+
const json = await response.json();
|
|
52914
|
+
const mapping = {};
|
|
52915
|
+
if (json && Array.isArray(json.rows)) {
|
|
52916
|
+
for (const row of json.rows) {
|
|
52917
|
+
for (const field of row) {
|
|
52918
|
+
if (field && field.code && field.name) {
|
|
52919
|
+
mapping[field.code] = field.name;
|
|
52920
|
+
}
|
|
52921
|
+
}
|
|
52922
|
+
}
|
|
52923
|
+
}
|
|
52924
|
+
return mapping;
|
|
52925
|
+
}
|
|
52895
52926
|
async function getContactValues$1(contactId) {
|
|
52896
52927
|
const url = `${API_BASE_URL$1}/api/campaign-contact/${contactId}`;
|
|
52897
52928
|
const response = await fetch(url, {
|
|
@@ -52906,6 +52937,20 @@ async function getContactValues$1(contactId) {
|
|
|
52906
52937
|
const json = await response.json();
|
|
52907
52938
|
return json;
|
|
52908
52939
|
}
|
|
52940
|
+
async function getCustomerContactValues(customerId) {
|
|
52941
|
+
const url = `${API_BASE_URL$1}/api/campaign-fields/0?source=customer&customerId=${encodeURIComponent(String(customerId))}`;
|
|
52942
|
+
const response = await fetch(url, {
|
|
52943
|
+
method: "GET",
|
|
52944
|
+
headers: getAuthHeaders$1(),
|
|
52945
|
+
credentials: "omit"
|
|
52946
|
+
});
|
|
52947
|
+
if (!response.ok) {
|
|
52948
|
+
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
52949
|
+
throw new Error(error2.error || `Falha ao buscar valores (cliente): ${response.status}`);
|
|
52950
|
+
}
|
|
52951
|
+
const json = await response.json();
|
|
52952
|
+
return json;
|
|
52953
|
+
}
|
|
52909
52954
|
function CallInfoDisplay() {
|
|
52910
52955
|
const callInfo = clientSdkReactExports.useCallOperatorCurrentCallInfo();
|
|
52911
52956
|
useEffect(() => {
|
|
@@ -52944,17 +52989,29 @@ function CampaignCallInfoDisplay(props) {
|
|
|
52944
52989
|
const fetchContactData = async () => {
|
|
52945
52990
|
setContactData({ finalData: {}, isLoading: true, error: null });
|
|
52946
52991
|
try {
|
|
52947
|
-
|
|
52948
|
-
|
|
52949
|
-
|
|
52950
|
-
|
|
52951
|
-
|
|
52992
|
+
const customer = campaignContact.customer;
|
|
52993
|
+
console.log("[CampaignCallInfoDisplay] 1. Verificando customer no campaignContact:", customer);
|
|
52994
|
+
let codeToNameMap = {};
|
|
52995
|
+
let contactValues = {};
|
|
52996
|
+
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
|
+
[codeToNameMap, contactValues] = await Promise.all([
|
|
52999
|
+
getCustomerCodeToNameMapping(customer.formId),
|
|
53000
|
+
getCustomerContactValues(customer.id)
|
|
53001
|
+
]);
|
|
53002
|
+
} else {
|
|
53003
|
+
console.log("[CampaignCallInfoDisplay] 2b. Modo CAMPANHA: buscando config, rows e dados...");
|
|
53004
|
+
const config = await getCampaignConfig$1(campaignContact.id);
|
|
53005
|
+
console.log("[CampaignCallInfoDisplay] 2b. Config recebida:", config);
|
|
53006
|
+
if (!config.campaignModelId) {
|
|
53007
|
+
throw new Error("campaignModelId não encontrado");
|
|
53008
|
+
}
|
|
53009
|
+
console.log("[CampaignCallInfoDisplay] 3. Buscando mapeamento e valores em paralelo...");
|
|
53010
|
+
[codeToNameMap, contactValues] = await Promise.all([
|
|
53011
|
+
getCodeToNameMapping(config.campaignModelId),
|
|
53012
|
+
getContactValues$1(campaignContact.id)
|
|
53013
|
+
]);
|
|
52952
53014
|
}
|
|
52953
|
-
console.log("[CampaignCallInfoDisplay] 3. Buscando mapeamento e valores em paralelo...");
|
|
52954
|
-
const [codeToNameMap, contactValues] = await Promise.all([
|
|
52955
|
-
getCodeToNameMapping(config.campaignModelId),
|
|
52956
|
-
getContactValues$1(campaignContact.id)
|
|
52957
|
-
]);
|
|
52958
53015
|
console.log("[CampaignCallInfoDisplay] 4. Mapeamento recebido:", codeToNameMap);
|
|
52959
53016
|
console.log("[CampaignCallInfoDisplay] 5. Valores recebidos:", contactValues);
|
|
52960
53017
|
const finalData = {};
|