import{u as w}from"./BZ7f31ti.js";import{u as D}from"./DKzHUNYh.js";import{u as $,q as A,c as a,a as t,t as l,e as N,F as p,r as v,i as m,l as _,o,n as S}from"./BKiFavna.js";import{_ as x}from"./DlAUqK2U.js";const B={class:"page-head"},j={class:"page-hdr"},F={class:"filter-tabs"},I=["onClick"],L={class:"table-wrap"},M={class:"ad-table"},P={class:"content-cell"},T={class:"actions"},V=["onClick"],q=["onClick"],z=["onClick"],E={key:0},U={__name:"comments",setup(G){const{lang:b}=$(),{api:r}=w(),f=D(),h=[{value:"pending",label:"Pending"},{value:"approved",label:"Approved"},{value:"spam",label:"Spam"},{value:"trash",label:"Trash"}],c=_("pending"),u=_([]),i=async()=>{try{const n=await r.get("/admin/comments",{status:c.value});u.value=n.data.comments}catch{}},k=async n=>{await r.post(`/admin/comments/${n.id}/approve`),i()},g=async(n,e)=>{await r.post(`/admin/comments/${n.id}/reject`,{reason:e}),i()},y=async n=>{confirm("Delete comment?")&&(await r.del(`/admin/comments/${n.id}`),i(),f.success("Deleted"))},C=n=>new Date(n).toLocaleString();return A(i),(n,e)=>(o(),a("div",null,[t("div",B,[t("h1",j,l(N(b)==="bn"?"কমেন্ট মডারেশন":"Comments Moderation"),1)]),t("div",F,[(o(),a(p,null,v(h,s=>t("button",{key:s.value,class:S(["tab",{active:c.value===s.value}]),onClick:d=>{c.value=s.value,i()}},l(s.label),11,I)),64))]),t("div",L,[t("table",M,[e[5]||(e[5]=t("thead",null,[t("tr",null,[t("th",null,"User"),t("th",null,"Post"),t("th",null,"Comment"),t("th",null,"Date"),t("th",null,"Actions")])],-1)),t("tbody",null,[(o(!0),a(p,null,v(u.value,s=>(o(),a("tr",{key:s.id},[t("td",null,[t("strong",null,l(s.user_name),1),e[0]||(e[0]=t("br",null,null,-1)),t("small",null,l(s.user_email),1)]),t("td",null,l(s.post_title?.slice(0,40)),1),t("td",P,l(s.content),1),t("td",null,l(C(s.created_at)),1),t("td",T,[s.status!=="approved"?(o(),a("button",{key:0,onClick:d=>k(s),class:"btn-icon success",title:"Approve"},[...e[1]||(e[1]=[t("i",{class:"fas fa-check"},null,-1)])],8,V)):m("",!0),s.status!=="spam"?(o(),a("button",{key:1,onClick:d=>g(s,"spam"),class:"btn-icon warn",title:"Spam"},[...e[2]||(e[2]=[t("i",{class:"fas fa-ban"},null,-1)])],8,q)):m("",!0),t("button",{onClick:d=>y(s),class:"btn-icon danger",title:"Delete"},[...e[3]||(e[3]=[t("i",{class:"fas fa-trash"},null,-1)])],8,z)])]))),128)),u.value.length?m("",!0):(o(),a("tr",E,[...e[4]||(e[4]=[t("td",{colspan:"5",class:"empty"},"No comments",-1)])]))])])])]))}},Q=x(U,[["__scopeId","data-v-a38525f5"]]);export{Q as default};
