import{u as w}from"./BZ7f31ti.js";import{u as N}from"./DKzHUNYh.js";import{u as k,q as C,c as o,a as t,t as a,e as S,F as x,r as D,i as _,l as c,m as j,o as u}from"./BKiFavna.js";import{_ as A}from"./DlAUqK2U.js";const B={class:"page-head"},$={class:"page-hdr"},F={class:"table-wrap"},I={class:"ad-table"},L={class:"actions"},M=["value","onChange"],P={key:0},T={key:0,class:"pagination"},V=["disabled"],q=["disabled"],h=20,E={__name:"tips",setup(Y){const{lang:m}=k(),{api:p}=w(),g=N(),i=c([]),l=c(1),v=c(0),r=j(()=>Math.ceil(v.value/h)),d=async()=>{try{const n=await p.get("/admin/tips",{page:l.value,limit:h});i.value=n.data.tips,v.value=n.meta.total}catch{}},b=async(n,e)=>{try{await p.put(`/admin/tips/${n}`,{status:e}),d()}catch(s){g.error(s.message)}},y=n=>n?new Date(n).toLocaleString():"";return C(d),(n,e)=>(u(),o("div",null,[t("div",B,[t("h1",$,a(S(m)==="bn"?"নিউজ টিপস":"News Tips"),1)]),t("div",F,[t("table",I,[e[4]||(e[4]=t("thead",null,[t("tr",null,[t("th",null,"Anon"),t("th",null,"Name"),t("th",null,"Category"),t("th",null,"Subject"),t("th",null,"Status"),t("th",null,"Date"),t("th",null,"Actions")])],-1)),t("tbody",null,[(u(!0),o(x,null,D(i.value,s=>(u(),o("tr",{key:s.id},[t("td",null,a(s.is_anonymous?"Yes":"No"),1),t("td",null,a(s.name||"-"),1),t("td",null,a(s.category),1),t("td",null,a(s.subject),1),t("td",null,a(s.status),1),t("td",null,a(y(s.created_at)),1),t("td",L,[t("select",{value:s.status,onChange:f=>b(s.id,f.target.value),class:"mini-select"},[...e[2]||(e[2]=[t("option",null,"new",-1),t("option",null,"reviewing",-1),t("option",null,"published",-1),t("option",null,"rejected",-1)])],40,M)])]))),128)),i.value.length?_("",!0):(u(),o("tr",P,[...e[3]||(e[3]=[t("td",{colspan:7,class:"empty"},"No data",-1)])]))])])]),r.value>1?(u(),o("div",T,[t("button",{onClick:e[0]||(e[0]=s=>{l.value--,d()}),disabled:l.value<=1},"Prev",8,V),t("span",null,a(l.value)+" / "+a(r.value),1),t("button",{onClick:e[1]||(e[1]=s=>{l.value++,d()}),disabled:l.value>=r.value},"Next",8,q)])):_("",!0)]))}},K=A(E,[["__scopeId","data-v-bd1c2dd2"]]);export{K as default};
