import{j as e}from"./v_7_4_3_5_5680d44b-ceb1-449a-bec3-8cbef70a2777.js";import{u,d as x}from"./v_7_4_3_5_5680d44b-ceb1-449a-bec3-8cbef70a277720.js";import{d as f}from"./v_7_4_3_5_5680d44b-ceb1-449a-bec3-8cbef70a2777154.js";import{de as i,U as h,ar as g,I as n}from"./v_7_4_3_5_5680d44b-ceb1-449a-bec3-8cbef70a277711.js";import{u as w}from"./v_7_4_3_5_5680d44b-ceb1-449a-bec3-8cbef70a277746.js";import{V as j}from"./v_7_4_3_5_5680d44b-ceb1-449a-bec3-8cbef70a277719.js";import"./v_7_4_3_5_5680d44b-ceb1-449a-bec3-8cbef70a27778.js";import"./v_7_4_3_5_5680d44b-ceb1-449a-bec3-8cbef70a27777.js";import"./v_7_4_3_5_5680d44b-ceb1-449a-bec3-8cbef70a27779.js";import"./v_7_4_3_5_5680d44b-ceb1-449a-bec3-8cbef70a27776.js";function T({rel:r}){const{language:t}=u(),{config:l}=x(w(a=>({config:a.config}))),m=[{ico:e.jsx(i,{className:"w-5 h-5 text-[var(--secundaria)]"}),name:`${t.baixar_todos}`,type:"all"},{ico:e.jsx(i,{className:"w-5 h-5 text-[var(--primaria)]"}),name:`${t.baixar_com_falha}`,type:"error"},{ico:e.jsx(i,{className:"w-5 h-5 text-[var(--terciaria)]"}),name:`${t.baixar_com_sucesso}`,type:"success"}],p=async a=>{let o=[];if(a==="all"?o=r.send.map(s=>({id:s.phone,name:s.nome,status:s.status})):a==="success"?o=r.send.filter(s=>s.status==="Enviado").map(s=>({id:s.phone,name:s.nome,status:s.status})):o=r.send.filter(s=>s.status==="Erro").map(s=>({id:s.phone,name:s.nome,status:s.status})),o.length===0){n({type:"Error",message:`${t.relatorio_vazio}`,position:"top-right"});return}const c={contacts:o,labelName:l.nameID,type:a};try{const s=await fetch(`${j.backend_utils}api/XLSX/exportrelatorio`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!s.ok)throw new Error("Erro ao enviar dados para o servidor");const d=await s.json();f(d.XLSXbase64,`${l.nameID}_relatorio_${a}.xlsx`),n({type:"Success",message:`${t.contatos_exportados}`,position:"top-right"})}catch(s){console.error("Erro ao exportar relatório:",s),n({type:"Error",message:t.erroEnvio,position:"top-right"})}};return e.jsxs("div",{className:"bugiwsl0 fooq7fky",children:[e.jsx("h2",{className:"px-2",children:h.MillisToFormattedDate(parseInt(r.id))}),m.map((a,o)=>e.jsx("span",{children:e.jsx(g,{content:a.name,icon:a.ico,setFunction:()=>p(a.type),stroke:"1"})},o))]})}export{T as default};
