callix-dialer-widget 1.4.1 → 1.4.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.
|
@@ -52878,7 +52878,7 @@ async function getCampaignConfig$1(contactId) {
|
|
|
52878
52878
|
const json = await response.json();
|
|
52879
52879
|
return json;
|
|
52880
52880
|
}
|
|
52881
|
-
async function getCodeToNameMapping
|
|
52881
|
+
async function getCodeToNameMapping(campaignModelId) {
|
|
52882
52882
|
const url = `${API_BASE_URL$1}/api/campaign-fields/${campaignModelId}`;
|
|
52883
52883
|
const response = await fetch(url, {
|
|
52884
52884
|
method: "GET",
|
|
@@ -52952,7 +52952,7 @@ function CampaignCallInfoDisplay(props) {
|
|
|
52952
52952
|
}
|
|
52953
52953
|
console.log("[CampaignCallInfoDisplay] 3. Buscando mapeamento e valores em paralelo...");
|
|
52954
52954
|
const [codeToNameMap, contactValues] = await Promise.all([
|
|
52955
|
-
getCodeToNameMapping
|
|
52955
|
+
getCodeToNameMapping(config.campaignModelId),
|
|
52956
52956
|
getContactValues$1(campaignContact.id)
|
|
52957
52957
|
]);
|
|
52958
52958
|
console.log("[CampaignCallInfoDisplay] 4. Mapeamento recebido:", codeToNameMap);
|
|
@@ -55515,7 +55515,7 @@ async function getCampaignConfig(contactId) {
|
|
|
55515
55515
|
const json = await response.json();
|
|
55516
55516
|
return json;
|
|
55517
55517
|
}
|
|
55518
|
-
async function
|
|
55518
|
+
async function getCampaignFields(campaignModelId) {
|
|
55519
55519
|
const url = `${API_BASE_URL}/api/campaign-fields/${campaignModelId}`;
|
|
55520
55520
|
const response = await fetch(url, {
|
|
55521
55521
|
method: "GET",
|
|
@@ -55524,9 +55524,18 @@ async function getCodeToNameMapping(campaignModelId) {
|
|
|
55524
55524
|
});
|
|
55525
55525
|
if (!response.ok) {
|
|
55526
55526
|
const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
|
|
55527
|
-
throw new Error(error2.error || `Falha ao buscar
|
|
55527
|
+
throw new Error(error2.error || `Falha ao buscar campos: ${response.status}`);
|
|
55528
55528
|
}
|
|
55529
55529
|
const json = await response.json();
|
|
55530
|
+
console.log("[DraggableClientInfoModal] Estrutura de campos recebida:", json);
|
|
55531
|
+
if (!json.rows || !Array.isArray(json.rows)) {
|
|
55532
|
+
console.warn("[DraggableClientInfoModal] Estrutura de campos inválida, usando fallback");
|
|
55533
|
+
return {
|
|
55534
|
+
rows: [],
|
|
55535
|
+
labelField: null,
|
|
55536
|
+
phoneFields: []
|
|
55537
|
+
};
|
|
55538
|
+
}
|
|
55530
55539
|
return json;
|
|
55531
55540
|
}
|
|
55532
55541
|
async function getContactValues(contactId) {
|
|
@@ -55556,6 +55565,7 @@ function DraggableClientInfoModal({
|
|
|
55556
55565
|
const [position2, setPosition] = useState({ x: 100, y: 100 });
|
|
55557
55566
|
const [isDragging, setIsDragging] = useState(false);
|
|
55558
55567
|
const [contactData, setContactData] = useState({});
|
|
55568
|
+
const [fieldRows, setFieldRows] = useState([]);
|
|
55559
55569
|
const [isLoading, setIsLoading] = useState(false);
|
|
55560
55570
|
const [error2, setError] = useState(null);
|
|
55561
55571
|
const [fetchedContactId, setFetchedContactId] = useState(null);
|
|
@@ -55620,22 +55630,17 @@ function DraggableClientInfoModal({
|
|
|
55620
55630
|
if (!config.campaignModelId) {
|
|
55621
55631
|
throw new Error("campaignModelId não encontrado");
|
|
55622
55632
|
}
|
|
55623
|
-
console.log("[DraggableClientInfoModal] 3. Buscando
|
|
55624
|
-
const [
|
|
55625
|
-
|
|
55633
|
+
console.log("[DraggableClientInfoModal] 3. Buscando campos e valores em paralelo...");
|
|
55634
|
+
const [campaignFields, contactValues] = await Promise.all([
|
|
55635
|
+
getCampaignFields(config.campaignModelId),
|
|
55626
55636
|
getContactValues(campaignContact.id)
|
|
55627
55637
|
]);
|
|
55628
|
-
console.log("[DraggableClientInfoModal] 4.
|
|
55638
|
+
console.log("[DraggableClientInfoModal] 4. Campos recebidos:", campaignFields);
|
|
55629
55639
|
console.log("[DraggableClientInfoModal] 5. Valores recebidos:", contactValues);
|
|
55630
|
-
const finalData = {};
|
|
55631
|
-
Object.entries(contactValues).forEach(([code, value]) => {
|
|
55632
|
-
if (code in codeToNameMap) {
|
|
55633
|
-
finalData[codeToNameMap[code]] = value;
|
|
55634
|
-
}
|
|
55635
|
-
});
|
|
55636
55640
|
if (!cancelled) {
|
|
55637
|
-
console.log("[DraggableClientInfoModal] ✅ Dados
|
|
55638
|
-
setContactData(
|
|
55641
|
+
console.log("[DraggableClientInfoModal] ✅ Dados carregados com sucesso");
|
|
55642
|
+
setContactData(contactValues);
|
|
55643
|
+
setFieldRows(campaignFields.rows || []);
|
|
55639
55644
|
setFetchedContactId(campaignContact.id);
|
|
55640
55645
|
setIsLoading(false);
|
|
55641
55646
|
}
|
|
@@ -55718,14 +55723,9 @@ function DraggableClientInfoModal({
|
|
|
55718
55723
|
return null;
|
|
55719
55724
|
}
|
|
55720
55725
|
const hasData = Object.keys(contactData).length > 0;
|
|
55721
|
-
const
|
|
55722
|
-
|
|
55723
|
-
|
|
55724
|
-
}
|
|
55725
|
-
const valueKey = Object.keys(contactData).find(
|
|
55726
|
-
(k) => k.toLowerCase() === fieldName.toLowerCase()
|
|
55727
|
-
);
|
|
55728
|
-
return valueKey ? contactData[valueKey] : "-";
|
|
55726
|
+
const hasFieldStructure = fieldRows && fieldRows.length > 0;
|
|
55727
|
+
const getFieldValue = (fieldCode) => {
|
|
55728
|
+
return contactData[fieldCode] || "-";
|
|
55729
55729
|
};
|
|
55730
55730
|
const modalContent = /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
55731
55731
|
"div",
|
|
@@ -55792,29 +55792,36 @@ function DraggableClientInfoModal({
|
|
|
55792
55792
|
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-[10px] text-red-600`, children: error2 })
|
|
55793
55793
|
] })
|
|
55794
55794
|
] }) }),
|
|
55795
|
-
!isLoading && !error2 && hasData && /* @__PURE__ */ jsxRuntimeExports.
|
|
55796
|
-
|
|
55797
|
-
|
|
55798
|
-
|
|
55799
|
-
|
|
55800
|
-
|
|
55801
|
-
|
|
55802
|
-
|
|
55803
|
-
|
|
55804
|
-
|
|
55805
|
-
|
|
55806
|
-
|
|
55807
|
-
|
|
55808
|
-
|
|
55809
|
-
|
|
55810
|
-
|
|
55811
|
-
|
|
55812
|
-
|
|
55813
|
-
|
|
55814
|
-
|
|
55815
|
-
|
|
55816
|
-
|
|
55817
|
-
|
|
55795
|
+
!isLoading && !error2 && hasData && hasFieldStructure && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`space-y-2`, children: fieldRows.map((row, rowIndex) => {
|
|
55796
|
+
const numFields = row.length;
|
|
55797
|
+
let gridCols = "grid-cols-1";
|
|
55798
|
+
if (numFields === 2) {
|
|
55799
|
+
gridCols = "grid-cols-2";
|
|
55800
|
+
} else if (numFields === 3) {
|
|
55801
|
+
gridCols = "grid-cols-3";
|
|
55802
|
+
} else if (numFields === 4) {
|
|
55803
|
+
gridCols = "grid-cols-4";
|
|
55804
|
+
} else if (numFields === 5) {
|
|
55805
|
+
gridCols = "grid-cols-5";
|
|
55806
|
+
}
|
|
55807
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
55808
|
+
"div",
|
|
55809
|
+
{
|
|
55810
|
+
className: tw`grid gap-2 ${gridCols}`,
|
|
55811
|
+
children: row.map((field, fieldIndex) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
55812
|
+
Field,
|
|
55813
|
+
{
|
|
55814
|
+
label: field.name,
|
|
55815
|
+
value: getFieldValue(field.code),
|
|
55816
|
+
type: field.type,
|
|
55817
|
+
fullWidth: field.width === "100%"
|
|
55818
|
+
},
|
|
55819
|
+
`${rowIndex}-${fieldIndex}-${field.code}`
|
|
55820
|
+
))
|
|
55821
|
+
},
|
|
55822
|
+
rowIndex
|
|
55823
|
+
);
|
|
55824
|
+
}) }),
|
|
55818
55825
|
!isLoading && !error2 && !hasData && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex flex-col items-center justify-center rounded-lg border border-slate-200 bg-slate-50 px-4 py-8 text-center`, children: [
|
|
55819
55826
|
/* @__PURE__ */ jsxRuntimeExports.jsx(FiUser, { className: tw`mb-2 h-8 w-8 text-slate-400` }),
|
|
55820
55827
|
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-sm text-slate-500`, children: "Nenhum dado disponível" })
|
|
@@ -55829,8 +55836,14 @@ function DraggableClientInfoModal({
|
|
|
55829
55836
|
}
|
|
55830
55837
|
return null;
|
|
55831
55838
|
}
|
|
55832
|
-
function Field({
|
|
55833
|
-
|
|
55839
|
+
function Field({
|
|
55840
|
+
label,
|
|
55841
|
+
value,
|
|
55842
|
+
type,
|
|
55843
|
+
fullWidth
|
|
55844
|
+
}) {
|
|
55845
|
+
const widthClass = fullWidth ? "col-span-full" : "";
|
|
55846
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`rounded-lg border border-slate-200 bg-white p-2 ${widthClass}`, children: [
|
|
55834
55847
|
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`mb-0.5 truncate text-[9px] font-semibold uppercase tracking-wide text-slate-500`, children: label }),
|
|
55835
55848
|
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`break-words text-xs font-semibold text-slate-800 line-clamp-2`, children: value })
|
|
55836
55849
|
] });
|