import{f as w}from"./primevue-CfIk0_DY.js";import{_ as C,b as S,s as _}from"./index-BxIwIJfy.js";import{o as N,w as q,b as i,c as a,d as e,p as d,v as V,l as B,F as h,C as E,t as l,f as m,a as y,y as F}from"./vue-core-Di3IuVqe.js";const $=["title"],j={key:0,class:"p-3 text-center text-gray-500"},H={key:1,class:"flex flex-col gap-2"},I={class:"histo-item-head"},L={class:"histo-item-date"},M={key:0,class:"histo-item-user"},z={class:"histo-item-line"},A={key:0,class:"histo-item-line"},O={class:"histo-item-line"},R={__name:"HistoriqueEnvoiMail",props:{typeDocument:{type:String,required:!0},idDocument:{type:[String,Number],default:""}},emits:["count"],setup(f,{expose:g,emit:b}){const r=f,p=b,o=y([]),c=y(!1),x=F(()=>o.value.length?`Envoyé ${o.value.length} fois — cliquez pour le détail`:"Ce document n'a pas encore été envoyé par e-mail"),k=n=>n?new Date(n).toLocaleString("fr-FR",{dateStyle:"short",timeStyle:"short"}):"",u=async()=>{if(!r.idDocument){o.value=[],p("count",0);return}try{const n=await S.post(`${_.lienApi}/mail_envoi/${_.db}`,{type_document:r.typeDocument,id_document:r.idDocument});o.value=n.data||[]}catch{o.value=[]}p("count",o.value.length)},v=()=>{u(),c.value=!0};return N(u),q(()=>r.idDocument,u),g({recharger:u,ouvrir:v}),(n,t)=>{const D=w;return i(),a(h,null,[o.value.length?(i(),a("div",{key:0,class:"histo-mail-wrap",title:x.value,onClick:v},[...t[1]||(t[1]=[e("label",{class:"block histo-mail-label"}," ",-1),e("span",{class:"histo-mail-icon"},[e("i",{class:"pi pi-envelope"})],-1)])],8,$)):d("",!0),V(D,{visible:c.value,"onUpdate:visible":t[0]||(t[0]=s=>c.value=s),header:"Historique des envois par e-mail",modal:!0,style:{width:"640px"}},{default:B(()=>[o.value.length?(i(),a("div",H,[(i(!0),a(h,null,E(o.value,s=>(i(),a("div",{key:s.id_envoi,class:"histo-item"},[e("div",I,[t[2]||(t[2]=e("i",{class:"pi pi-send"},null,-1)),e("span",L,l(k(s.date_envoi)),1),s.nom_utilisateur?(i(),a("span",M,"par "+l(s.nom_utilisateur),1)):d("",!0)]),e("div",z,[t[3]||(t[3]=e("b",null,"À :",-1)),m(" "+l(s.destinataires),1)]),s.cc?(i(),a("div",A,[t[4]||(t[4]=e("b",null,"Cc :",-1)),m(" "+l(s.cc),1)])):d("",!0),e("div",O,[t[5]||(t[5]=e("b",null,"Objet :",-1)),m(" "+l(s.sujet),1)])]))),128))])):(i(),a("div",j," Ce document n'a pas encore été envoyé par e-mail. "))]),_:1},8,["visible"])],64)}}},J=C(R,[["__scopeId","data-v-0dd62ffa"]]);export{J as _};
