PageSourceSearch

https://accounts.wisedataagency.com/assets/js/ExportsListPage-CHoDlZYk.js

js wisedataagency.com collected 2026-09-24 14:01:44 UTC 8,708 bytes, 1 lines download raw bytes

1var M=Object.defineProperty;var N=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var w=Math.pow,S=(t,e,a)=>e in t?M(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,T=(t,e)=>{for(var a in e||(e={}))F.call(e,a)&&S(t,a,e[a]);if(N)for(var a of N(e))L.call(e,a)&&S(t,a,e[a]);return t};import{r as x,j as s}from"./vendor-BlJ90GWG.js";import{o as j,m as b,a5 as q,E as _,l as k,n as P,c3 as O,B as z,cG as $,a_ as K,x as E,u as Q,aj as V,dp as p,P as G,L as U,T as Y,bZ as Z,au as H}from"./index-BIHwndtW.js";import{A as J}from"./ActionsDropdown-CEk78LeB.js";import{B as W}from"./BackButton-BZFMqPGI.js";import{c as y}from"./crmKeys-Dih5WwA9.js";import{e as I}from"./extractErrorMessage-DjXdhE27.js";import{P as h}from"./charts-i6LaAsIH.js";import{S as C}from"./Select-CGDbQs1i.js";import"./pdf-Ba4Lif-1.js";(function(){try{var t=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:{};t.SENTRY_RELEASE={id:"0d78e8d78eda4804299eff0767f9df5613e65c75"};var e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="0a0b2825-cc25-4028-abbf-ff3c4ce68114",t._sentryDebugIdIdentifier="sentry-dbid-0a0b2825-cc25-4028-abbf-ff3c4ce68114")}catch(a){}})();function A(t){return t==="/admins"?"admin":"employee"}function X(t){const e=j(),{showErrorToast:a,showSuccessToast:c}=b(),r=_(A(t));return q({mutationFn:({targetEntity:o,format:i,filters:d})=>r.post("/crm/exports",{target_entity:o,format:i,filters:d!=null?d:{}},{headers:{"Idempotency-Key":crypto.randomUUID()}}).then(l=>l.data),onSuccess:()=>{e.invalidateQueries({queryKey:y.exports(t)}),c({title:"Exportação solicitada",message:"Avisamos por aqui e por e-mail assim que o arquivo estiver pronto."})},onError:o=>{a({message:I(o,"Não foi possível solicitar a exportação.")})}})}function ee(t){const e=j(),{showErrorToast:a}=b(),c=_(A(t));return q({mutationFn:r=>c.get(`/crm/exports/${r}/download`).then(o=>o.data),onSuccess:r=>{var i;const o=(i=r==null?void 0:r.data)==null?void 0:i.url;if(!o){a({message:"Não foi possível obter o link de download."});return}window.location.href=o},onError:(r,o)=>{var i;if(((i=r==null?void 0:r.response)==null?void 0:i.status)===410){e.invalidateQueries({queryKey:y.exports(t)}),a({title:"Arquivo expirado",message:"Este arquivo não está mais disponível. Gere uma nova exportação."});return}a({message:I(r,`Não foi possível baixar a exportação ${o}.`)})}})}function te(t,e={},a={}){const r=_(t==="/admins"?"admin":"employee");return k(T({queryKey:y.exportsList(t,e),queryFn:({signal:o})=>r.get("/crm/exports",{params:e,signal:o}).then(i=>i.data),staleTime:1e4,placeholderData:o=>o,refetchInterval:o=>{var l,f;return((f=(l=o.state.data)==null?void 0:l.data)!=null?f:[]).some(u=>u.isInProgress)?5e3:!1}},a))}function se({apiPrefix:t}){const{user:e}=P(),a=j(),{showSuccessToast:c,showErrorToast:r}=b(),[o,i]=x.useState(!1),d=x.useRef(new Set);return x.useEffect(()=>{if(!(e!=null&&e.tenant_id)||!(e!=null&&e.id))return;const l=O();if(!l)return;const f=`tenant.${e.tenant_id}.user.${e.id}.crm-export`,u=m=>{var g;if(m!=null&&m.batchId&&!(m.eventId&&d.current.has(m.eventId))){if(m.eventId&&(d.current.add(m.eventId),d.current.size>500&&(d.current=new Set(Array.from(d.current).slice(-250)))),a.invalidateQueries({queryKey:y.exports(t)}),m.status==="completed"){const D=(g=m.totalRows)!=null?g:0;c({title:"Exportação concluída",message:`${D.toLocaleString("pt-BR")} registros prontos para download.`});return}m.status==="failed"&&r({title:"Exportação falhou",message:"Não foi possível gerar o arquivo. Tente novamente."})}},n=l.private(f);return n.listen(".crm.export.completed",u),i(!0),()=>{try{n.stopListening(".crm.export.completed"),l.leave(f)}catch(m){}i(!1)}},[t,a,e==null?void 0:e.id,e==null?void 0:e.tenant_id,c,r]),{isConnected:o}}const ae={pending:"secondary",processing:"info",completed:"success",failed:"danger",expired:"warning"},oe={pending:"Na fila",processing:"Gerando",completed:"Concluída",failed:"Falhou",expired:"Expirada"};function B({status:t,label:e}){var r,o;const a=(r=ae[t])!=null?r:"secondary",c=(o=e!=null?e:oe[t])!=null?o:t;return s.jsx(z,{variant:a,size:"sm",children:c})}B.propTypes={status:h.string.isRequired,label:h.string};const ne="_form_55h1j_1",re="_footer_55h1j_7",ie="_warning_55h1j_13",ce="_hint_55h1j_33",v={form:ne,footer:re,warning:ie,hint:ce},le=[{value:"contact",label:"Contatos"},{value:"company",label:"Empresas"},{value:"deal",label:"Negociações"},{value:"tag",label:"Tags"},{value:"custom_field",label:"Campos personalizados"}],de=[{value:"xlsx",label:"Excel (.xlsx)"},{value:"csv",label:"CSV (.csv)"}
1];function R({isOpen:t,onClose:e,apiPrefix:a}){const[c,r]=x.useState("contact"),[o,i]=x.useState("xlsx"),d=X(a),l=d.isPending,f=c==="deal"&&o==="csv",u=()=>{d.mutate({targetEntity:c,format:o,filters:{}},{onSuccess:()=>{r("contact"),i("xlsx"),e()}})},n=s.jsxs("div",{className:v.footer,children:[s.jsx(E,{variant:"secondary",onClick:e,disabled:l,children:"Cancelar"}),s.jsx(E,{variant:"primary",onClick:u,disabled:l,children:l?"Solicitando...":"Exportar"})]});return s.jsx($,{isOpen:t,onClose:e,title:"Nova exportação",size:"md",footer:n,children:s.jsxs("div",{className:v.form,children:[s.jsx(C,{id:"export-target-entity",name:"target_entity",label:"O que exportar",options:le,value:c,onChange:r,disabled:l}),s.jsx(C,{id:"export-format",name:"format",label:"Formato do arquivo",options:de,value:o,onChange:i,disabled:l}),f&&s.jsxs("p",{className:v.warning,role:"alert",children:[s.jsx(K,{"aria-hidden":"true"}),s.jsxs("span",{children:["O CSV não comporta abas: os ",s.jsx("strong",{children:"itens das negociações"})," ficam de fora. Escolha Excel se precisar deles."]})]}),s.jsx("p",{className:v.hint,children:"O arquivo é gerado em segundo plano. Avisamos aqui e por e-mail quando estiver pronto, e ele fica disponível por 7 dias."})]})})}R.propTypes={isOpen:h.bool.isRequired,onClose:h.func.isRequired,apiPrefix:h.string.isRequired};function ue(t){if(!t)return"—";try{return new Intl.DateTimeFormat("pt-BR",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}catch(e){return"—"}}function me(t){if(!t||t<=0)return"—";const e=["B","KB","MB","GB"],a=Math.min(Math.floor(Math.log(t)/Math.log(1024)),e.length-1);return`${(t/w(1024,a)).toFixed(a===0?0:1)} ${e[a]}`}function _e(){var l,f;const t=Q(),e=V(),[a,c]=x.useState(!1),r=te(t),o=ee(t);se({apiPrefix:t});const i=(f=(l=r.data)==null?void 0:l.data)!=null?f:[],d=[{key:"fileName",title:"Arquivo",render:(u,n)=>s.jsxs("div",{className:p.fileCell,children:[s.jsx("span",{className:p.fileName,children:n.fileName}),s.jsxs("span",{className:p.fileMeta,children:[n.targetEntityLabel," · ",n.formatLabel]})]})},{key:"status",title:"Status",render:(u,n)=>s.jsxs("div",{className:p.statusCell,children:[s.jsx(B,{status:n.status,label:n.statusLabel}),n.status==="failed"&&n.errorMessage&&s.jsx("small",{className:p.errorMessage,children:n.errorMessage})]})},{key:"totalRows",title:"Registros",align:"right",render:(u,n)=>n.status==="completed"||n.status==="expired"?n.totalRows.toLocaleString("pt-BR"):"—"},{key:"fileSize",title:"Tamanho",align:"right",render:(u,n)=>me(n.fileSize)},{key:"createdBy",title:"Exportado por",render:(u,n)=>{var m,g;return(g=(m=n.createdBy)==null?void 0:m.name)!=null?g:"—"}},{key:"createdAt",title:"Data",render:(u,n)=>ue(n.createdAt)},{key:"actions",title:"Ações",width:"80px",align:"right",render:(u,n)=>n.isDownloadable?s.jsx(J,{size:"sm",actions:[{icon:s.jsx(H,{size:14}),label:"Baixar arquivo",onClick:()=>o.mutate(n.id)}]}):null}];return s.jsxs("div",{className:p.container,children:[s.jsx(G,{title:"Exportações"}),s.jsxs("div",{className:p.header,children:[s.jsxs("div",{className:p.headerLeft,children:[s.jsx(W,{to:`${e}/crm/contatos`,label:"Voltar para o CRM"}),s.jsxs("div",{className:p.titleContainer,children:[s.jsx("h1",{className:p.title,children:"Exportações"}),s.jsx("p",{className:p.subtitle,children:"Exporte contatos, empresas, negociações, tags e campos personalizados em Excel ou CSV. O arquivo fica disponível por 7 dias."})]})]}),s.jsx("div",{className:p.headerActions,children:s.jsx(E,{variant:"primary",icon:s.jsx(U,{size:16}),onClick:()=>c(!0),children:"Nova exportação"})})]}),s.jsx(Y,{columns:d,data:i,loading:r.isPending,getRowId:u=>u.id,emptyMessage:s.jsxs("span",{className:p.empty,children:[s.jsx(Z,{"aria-hidden":"true"}),'Nenhuma exportação ainda. Clique em "Nova exportação" para gerar a primeira.']})}),s.jsx(R,{isOpen:a,onClose:()=>c(!1),apiPrefix:t})]})}export{_e as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.