import{j as e,cU as i,U as u,am as x,I as n}from"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e410.js";import{u as h}from"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e419.js";import{s as f}from"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e423.js";import{d as g}from"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e4155.js";import{V as w}from"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e418.js";import"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e48.js";import"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e44.js";import"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e4.js";import"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e45.js";import"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e47.js";import"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e46.js";import"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e49.js";import"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e42.js";import"./v_7_4_2_14_b047d88c-9af4-4a49-a965-946ffe7780e43.js";function L({rel:r}){const{label:m}=f(),{language:t}=h(),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 o=>{let s=[];if(o==="all"?s=r.send.map(a=>({id:a.phone,name:a.nome,status:a.status})):o==="success"?s=r.send.filter(a=>a.status==="Enviado").map(a=>({id:a.phone,name:a.nome,status:a.status})):s=r.send.filter(a=>a.status==="Erro").map(a=>({id:a.phone,name:a.nome,status:a.status})),s.length===0){n({type:"Error",message:`${t.relatorio_vazio}`,position:"top-right"});return}const c={contacts:s,labelName:m.nameID,type:o};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,`${m.nameID}_relatorio_${o}.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))}),l.map((o,s)=>e.jsx("span",{children:e.jsx(x,{content:o.name,icon:o.ico,setFunction:()=>p(o.type),stroke:"1"})},s))]})}export{L as default};
