import{j as e,cK as i,U as u,al as x,I as n}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf10.js";import{u as h}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf19.js";import{q as f}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf23.js";import{d as g}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf154.js";import{V as w}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf18.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf8.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf4.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf5.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf7.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf6.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf9.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf2.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf3.js";function L({rel:r}){const{label:l}=f(),{language:t}=h(),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 o=>{let s=[];if(o==="all"?s=r.send.map(a=>({id:a.phone,name:a.nome,status:a.status})):o==="success"?s=r.send.filter(a=>a.status==="Enviado").map(a=>({id:a.phone,name:a.nome,status:a.status})):s=r.send.filter(a=>a.status==="Erro").map(a=>({id:a.phone,name:a.nome,status:a.status})),s.length===0){n({type:"Error",message:`${t.relatorio_vazio}`,position:"top-right"});return}const c={contacts:s,labelName:l.nameID,type:o};try{const a=await fetch(`${w.backend_utils}api/XLSX/exportrelatorio`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!a.ok)throw new Error("Erro ao enviar dados para o servidor");const d=await a.json();g(d.XLSXbase64,`${l.nameID}_relatorio_${o}.xlsx`),n({type:"Success",message:`${t.contatos_exportados}`,position:"top-right"})}catch(a){console.error("Erro ao exportar relatório:",a),n({type:"Error",message:t.erroEnvio,position:"top-right"})}};return e.jsxs("div",{className:"bugiwsl0 fooq7fky",children:[e.jsx("h2",{className:"px-2",children:u.MillisToFormattedDate(parseInt(r.id))}),m.map((o,s)=>e.jsx("span",{children:e.jsx(x,{content:o.name,icon:o.ico,setFunction:()=>p(o.type),stroke:"1"})},s))]})}export{L as default};
