import{u as w}from"./BZ7f31ti.js";import{u as y}from"./DKzHUNYh.js";import{u as k,q as N,c as o,a as t,t as l,e as D,F as C,r as x,i as p,l as c,m as S,o as r}from"./BKiFavna.js";import{_ as $}from"./DlAUqK2U.js";const A={class:"page-head"},B={class:"page-hdr"},I={class:"table-wrap"},E={class:"ad-table"},F={class:"actions"},L=["onClick"],M={key:0},P={key:0,class:"pagination"},V=["disabled"],q=["disabled"],b=20,T={__name:"newsletter",setup(j){const{lang:h}=k(),{api:v}=w(),_=y(),i=c([]),n=c(1),m=c(0),d=S(()=>Math.ceil(m.value/b)),u=async()=>{try{const a=await v.get("/admin/newsletter",{page:n.value,limit:b});i.value=a.data.subscribers,m.value=a.meta.total}catch{}},f=async a=>{if(confirm("Delete?"))try{await v.del(`/admin/newsletter/${a}`),u(),_.success("Deleted")}catch(e){_.error(e.message)}},g=a=>a?new Date(a).toLocaleString():"";return N(u),(a,e)=>(r(),o("div",null,[t("div",A,[t("h1",B,l(D(h)==="bn"?"নিউজলেটার সাবস্ক্রাইবার":"Newsletter Subscribers"),1)]),t("div",I,[t("table",E,[e[4]||(e[4]=t("thead",null,[t("tr",null,[t("th",null,"ID"),t("th",null,"Email"),t("th",null,"Name"),t("th",null,"Active"),t("th",null,"Subscribed"),t("th",null,"Actions")])],-1)),t("tbody",null,[(r(!0),o(C,null,x(i.value,s=>(r(),o("tr",{key:s.id},[t("td",null,l(s.id),1),t("td",null,l(s.email),1),t("td",null,l(s.name||"-"),1),t("td",null,l(s.is_active?"✓":"×"),1),t("td",null,l(g(s.subscribed_at)),1),t("td",F,[t("button",{onClick:z=>f(s.id),class:"btn-icon danger"},[...e[2]||(e[2]=[t("i",{class:"fas fa-trash"},null,-1)])],8,L)])]))),128)),i.value.length?p("",!0):(r(),o("tr",M,[...e[3]||(e[3]=[t("td",{colspan:6,class:"empty"},"No data",-1)])]))])])]),d.value>1?(r(),o("div",P,[t("button",{onClick:e[0]||(e[0]=s=>{n.value--,u()}),disabled:n.value<=1},"Prev",8,V),t("span",null,l(n.value)+" / "+l(d.value),1),t("button",{onClick:e[1]||(e[1]=s=>{n.value++,u()}),disabled:n.value>=d.value},"Next",8,q)])):p("",!0)]))}},O=$(T,[["__scopeId","data-v-87580f7d"]]);export{O as default};
