import{u as C}from"./BZ7f31ti.js";import{u as w}from"./DKzHUNYh.js";import{u as D,q as N,c as u,a as t,t as n,e as S,F as $,r as x,i as _,l as m,m as M,o as c}from"./BKiFavna.js";import{_ as B}from"./DlAUqK2U.js";const j={class:"page-head"},A={class:"page-hdr"},E={class:"table-wrap"},F={class:"ad-table"},I={class:"actions"},L=["value","onChange"],P=["onClick"],V={key:0},q={key:0,class:"pagination"},T=["disabled"],z=["disabled"],h=20,G={__name:"contact",setup(H){const{lang:f}=D(),{api:d}=C(),i=w(),r=m([]),l=m(1),v=m(0),p=M(()=>Math.ceil(v.value/h)),o=async()=>{try{const a=await d.get("/admin/contact-messages",{page:l.value,limit:h});r.value=a.data.messages,v.value=a.meta.total}catch{}},b=async a=>{if(confirm("Delete?"))try{await d.del(`/admin/contact-messages/${a}`),o(),i.success("Deleted")}catch(s){i.error(s.message)}},y=async(a,s)=>{try{await d.put(`/admin/contact-messages/${a}`,{status:s}),o()}catch(e){i.error(e.message)}},k=a=>a?new Date(a).toLocaleString():"";return N(o),(a,s)=>(c(),u("div",null,[t("div",j,[t("h1",A,n(S(f)==="bn"?"কন্টাক্ট বার্তা":"Contact Messages"),1)]),t("div",E,[t("table",F,[s[5]||(s[5]=t("thead",null,[t("tr",null,[t("th",null,"Name"),t("th",null,"Email"),t("th",null,"Subject"),t("th",null,"Message"),t("th",null,"Status"),t("th",null,"Date"),t("th",null,"Actions")])],-1)),t("tbody",null,[(c(!0),u($,null,x(r.value,e=>(c(),u("tr",{key:e.id},[t("td",null,n(e.name),1),t("td",null,n(e.email),1),t("td",null,n(e.subject||"-"),1),t("td",null,n((e.message||"").slice(0,80)),1),t("td",null,n(e.status),1),t("td",null,n(k(e.created_at)),1),t("td",I,[t("select",{value:e.status,onChange:g=>y(e.id,g.target.value),class:"mini-select"},[...s[2]||(s[2]=[t("option",null,"new",-1),t("option",null,"read",-1),t("option",null,"replied",-1),t("option",null,"archived",-1)])],40,L),t("button",{onClick:g=>b(e.id),class:"btn-icon danger"},[...s[3]||(s[3]=[t("i",{class:"fas fa-trash"},null,-1)])],8,P)])]))),128)),r.value.length?_("",!0):(c(),u("tr",V,[...s[4]||(s[4]=[t("td",{colspan:7,class:"empty"},"No data",-1)])]))])])]),p.value>1?(c(),u("div",q,[t("button",{onClick:s[0]||(s[0]=e=>{l.value--,o()}),disabled:l.value<=1},"Prev",8,T),t("span",null,n(l.value)+" / "+n(p.value),1),t("button",{onClick:s[1]||(s[1]=e=>{l.value++,o()}),disabled:l.value>=p.value},"Next",8,z)])):_("",!0)]))}},R=B(G,[["__scopeId","data-v-4a88bf9f"]]);export{R as default};
