import{j as e,ay as i,U as u,ad as x,I as n}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e10.js";import{a as h,u as f}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e19.js";import{d as g}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e124.js";import{V as w}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e18.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e8.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e4.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e5.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e7.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e6.js";function S({rel:r}){const{label:l}=h(),{language:t}=f(),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 s=>{let o=[];if(s==="all"?o=r.send.map(a=>({id:a.phone,name:a.nome,status:a.status})):s==="success"?o=r.send.filter(a=>a.status==="Sent").map(a=>({id:a.phone,name:a.nome,status:a.status})):o=r.send.filter(a=>a.status==="Erro").map(a=>({id:a.phone,name:a.nome,status:a.status})),o.length===0){n({type:"Error",message:`${t.relatorio_vazio}`,position:"top-right"});return}const c={contacts:o,labelName:l.nameID,type:s};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_${s}.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((s,o)=>e.jsx("span",{children:e.jsx(x,{content:s.name,icon:s.ico,setFunction:()=>p(s.type),stroke:"1"})},o))]})}export{S as default};
