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