import{_ as O}from"./Input.7105798b.js";import P from"./Icon.1464d3c9.js";import{_ as R}from"./Button.c35f3c05.js";import{_ as T}from"./Table.e164c81e.js";import{_ as E}from"./Pagination.967f26ab.js";import{bF as V,bE as C,aL as d,bq as k,o as M,c as U,b as l,w as p,a as t,d as n,t as _,ba as c,ah as A,F as H,u as z,bG as G,bD as j,bz as J}from"./entry.816e6e91.js";import{_ as K}from"./card.924cd882.js";import"./Button.8c8352d3.js";import"./nuxt-link.0e2876ca.js";import"./index.84e04faa.js";const Q={class:"d-flex align-items-center"},W=["src"],X={class:"badge bg-success"},Y=t("br",null,null,-1),Z={class:"badge bg-success"},ee=t("br",null,null,-1),te={class:"badge bg-success"},se={__name:"List",props:{pending:{type:Boolean},customers:{type:Array,default:()=>[]},page:{type:Number,default:1},total:{type:Number,default:1}},setup(u){const m=V(),o=C(),g=u,b=[{key:"id",label:"ID"},{key:"name",label:"Full Name"},{key:"username",label:"Username"},{key:"user_type",label:"User Type"},{key:"mobile_number",label:"Mobile Number"},{key:"statistics",label:"Statistics"},{key:"created_at",label:"Date"}];let s=d();s.value=g.page;let r=d("");return k(()=>m.query,()=>{r.value=m.query.search,s.value=+m.query.page||g.page},{immediate:!0}),k(s,()=>{o.push({query:{page:s.value,search:r.value}})}),(D,h)=>{const a=T,q=E;return M(),U(H,null,[l(a,{columns:b,rows:u.customers,loading:u.pending,"loading-state":{label:"Loading..."}},{"name-data":p(({row:e})=>[t("div",Q,[t("img",{src:e.img,alt:"Image",class:"rounded me-2",width:"40",height:"40"},null,8,W),n(" "+_(e.fullname),1)])]),"statistics-data":p(({row:e})=>[n(" Followers: "),t("span",X,_(e.totalOfMyFollowers),1),n(),Y,n(" Following: "),t("span",Z,_(e.totalOfMyFollows),1),n(),ee,n(" Posts: "),t("span",te,_(e.totalOfMyPosts),1)]),"created_at-data":p(({row:e})=>[n(_(new Date(e.created_at).getHours()+":"+new Date(e.created_at).getMinutes()+", "+new Date(e.created_at).toDateString()),1)]),_:1},8,["rows","loading","loading-state"]),l(q,{modelValue:c(s),"onUpdate:modelValue":h[0]||(h[0]=e=>A(s)?s.value=e:s=e),"page-count":20,total:u.total},null,8,["modelValue","total"])],64)}}},ae={class:"row mx-0"},oe={class:"col-lg-4 col-md-6 col-10 mb-4"},ne=["onSubmit"],le={class:"row"},re={class:"col-10"},ce={class:"col-2"},ue={class:"col-lg-12"},ve={__name:"index",setup(u){var e,F;z({title:"Customers list"});const m=G();m.pageName="Customers list";const o=V(),g=C();let b=d(""),s=d(1);const{data:r,pending:D,execute:h}=j({url:"customers/search/10",method:"post"},{immediate:!1,body:{key:b},query:{page:s}});s.value=((e=o.query)==null?void 0:e.page)||1,k(()=>o.query,(y,f)=>{var v,x;b.value=((v=o.query)==null?void 0:v.search)||"",s.value=((x=o.query)==null?void 0:x.page)||1,f==null&&!(y!=null&&y.search)&&h()},{immediate:!0});let a=d("");a.value=(F=o.query)==null?void 0:F.search;const q=()=>{g.push({query:{page:1,search:a.value}})};return(y,f)=>{const v=O,x=P,B=R,L=se,I=K;return M(),U("div",ae,[t("div",oe,[t("form",{onSubmit:J(q,["prevent"])},[t("div",le,[t("div",re,[l(v,{placeholder:"Search by customer id, mobile number, username",modelValue:c(a),"onUpdate:modelValue":f[0]||(f[0]=i=>A(a)?a.value=i:a=i)},null,8,["modelValue"])]),t("div",ce,[l(B,{color:"dark",type:"submit"},{default:p(()=>[l(x,{name:"material-symbols:search"})]),_:1})])])],40,ne)]),t("div",ue,[l(I,{bodyClasses:"mt-2"},{body:p(()=>{var i,$,N,S,w;return[l(L,{pending:c(D),customers:(i=c(r))==null?void 0:i.data,page:(N=($=c(r))==null?void 0:$.meta)==null?void 0:N.current_page,total:(w=(S=c(r))==null?void 0:S.meta)==null?void 0:w.total},null,8,["pending","customers","page","total"])]}),_:1})])])}}};export{ve as default};
