import{j as e}from"./v_7_4_3_23_c059010f-ff6a-45e1-bfa2-f58a98f4a3915.js";import{u,e as f,U as x}from"./v_7_4_3_23_c059010f-ff6a-45e1-bfa2-f58a98f4a3914.js";import{d as h}from"./v_7_4_3_23_c059010f-ff6a-45e1-bfa2-f58a98f4a391156.js";import{c_ as i,af as g,I as n}from"./v_7_4_3_23_c059010f-ff6a-45e1-bfa2-f58a98f4a3917.js";import"./v_7_4_3_23_c059010f-ff6a-45e1-bfa2-f58a98f4a391.js";import{u as w}from"./v_7_4_3_23_c059010f-ff6a-45e1-bfa2-f58a98f4a39147.js";import{V as _}from"./v_7_4_3_23_c059010f-ff6a-45e1-bfa2-f58a98f4a3912.js";import"./v_7_4_3_23_c059010f-ff6a-45e1-bfa2-f58a98f4a3913.js";import"./v_7_4_3_23_c059010f-ff6a-45e1-bfa2-f58a98f4a3916.js";import"./v_7_4_3_23_c059010f-ff6a-45e1-bfa2-f58a98f4a3918.js";function T({rel:r}){const{language:t}=u(),{config:l}=f(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(`${_.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();h(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:x.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};
