import{j as e}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89263.js";import{u,e as x,U as f,V as h}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89264.js";import{d as g}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c8926174.js";import{dd as i,ap as w,I as n}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89268.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89262.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89265.js";import{u as j}from"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892656.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89266.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c89267.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c8926.js";import"./v_7_4_3_72_6a457bf5-eeae-4570-8821-bd6fa39c892643.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};
