callix-dialer-widget 1.4.2 → 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.
@@ -55527,6 +55527,15 @@ async function getCampaignFields(campaignModelId) {
55527
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) {
@@ -55631,7 +55640,7 @@ function DraggableClientInfoModal({
55631
55640
  if (!cancelled) {
55632
55641
  console.log("[DraggableClientInfoModal] ✅ Dados carregados com sucesso");
55633
55642
  setContactData(contactValues);
55634
- setFieldRows(campaignFields.rows);
55643
+ setFieldRows(campaignFields.rows || []);
55635
55644
  setFetchedContactId(campaignContact.id);
55636
55645
  setIsLoading(false);
55637
55646
  }
@@ -55714,6 +55723,7 @@ function DraggableClientInfoModal({
55714
55723
  return null;
55715
55724
  }
55716
55725
  const hasData = Object.keys(contactData).length > 0;
55726
+ const hasFieldStructure = fieldRows && fieldRows.length > 0;
55717
55727
  const getFieldValue = (fieldCode) => {
55718
55728
  return contactData[fieldCode] || "-";
55719
55729
  };
@@ -55782,29 +55792,29 @@ function DraggableClientInfoModal({
55782
55792
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-[10px] text-red-600`, children: error2 })
55783
55793
  ] })
55784
55794
  ] }) }),
55785
- !isLoading && !error2 && hasData && fieldRows.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`space-y-2`, children: fieldRows.map((row, rowIndex) => {
55786
- const gridColumns = row.map((field) => {
55787
- const width = field.width;
55788
- if (width === "100%") return "1fr";
55789
- if (width === "50%") return "0.5fr";
55790
- if (width === "33.33%") return "0.3333fr";
55791
- if (width === "25%") return "0.25fr";
55792
- if (width === "20%") return "0.2fr";
55793
- return "1fr";
55794
- }).join(" ");
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
+ }
55795
55807
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
55796
55808
  "div",
55797
55809
  {
55798
- className: tw`grid gap-2`,
55799
- style: {
55800
- gridTemplateColumns: gridColumns
55801
- },
55810
+ className: tw`grid gap-2 ${gridCols}`,
55802
55811
  children: row.map((field, fieldIndex) => /* @__PURE__ */ jsxRuntimeExports.jsx(
55803
55812
  Field,
55804
55813
  {
55805
55814
  label: field.name,
55806
55815
  value: getFieldValue(field.code),
55807
- type: field.type
55816
+ type: field.type,
55817
+ fullWidth: field.width === "100%"
55808
55818
  },
55809
55819
  `${rowIndex}-${fieldIndex}-${field.code}`
55810
55820
  ))
@@ -55826,8 +55836,14 @@ function DraggableClientInfoModal({
55826
55836
  }
55827
55837
  return null;
55828
55838
  }
55829
- function Field({ label, value, type }) {
55830
- 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: [
55831
55847
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`mb-0.5 truncate text-[9px] font-semibold uppercase tracking-wide text-slate-500`, children: label }),
55832
55848
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`break-words text-xs font-semibold text-slate-800 line-clamp-2`, children: value })
55833
55849
  ] });