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$1(campaignModelId) {
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$1(config.campaignModelId),
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 getCodeToNameMapping(campaignModelId) {
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 mapeamento: ${response.status}`);
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 mapeamento e valores em paralelo...");
55624
- const [codeToNameMap, contactValues] = await Promise.all([
55625
- getCodeToNameMapping(config.campaignModelId),
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. Mapeamento recebido:", codeToNameMap);
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 finais mapeados:", finalData);
55638
- setContactData(finalData);
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 getFieldValue = (fieldName) => {
55722
- if (contactData[fieldName]) {
55723
- return contactData[fieldName];
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.jsxs("div", { className: tw`space-y-2`, children: [
55796
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`grid grid-cols-3 gap-2`, children: [
55797
- /* @__PURE__ */ jsxRuntimeExports.jsx(Field, { label: "CNPJ", value: getFieldValue("CNPJ") }),
55798
- /* @__PURE__ */ jsxRuntimeExports.jsx(Field, { label: "EMPRESA", value: getFieldValue("EMPRESA") }),
55799
- /* @__PURE__ */ jsxRuntimeExports.jsx(Field, { label: "TOTAL BENEFÍCIO", value: getFieldValue("TOTAL BENEFICIO") })
55800
- ] }),
55801
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`grid grid-cols-3 gap-2`, children: [
55802
- /* @__PURE__ */ jsxRuntimeExports.jsx(Field, { label: "DECISOR", value: getFieldValue("DECISOR") }),
55803
- /* @__PURE__ */ jsxRuntimeExports.jsx(Field, { label: "PRODUTO", value: getFieldValue("PRODUTO PROSPECTADO") }),
55804
- /* @__PURE__ */ jsxRuntimeExports.jsx(Field, { label: "VALOR PARCELAMENTO", value: getFieldValue("VALOR QUE PAGA POR MÊS EM PARCELAMENTOS") })
55805
- ] }),
55806
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`grid grid-cols-3 gap-2`, children: [
55807
- /* @__PURE__ */ jsxRuntimeExports.jsx(Field, { label: "SALDO PGFN", value: getFieldValue("TOTAL SALDO DEVEDOR PGFN") }),
55808
- /* @__PURE__ */ jsxRuntimeExports.jsx(Field, { label: "SALDO RFB", value: getFieldValue("TOTAL SALDO DEVEDOR RFB") }),
55809
- /* @__PURE__ */ jsxRuntimeExports.jsx(Field, { label: "DÍVIDA ATIVA", value: getFieldValue("DIVIDA ATIVA") })
55810
- ] }),
55811
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`grid grid-cols-4 gap-2`, children: [
55812
- /* @__PURE__ */ jsxRuntimeExports.jsx(Field, { label: "CORRESP. SÓCIO", value: getFieldValue("CORRESPONSABILIDADE SOCIO") }),
55813
- /* @__PURE__ */ jsxRuntimeExports.jsx(Field, { label: "EXEC. FISCAL", value: getFieldValue("EXECUÇÃO FISCAL") }),
55814
- /* @__PURE__ */ jsxRuntimeExports.jsx(Field, { label: "TRANSAÇÃO BENEF.", value: getFieldValue("TRANSAÇÃO COM BENEFICIO") }),
55815
- /* @__PURE__ */ jsxRuntimeExports.jsx(Field, { label: "REGIME TRIB.", value: getFieldValue("REGIME TRIBUTARIO") })
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({ label, value }) {
55833
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`rounded-lg border border-slate-200 bg-white p-2`, children: [
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
  ] });