import{j as e}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a53.js";import{u,e as x,U as f,V as h}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a54.js";import{d as g}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5174.js";import{dd as i,ap as w,I as n}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a58.js";import"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a52.js";import"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a55.js";import{u as j}from"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a556.js";import"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a56.js";import"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a57.js";import"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a5.js";import"./v_7_4_3_73_d3c9bac7-c74e-47f6-ac42-499f067843a543.js";function k({rel:r}){const{language:t}=u(),{config:l}=x(j(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(`${h.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();g(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:f.MillisToFormattedDate(parseInt(r.id))}),m.map((a,o)=>e.jsx("span",{children:e.jsx(w,{content:a.name,icon:a.ico,setFunction:()=>p(a.type),stroke:"1"})},o))]})}export{k as default};
