PageSourceSearch

https://sentinel-365-c9d4f.web.app/assets/EdiProcedaPage-ClAh8sPS.js

js sentinel-365-c9d4f.web.app collected 2026-10-03 12:38:42 UTC 18,564 bytes, 1 lines download raw bytes

1import{r as s,j as e}from"./react-vendor-pafHdoJx.js";import{d as y,u as m}from"./index-Db0fDLGN.js";import{E as j}from"./ErrorState-B9i6eo2M.js";import{K as B,L as w,S as z}from"./Skeleton-iaj4CjC_.js";import{V as E,av as F,aT as O,U as T,as as D,x as I,aY as N,L as A,bQ as L,b8 as _,at as W}from"./ui-vendor-DLXJn6s3.js";import"./map-vendor-Dr8zbd0c.js";import"./firebase-vendor-D3UzkAhn.js";const M=[{key:"overview",label:"Visão Geral",icon:E},{key:"inbound",label:"Recebidos",icon:F},{key:"outbound",label:"Enviados",icon:O},{key:"partners",label:"Parceiros",icon:T}],G="••••••••••••";function re(){const[r,n]=s.useState("overview");return e.jsxs("div",{style:{padding:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:20},children:[e.jsx(E,{className:"w-6 h-6",style:{color:"var(--accent-brand)"}}),e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:22,fontWeight:700,color:"var(--page-text-primary)"},children:"EDI PROCEDA"}),e.jsx("p",{style:{fontSize:12,color:"var(--page-text-secondary)"},children:"Integração com embarcadores via NOTFIS, OCOREN, CONEMB, PREFAT, DOCCOB"})]})]}),e.jsx("div",{role:"tablist",style:{display:"flex",gap:4,borderBottom:"1px solid var(--page-border)",marginBottom:20},children:M.map(a=>e.jsxs("button",{role:"tab","aria-selected":r===a.key,onClick:()=>n(a.key),style:{padding:"10px 16px",fontSize:13,fontWeight:r===a.key?600:500,color:r===a.key?"var(--accent-brand)":"var(--page-text-secondary)",borderBottom:r===a.key?"2px solid var(--accent-brand)":"2px solid transparent",background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:6},children:[e.jsx(a.icon,{className:"w-4 h-4"}),a.label]},a.key))}),r==="overview"&&e.jsx(U,{}),r==="inbound"&&e.jsx(C,{direction:"inbound"}),r==="outbound"&&e.jsx(C,{direction:"outbound"}),r==="partners"&&e.jsx($,{})]})}function U(){const[r,n]=s.useState(null),[a,u]=s.useState(!0),[x,c]=s.useState(null),g=s.useCallback(()=>{u(!0),c(null),y.procedaStats().then(d=>n((d==null?void 0:d.stats)??null)).catch(d=>c(d)).finally(()=>u(!1))},[]);if(s.useEffect(()=>{g()},[g]),a)return e.jsx(B,{count:7});if(x)return e.jsx(j,{error:x,onRetry:g,title:"Não foi possível carregar os indicadores EDI"});if(!r)return e.jsx("p",{style:{color:"var(--page-text-secondary)"},children:"Sem dados"});const p=(r.inboundErrors24h||0)+(r.outboundErrors24h||0);return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12},children:[e.jsx(f,{label:"Parceiros ativos",value:r.partnersActive??"—"}),e.jsx(f,{label:"Recebidos hoje",value:r.inboundToday??"—"}),e.jsx(f,{label:"Enviados hoje",value:r.outboundToday??"—"}),e.jsx(f,{label:"Erros 24h",value:p,kind:p>0?"danger":"ok"}),e.jsx(f,{label:"Fila pendente",value:r.pendingQueue??"—"}),e.jsx(f,{label:"Último recebido",value:r.lastInboundAt?new Date(r.lastInboundAt).toLocaleString("pt-BR"):"—",small:!0}),e.jsx(f,{label:"Último enviado",value:r.lastOutboundAt?new Date(r.lastOutboundAt).toLocaleString("pt-BR"):"—",small:!0})]})}function f({label:r,value:n,kind:a,small:u}){return e.jsxs("div",{style:{background:"var(--page-surface)",border:"1px solid var(--page-border)",borderRadius:10,padding:14},children:[e.jsx("div",{style:{fontSize:10,color:"var(--page-text-secondary)",textTransform:"uppercase",letterSpacing:.5,marginBottom:6},children:r}),e.jsx("div",{style:{fontSize:u?13:24,fontWeight:700,color:a==="danger"?"var(--danger)":a==="ok"?"var(--accent-brand)":"var(--page-text-primary)"},children:n})]})}function C({direction:r}){const{toast:n}=m(),[a,u]=s.useState([]),[x,c]=s.useState(!0),[g,p]=s.useState(null),[d,v]=s.useState({}),i=s.useCallback(()=>{c(!0),p(null),y.procedaDocuments({direction:r,...d}).then(o=>u(Array.isArray(o==null?void 0:o.documents)?o.documents:[])).catch(o=>p(o)).finally(()=>c(!1))},[r,d]);s.useEffect(()=>{i()},[i]);const l=async o=>{try{await y.procedaReprocess(o),n({kind:"success",title:"Reprocessamento enfileirado"}),i()}catch(h){n({kind:"error",title:(h==null?void 0:h.message)||"Falha ao reprocessar"})}},b=async o=>{try{await y.procedaRetrySend(o),n({kind:"success",title:"Reenvio enfileirado"}),i()}catch(h){n({kind:"error",title:(h==null?void 0:h.message)||"Falha ao reenviar"})}};return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsxs("select",{onChange:o=>v({...d,docType:o.target.value||void 0}),"aria-label":"Tipo de documento",style:{padding:"6px 10px",borderRadius:6,background:"var(--page-surface)",border:"1px solid var(--page-border)",color:"var(--page-text-primary)"},children:[e.jsx("option",{value:"",children:"Todos tipos"}),e.jsx("option",{value:"NOTFIS",children:"NOTFIS"}),e.jsx("option",{value:"OCOREN",children:"OCOREN"}),e.jsx("option",{value:"CONEMB",children:"CONEMB"}),e.jsx("option",{value:"PREFAT",children:"PREFAT"}),e.jsx("option",{value:"DOCCOB",children:"DOCCOB"})]}),e.jsxs("select",{onChange:o=>v({...d,status:o.target.value||void 0}),"aria-label":"Status",style:{padding:"6px 10px",borderRadius:6,background:"var(--page-surface)",border:"1px solid var(--page-border)",color:"var(--page-text-primary)"},children:[e.jsx("option",{value:"",children:"Todos status"}),e.jsx("option",{value:"received",children:"Recebido"}),e.jsx("option",{value:"parsed",children:"Parseado"}),e.jsx("option",{value:"applied",children:"Aplicado"}),e.jsx("option",{value:"parse_error",children:"Erro parse"}),e.jsx("option",{value:"mapping_error",children:"Erro mapping"}),e.jsx("option",{value:"queued",children:"Na fila"}),e.jsx("option",{value:"sent",children:"Enviado"}),e.jsx("option",{value:"send_error",children:"Erro envio"})]}),e.jsxs("button",{onClick:i,style:{padding:"6px 12px",borderRadius:6,background:"var(--accent-brand)",color:"#fff",border:"none",cursor:"pointer"},children:[e.jsx(D,{className:"w-3 h-3 inline mr-1"})," Atualizar"]})]}),x?e.jsx(w,{rows:5}):g?e.jsx(j,{error:g,onRetry:i,title:r==="inbound"?"Não foi possível carregar os documentos recebidos":"Não foi possível carregar os documentos enviados"}):a.length===0?e.jsx("p",{style:{color:"var(--page-text-secondary)"},children:"Nenhum documento"}):e.jsx("div",{style:{background:"var(--page-surface)",border:"1px solid var(--page-border)",borderRadius:10,overflow:"hidden"},children:e.jsxs("table",{style:{width:"100%",fontSize:12},children:[e.jsx("thead",{style:{background:"var(--page-surface-elevated)"},children:e.jsxs("tr",{children:[e.jsx("th",{style:{padding:10,textAlign:"left"},children:"Quando"}),e.jsx("th",{style:{padding:10,textAlign:"left"},children:"Tipo"}),e.jsx("th",{style:{padding:10,textAlign:"left"},children:"Parceiro"}),e.jsx("th",{style:{padding:10,textAlign:"left"},children:"Arquivo"}),e.jsx("th",{style:{padding:10,textAlign:"left"},children:"Status"}),e.jsx("th",{style:{padding:10,textAlign:"left"},children:"Ações"})]})}),e.jsx("tbody",{children:a.map(o=>e.jsxs("tr",{style:{borderTop:"1px solid var(--page-border)"},children:[e.jsx("td",{style:{padding:10}
1,children:o.createdAt?new Date(o.createdAt).toLocaleString("pt-BR"):"—"}),e.jsxs("td",{style:{padding:10},children:[e.jsx("strong",{children:o.docType})," ",e.jsxs("span",{style:{color:"var(--page-text-secondary)"},children:["v",o.version]})]}),e.jsx("td",{style:{padding:10},children:o.partnerName}),e.jsx("td",{style:{padding:10,fontFamily:"monospace",fontSize:11},children:o.filename}),e.jsx("td",{style:{padding:10},children:e.jsx(H,{status:o.status})}),e.jsxs("td",{style:{padding:10},children:[r==="inbound"&&["parse_error","mapping_error"].includes(o.status)&&e.jsx("button",{onClick:()=>l(o.id),style:{fontSize:10,padding:"2px 8px",background:"var(--page-surface-elevated)",border:"1px solid var(--page-border)",borderRadius:4,color:"var(--page-text-primary)",cursor:"pointer"},children:"Reprocessar"}),r==="outbound"&&o.status==="send_error"&&e.jsx("button",{onClick:()=>b(o.id),style:{fontSize:10,padding:"2px 8px",background:"var(--page-surface-elevated)",border:"1px solid var(--page-border)",borderRadius:4,color:"var(--page-text-primary)",cursor:"pointer"},children:"Reenviar"}),o.errorMessage&&e.jsx("span",{style:{fontSize:10,color:"var(--danger)",marginLeft:6},children:o.errorMessage})]})]},o.id))})]})})]})}function H({status:r}){const a={received:{color:"#3B82F6",label:"Recebido"},parsing:{color:"#F59E0B",label:"Processando"},parsed:{color:"#3B82F6",label:"Parseado"},applied:{color:"#10B981",label:"Aplicado"},parse_error:{color:"#EF4444",label:"Erro parse"},mapping_error:{color:"#EF4444",label:"Erro mapping"},queued:{color:"#F59E0B",label:"Na fila"},sent:{color:"#10B981",label:"Enviado"},send_error:{color:"#EF4444",label:"Erro envio"},acked:{color:"#10B981",label:"Confirmado"}}[r]||{color:"#64748B",label:r};return e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:10,fontSize:10,fontWeight:600,background:`${a.color}22`,color:a.color},children:a.label})}function $(){const[r,n]=s.useState([]),[a,u]=s.useState(!0),[x,c]=s.useState(null),[g,p]=s.useState(!1),[d,v]=s.useState(null),i=s.useCallback(()=>{u(!0),c(null),y.procedaPartners().then(l=>n(Array.isArray(l==null?void 0:l.partners)?l.partners:[])).catch(l=>c(l)).finally(()=>u(!1))},[]);return s.useEffect(()=>{i()},[i]),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--page-text-secondary)"},children:"Parceiros embarcadores cadastrados. Cada um recebe credenciais SFTP/webhook únicas."}),e.jsxs("button",{onClick:()=>p(!0),style:{padding:"8px 14px",borderRadius:6,background:"var(--accent-brand)",color:"#fff",border:"none",cursor:"pointer",fontSize:12,fontWeight:600},children:[e.jsx(I,{className:"w-3 h-3 inline mr-1"})," Cadastrar parceiro"]})]}),a?e.jsx(w,{rows:3}):x?e.jsx(j,{error:x,onRetry:i,title:"Não foi possível carregar os parceiros"}):r.length===0?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"var(--page-text-secondary)"},children:[e.jsx(T,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"Nenhum parceiro cadastrado. Comece adicionando o primeiro embarcador."})]}):e.jsx("div",{style:{display:"grid",gap:8},children:r.map(l=>e.jsxs("div",{style:{background:"var(--page-surface)",border:"1px solid var(--page-border)",borderRadius:8,padding:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:600},children:l.name}),e.jsxs("div",{style:{fontSize:11,color:"var(--page-text-secondary)",fontFamily:"monospace"},children:["CNPJ ",l.cnpj," · ",String(l.transport||"").toUpperCase()," · ",l.active?"✓ Ativo":"○ Inativo"]})]}),e.jsx("button",{onClick:()=>v(d===l.id?null:l.id),style:{padding:"6px 12px",borderRadius:6,background:"var(--page-surface-elevated)",border:"1px solid var(--page-border)",color:"var(--page-text-primary)",cursor:"pointer",fontSize:11},children:d===l.id?"Fechar":"Detalhes"})]}),d===l.id&&e.jsx(K,{partnerId:l.id})]},l.id))}),g&&e.jsx(q,{onClose:()=>p(!1),onSaved:()=>{p(!1),i()}})]})}function R({label:r,secret:n,onReveal:a,onCopy:u}){const[x,c]=s.useState(!1),[g,p]=s.useState(!1),d=async()=>
1{if(n){p(l=>!l);return}c(!0);try{await a(),p(!0)}finally{c(!1)}},v=async()=>{if(n){u(n);return}c(!0);try{await a()}finally{c(!1)}},i=g&&!!n;return e.jsxs("div",{children:[r,": ",e.jsx("code",{children:i?n:G})," ",e.jsxs("button",{type:"button",onClick:d,disabled:x,"aria-label":i?`Ocultar ${r}`:`Revelar ${r}`,title:i?"Ocultar":"Revelar (registrado em auditoria)",style:{background:"none",border:"none",cursor:"pointer",color:"var(--accent-brand)",fontSize:11},children:[x?e.jsx(A,{className:"w-3 h-3 inline animate-spin"}):i?e.jsx(_,{className:"w-3 h-3 inline"}):e.jsx(W,{className:"w-3 h-3 inline"})," ",i?"Ocultar":"Revelar"]}),e.jsx("button",{type:"button",onClick:v,disabled:x,"aria-label":`Copiar ${r}`,style:{background:"none",border:"none",cursor:"pointer",color:"var(--accent-brand)"},children:e.jsx(N,{className:"w-3 h-3 inline"})})]})}function K({partnerId:r}){const{toast:n}=m(),[a,u]=s.useState(null),[x,c]=s.useState(null),[g,p]=s.useState(null),[d,v]=s.useState(!1),[i,l]=s.useState(null),b=s.useCallback(()=>{c(null),y.procedaPartner(r).then(t=>u((t==null?void 0:t.partner)??null)).catch(t=>c(t))},[r]);s.useEffect(()=>{b()},[b]);const o=(t,S)=>{var k;(k=navigator.clipboard)==null||k.writeText(t).then(()=>n({kind:"success",title:`${S} copiado`})).catch(()=>n({kind:"error",title:`Não foi possível copiar ${S}`}))},h=async()=>{try{const t=await y.procedaRevealSecret(r);l(t||{}),!(t!=null&&t.password)&&!(t!=null&&t.webhookSecret)&&n({kind:"warning",title:"Nenhum segredo disponível pra este parceiro"})}catch(t){throw n({kind:"error",title:"Falha ao revelar credencial",description:t==null?void 0:t.message}),t}},P=async()=>{v(!0);try{const t=await y.procedaActivationGuide(r);p((t==null?void 0:t.guide)??"")}catch(t){n({kind:"error",title:"Falha ao gerar guia de ativação",description:t==null?void 0:t.message})}finally{v(!1)}};return x?e.jsx("div",{style:{marginTop:12},children:e.jsx(j,{inline:!0,error:x,onRetry:b,title:"Não foi possível carregar o parceiro"})}):a?e.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:"1px solid var(--page-border)"},children:[a.sftp&&e.jsxs("div",{style:{background:"var(--page-surface-elevated)",padding:12,borderRadius:6,marginBottom:10},children:[e.jsx("strong",{style:{fontSize:11,color:"var(--accent-brand)"},children:"CREDENCIAIS SFTP"}),e.jsxs("div",{style:{fontFamily:"monospace",fontSize:11,marginTop:6,lineHeight:1.8},children:[e.jsxs("div",{children:["Host: ",e.jsx("code",{children:"edi.sentinel365.ai"})," · Porta: ",e.jsx("code",{children:"2222"})]}),e.jsxs("div",{children:["Usuário: ",e.jsx("code",{children:a.sftp.username})," ",e.jsx("button",{type:"button",onClick:()=>o(a.sftp.username,"Usuário"),"aria-label":"Copiar usuário",style:{background:"none",border:"none",cursor:"pointer",color:"var(--accent-brand)"},children:e.jsx(N,{className:"w-3 h-3 inline"})})]}),e.jsx(R,{label:"Senha",secret:(i==null?void 0:i.password)??null,onReveal:h,onCopy:t=>o(t,"Senha")}),e.jsxs("div",{children:["Pasta in: ",e.jsxs("code",{children:[a.sftp.rootPath,"/in"]})]}),e.jsxs("div",{children:["Pasta out: ",e.jsxs("code",{children:[a.sftp.rootPath,"/out"]})]})]})]}),a.webhook&&e.jsxs("div",{style:{background:"var(--page-surface-elevated)",padding:12,borderRadius:6,marginBottom:10},children:[e.jsx("strong",{style:{fontSize:11,color:"var(--accent-brand)"},children:"WEBHOOK"}),e.jsxs("div",{style:{fontFamily:"monospace",fontSize:11,marginTop:6,lineHeight:1.8},children:[e.jsxs("div",{children:["Endpoint inbound: ",e.jsxs("code",{children:["POST /api/proceda/webhook/inbound/",a.id]})]}),e.jsx(R,{label:"HMAC secret",secret:(i==null?void 0:i.webhookSecret)??null,onReveal:h,onCopy:t=>o(t,"Secret")})]})]}),e.jsxs("button",{onClick:P,disabled:d,style:{padding:"6px 12px",borderRadius:6,background:"var(--page-surface-elevated)",border:"1px solid var(--page-border)",color:"var(--page-text-primary)",cursor:"pointer",fontSize:11,marginRight:8},children:[d?e.jsx(A,{className:"w-3 h-3 inline mr-1 animate-spin"}):e.jsx(L,{className:"w-3 h-3 inline mr-1"})," Gerar guia de ativação"]}),g&&e.jsx("pre",{style:{marginTop:10,background:"var(--page-surface-elevated)",padding:12,borderRadius:6,fontSize:11,overflow:"auto",whiteSpace:"pre-wrap"},children:g})]}):e.jsx("div",{style:{marginTop:12},children:e.jsx(z,{lines:3})})}function q({onClose:r,onSaved:n}){const{toast:a}=m(),[u,x]=s.useState(""),[c,g]=s.useState(""),[p,d]=s.useState("sftp"),[v,i]=s.useState(!1),l=async()=>{i(!0);try{await y.procedaCreatePartner({name:u,cnpj:c,transport:p}),a({kind:"success",title:"Parceiro criado"}),n()}catch(b){a({kind:"error",title:(b==null?void 0:b.message)||"Falha ao criar parceiro"})}i(!1)};return e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:999},onClick:r,children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Cadastrar parceiro",style:{background:"var(--page-surface)",borderRadius:10,padding:20,width:480},onClick:b=>b.stopPropagation(),children:[e.jsx("h3",{style:{marginBottom:16,fontSize:16},children:"Cadastrar parceiro"}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{fontSize:11,color:"var(--page-text-secondary)"},children:"Nome do embarcador"}),e.jsx("input",{value:u,onChange:b=>x(b.target.value),placeholder:"Ambev, Vale, Unilever...",style:{width:"100%",padding:8,marginTop:4,background:"var(--page-surface-elevated)",border:"1px solid var(--page-border)",borderRadius:6,color:"var(--page-text-primary)"}})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{fontSize:11,color:"var(--page-text-secondary)"},children:"CNPJ"}),e.jsx("input",{value:c,onChange:b=>g(b.target.value),placeholder:"00.000.000/0001-00",style:{width:"100%",padding:8,marginTop:4,background:"var(--page-surface-elevated)",border:"1px solid var(--page-border)",borderRadius:6,color:"var(--page-text-primary)"}})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{fontSize:11,color:"var(--page-text-secondary)"},children:"Transporte"}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:6},children:[e.jsx("button",{onClick:()=>d("sftp"),style:{flex:1,padding:10,borderRadius:6,background:p==="sftp"?"var(--accent-brand)":"var(--page-surface-elevated)",border:"1px solid var(--page-border)",color:p==="sftp"?"#fff":"var(--page-text-primary)",cursor:"pointer",fontSize:12},children:"SFTP (recomendado)"}),e.jsx("button",{onClick:()=>d("webhook"),style:{flex:1,padding:10,borderRadius:6,background:p==="webhook"?"var(--accent-brand)":"var(--page-surface-elevated)",border:"1px solid var(--page-border)",color:p==="webhook"?"#fff":"var(--page-text-primary)",cursor:"pointer",fontSize:12},children:"Webhook (HTTP)"})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:r,style:{padding:"8px 14px",borderRadius:6,background:"none",border:"1px solid var(--page-border)",color:"var(--page-text-primary)",cursor:"pointer",fontSize:12},children:"Cancelar"}),e.jsx("button",{onClick:l,disabled:v||!u||!c,style:{padding:"8px 14px",borderRadius:6,background:"var(--accent-brand)",border:"none",color:"#fff",cursor:"pointer",fontSize:12,fontWeight:600,opacity:v||!u||!c?.5:1},children:v?"Salvando...":"Criar"})]})]})})}export{re 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.