import{u as D}from"./BZ7f31ti.js";import{u as C}from"./DKzHUNYh.js";import{u as w,q as N,c as u,a as t,t as e,e as $,F as x,r as A,i as h,l as m,m as S,o as d}from"./BKiFavna.js";import{_ as B}from"./DlAUqK2U.js";const I={class:"page-head"},M={class:"page-hdr"},F={class:"table-wrap"},L={class:"ad-table"},P={class:"actions"},T=["value","onChange"],V=["onClick"],q={key:0},E={key:0,class:"pagination"},j=["disabled"],z=["disabled"],f=20,G={__name:"donations",setup(H){const{lang:g}=w(),{api:i}=D(),r=C(),c=m([]),o=m(1),v=m(0),p=S(()=>Math.ceil(v.value/f)),l=async()=>{try{const s=await i.get("/admin/donations",{page:o.value,limit:f});c.value=s.data.donations,v.value=s.meta.total}catch{}},y=async s=>{if(confirm("Delete?"))try{await i.del(`/admin/donations/${s}`),l(),r.success("Deleted")}catch(n){r.error(n.message)}},b=async(s,n)=>{try{await i.put(`/admin/donations/${s}`,{status:n}),l()}catch(a){r.error(a.message)}},k=s=>s?new Date(s).toLocaleString():"";return N(l),(s,n)=>(d(),u("div",null,[t("div",I,[t("h1",M,e($(g)==="bn"?"ডোনেশন":"Donations"),1)]),t("div",F,[t("table",L,[n[5]||(n[5]=t("thead",null,[t("tr",null,[t("th",null,"Name"),t("th",null,"Amount"),t("th",null,"Method"),t("th",null,"TrxID"),t("th",null,"Status"),t("th",null,"Date"),t("th",null,"Actions")])],-1)),t("tbody",null,[(d(!0),u(x,null,A(c.value,a=>(d(),u("tr",{key:a.id},[t("td",null,e(a.is_anonymous?"Anonymous":a.name),1),t("td",null,e(`৳${a.amount}`),1),t("td",null,e(a.payment_method),1),t("td",null,e(a.transaction_id||"-"),1),t("td",null,e(a.status),1),t("td",null,e(k(a.created_at)),1),t("td",P,[t("select",{value:a.status,onChange:_=>b(a.id,_.target.value),class:"mini-select"},[...n[2]||(n[2]=[t("option",null,"pending",-1),t("option",null,"confirmed",-1),t("option",null,"failed",-1),t("option",null,"refunded",-1)])],40,T),t("button",{onClick:_=>y(a.id),class:"btn-icon danger"},[...n[3]||(n[3]=[t("i",{class:"fas fa-trash"},null,-1)])],8,V)])]))),128)),c.value.length?h("",!0):(d(),u("tr",q,[...n[4]||(n[4]=[t("td",{colspan:7,class:"empty"},"No data",-1)])]))])])]),p.value>1?(d(),u("div",E,[t("button",{onClick:n[0]||(n[0]=a=>{o.value--,l()}),disabled:o.value<=1},"Prev",8,j),t("span",null,e(o.value)+" / "+e(p.value),1),t("button",{onClick:n[1]||(n[1]=a=>{o.value++,l()}),disabled:o.value>=p.value},"Next",8,z)])):h("",!0)]))}},R=B(G,[["__scopeId","data-v-72fd3f55"]]);export{R as default};
