import{j as e}from"./v_7_4_3_28_345c6a4a-aab6-4ec9-a0c6-3718e7fdb1165.js";import{u,e as f,U as x}from"./v_7_4_3_28_345c6a4a-aab6-4ec9-a0c6-3718e7fdb1164.js";import{d as h}from"./v_7_4_3_28_345c6a4a-aab6-4ec9-a0c6-3718e7fdb116156.js";import{c_ as i,af as g,I as n}from"./v_7_4_3_28_345c6a4a-aab6-4ec9-a0c6-3718e7fdb1167.js";import"./v_7_4_3_28_345c6a4a-aab6-4ec9-a0c6-3718e7fdb116.js";import{u as w}from"./v_7_4_3_28_345c6a4a-aab6-4ec9-a0c6-3718e7fdb11647.js";import{V as _}from"./v_7_4_3_28_345c6a4a-aab6-4ec9-a0c6-3718e7fdb1162.js";import"./v_7_4_3_28_345c6a4a-aab6-4ec9-a0c6-3718e7fdb1163.js";import"./v_7_4_3_28_345c6a4a-aab6-4ec9-a0c6-3718e7fdb1166.js";import"./v_7_4_3_28_345c6a4a-aab6-4ec9-a0c6-3718e7fdb1168.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};
