import{j as e}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b.js";import{u}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b20.js";import{s as x}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b24.js";import{d as h}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b156.js";import{dd as i,U as f,ao as g,I as n}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b11.js";import{V as w}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b19.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b8.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b7.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b9.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b6.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b4.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b3.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b2.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b10.js";function L({rel:r}){const{label:m}=x(),{language:t}=u(),l=[{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 s=[];if(a==="all"?s=r.send.map(o=>({id:o.phone,name:o.nome,status:o.status})):a==="success"?s=r.send.filter(o=>o.status==="Enviado").map(o=>({id:o.phone,name:o.nome,status:o.status})):s=r.send.filter(o=>o.status==="Erro").map(o=>({id:o.phone,name:o.nome,status:o.status})),s.length===0){n({type:"Error",message:`${t.relatorio_vazio}`,position:"top-right"});return}const c={contacts:s,labelName:m.nameID,type:a};try{const o=await fetch(`${w.backend_utils}api/XLSX/exportrelatorio`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!o.ok)throw new Error("Erro ao enviar dados para o servidor");const d=await o.json();h(d.XLSXbase64,`${m.nameID}_relatorio_${a}.xlsx`),n({type:"Success",message:`${t.contatos_exportados}`,position:"top-right"})}catch(o){console.error("Erro ao exportar relatório:",o),n({type:"Error",message:t.erroEnvio,position:"top-right"})}};return e.jsxs("div",{className:"bugiwsl0 fooq7fky",children:[e.jsx("h2",{className:"px-2",children:f.MillisToFormattedDate(parseInt(r.id))}),l.map((a,s)=>e.jsx("span",{children:e.jsx(g,{content:a.name,icon:a.ico,setFunction:()=>p(a.type),stroke:"1"})},s))]})}export{L as default};
