callix-dialer-widget 1.5.2 → 1.5.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.
@@ -52937,7 +52937,7 @@ async function getContactValues$1(contactId) {
52937
52937
  const json = await response.json();
52938
52938
  return json;
52939
52939
  }
52940
- async function getCustomerContactValues(customerId) {
52940
+ async function getCustomerContactValues$1(customerId) {
52941
52941
  const url = `${API_BASE_URL$1}/api/campaign-fields/0?source=customer&customerId=${encodeURIComponent(String(customerId))}`;
52942
52942
  const response = await fetch(url, {
52943
52943
  method: "GET",
@@ -52997,7 +52997,7 @@ function CampaignCallInfoDisplay(props) {
52997
52997
  console.log("[CampaignCallInfoDisplay] 2a. Modo CUSTOMER: buscando rows (formId) e dados (customerId)...");
52998
52998
  [codeToNameMap, contactValues] = await Promise.all([
52999
52999
  getCustomerCodeToNameMapping(customer.formId),
53000
- getCustomerContactValues(customer.id)
53000
+ getCustomerContactValues$1(customer.id)
53001
53001
  ]);
53002
53002
  } else {
53003
53003
  console.log("[CampaignCallInfoDisplay] 2b. Modo CAMPANHA: buscando config, rows e dados...");
@@ -55706,6 +55706,7 @@ function getAuthHeaders() {
55706
55706
  };
55707
55707
  if (token) {
55708
55708
  headers["x-session-token"] = token;
55709
+ headers["Authorization"] = `Bearer ${token}`;
55709
55710
  }
55710
55711
  return headers;
55711
55712
  }
@@ -55747,6 +55748,25 @@ async function getCampaignFields(campaignModelId) {
55747
55748
  }
55748
55749
  return json;
55749
55750
  }
55751
+ async function getCustomerFields(formId) {
55752
+ const url = `${API_BASE_URL}/api/campaign-contact/0?source=customer&formId=${encodeURIComponent(String(formId))}`;
55753
+ const response = await fetch(url, {
55754
+ method: "GET",
55755
+ headers: getAuthHeaders(),
55756
+ credentials: "omit"
55757
+ });
55758
+ if (!response.ok) {
55759
+ const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
55760
+ throw new Error(error2.error || `Falha ao buscar campos (cliente): ${response.status}`);
55761
+ }
55762
+ const json = await response.json();
55763
+ console.log("[DraggableClientInfoModal] (cliente) Estrutura de campos recebida:", json);
55764
+ if (!json.rows || !Array.isArray(json.rows)) {
55765
+ console.warn("[DraggableClientInfoModal] (cliente) Estrutura de campos inválida, usando fallback");
55766
+ return { rows: [], labelField: null, phoneFields: [] };
55767
+ }
55768
+ return json;
55769
+ }
55750
55770
  async function getContactValues(contactId) {
55751
55771
  const url = `${API_BASE_URL}/api/campaign-contact/${contactId}`;
55752
55772
  const response = await fetch(url, {
@@ -55761,6 +55781,20 @@ async function getContactValues(contactId) {
55761
55781
  const json = await response.json();
55762
55782
  return json;
55763
55783
  }
55784
+ async function getCustomerContactValues(customerId) {
55785
+ const url = `${API_BASE_URL}/api/campaign-fields/0?source=customer&customerId=${encodeURIComponent(String(customerId))}`;
55786
+ const response = await fetch(url, {
55787
+ method: "GET",
55788
+ headers: getAuthHeaders(),
55789
+ credentials: "omit"
55790
+ });
55791
+ if (!response.ok) {
55792
+ const error2 = await response.json().catch(() => ({ error: "Erro desconhecido" }));
55793
+ throw new Error(error2.error || `Falha ao buscar valores (cliente): ${response.status}`);
55794
+ }
55795
+ const json = await response.json();
55796
+ return json;
55797
+ }
55764
55798
  function DraggableClientInfoModal({
55765
55799
  isOpen,
55766
55800
  campaignCallInfo,
@@ -55833,19 +55867,30 @@ function DraggableClientInfoModal({
55833
55867
  setIsLoading(true);
55834
55868
  setError(null);
55835
55869
  try {
55836
- console.log("[DraggableClientInfoModal] 1. Buscando config para contato:", campaignContact.id);
55837
- const config = await getCampaignConfig(campaignContact.id);
55838
- console.log("[DraggableClientInfoModal] 2. Config recebida:", config);
55839
- if (!config.campaignModelId) {
55840
- throw new Error("campaignModelId não encontrado");
55841
- }
55842
- console.log("[DraggableClientInfoModal] 3. Buscando campos e valores em paralelo...");
55843
- const [campaignFields, contactValues] = await Promise.all([
55844
- getCampaignFields(config.campaignModelId),
55845
- getContactValues(campaignContact.id)
55846
- ]);
55847
- console.log("[DraggableClientInfoModal] 4. Campos recebidos:", campaignFields);
55848
- console.log("[DraggableClientInfoModal] 5. Valores recebidos:", contactValues);
55870
+ const customer = campaignContact.customer;
55871
+ console.log("[DraggableClientInfoModal] Verificando customer em campaignContact:", customer);
55872
+ let campaignFields;
55873
+ let contactValues;
55874
+ if ((customer == null ? void 0 : customer.id) && (customer == null ? void 0 : customer.formId)) {
55875
+ console.log("[DraggableClientInfoModal] Modo CUSTOMER: carregando form-rows (formId) e form-data (customerId)");
55876
+ [campaignFields, contactValues] = await Promise.all([
55877
+ getCustomerFields(customer.formId),
55878
+ getCustomerContactValues(customer.id)
55879
+ ]);
55880
+ } else {
55881
+ console.log("[DraggableClientInfoModal] Modo CAMPANHA: buscando config, campos e valores");
55882
+ const config = await getCampaignConfig(campaignContact.id);
55883
+ console.log("[DraggableClientInfoModal] Config recebida:", config);
55884
+ if (!config.campaignModelId) {
55885
+ throw new Error("campaignModelId não encontrado");
55886
+ }
55887
+ [campaignFields, contactValues] = await Promise.all([
55888
+ getCampaignFields(config.campaignModelId),
55889
+ getContactValues(campaignContact.id)
55890
+ ]);
55891
+ }
55892
+ console.log("[DraggableClientInfoModal] Campos recebidos:", campaignFields);
55893
+ console.log("[DraggableClientInfoModal] Valores recebidos:", contactValues);
55849
55894
  if (!cancelled) {
55850
55895
  console.log("[DraggableClientInfoModal] ✅ Dados carregados com sucesso");
55851
55896
  setContactData(contactValues);
@@ -56338,7 +56383,7 @@ function AuthenticatedMiniDialer({
56338
56383
  const isInCall = callState === "callInProgress";
56339
56384
  const isRinging = callState === "manualCallRinging" || callState === "callRinging";
56340
56385
  const isConnecting = callState === "manualCallSetup" || isRinging;
56341
- const isIncomingCall = (currentCall == null ? void 0 : currentCall.direction) === "incoming";
56386
+ (currentCall == null ? void 0 : currentCall.direction) === "incoming";
56342
56387
  const isAfterCall = callState === "afterCall";
56343
56388
  useEffect(() => {
56344
56389
  if (!isInCall) {
@@ -56351,10 +56396,10 @@ function AuthenticatedMiniDialer({
56351
56396
  return () => clearInterval(interval);
56352
56397
  }, [isInCall]);
56353
56398
  useEffect(() => {
56354
- if ((isInCall || isConnecting) && isIncomingCall && (currentCallInfo == null ? void 0 : currentCallInfo.type) === "campaign") {
56399
+ if ((isInCall || isConnecting) && (currentCallInfo == null ? void 0 : currentCallInfo.type) === "campaign") {
56355
56400
  setIsClientInfoModalOpen(true);
56356
56401
  }
56357
- }, [isInCall, isConnecting, isIncomingCall, currentCallInfo]);
56402
+ }, [isInCall, isConnecting, currentCallInfo]);
56358
56403
  useEffect(() => {
56359
56404
  if (isAfterCall) {
56360
56405
  const shouldSkipCampaignQualification = (currentCallInfo == null ? void 0 : currentCallInfo.type) === "campaign" && currentCallInfo.info.campaign.skipCallQualification === true;