import{r as p,m as w,a9 as $,ah as k,F as B,ai as N,aD as S,P as g,Q as f,R as _,T as e,X as v,W as A,a1 as y,a2 as x,a0 as s,e as i,a5 as H,a6 as j}from"./vendor-D8NNcBCx.js";import{G as I,u as G}from"./useLoyaltyBalance-Dbt6xeiO.js";import{s as F,S as M,w as Y,L as q,F as J,H as W,R as U,I as z,J as Q}from"./index-C3Ufbmof.js";async function X(l){const{data:o}=await F.query({query:I,variables:{...l}});return o.loyaltyPointsHistory}function E(){const l=p(J),o=k([]),r=p(!1),c=p(0),u=p(1),h=p(new M("createdDate",Y.Descending));async function d(){r.value=!0;const m={sort:h.value.toString(),first:l.value,after:String((u.value-1)*l.value)};try{const n=await X(m);o.value=n?.items??[],c.value=Math.ceil((n?.totalCount??0)/l.value)}catch(n){throw q.error(`${E.name}.${d.name}`,n),n}finally{r.value=!1}}return{fetchHistory:d,sort:h,loading:$(r),historyLogs:w(()=>o.value),itemsPerPage:l,pages:c,page:u}}const K={class:"flex items-center justify-between gap-2"},Z={key:0},tt={class:"grid w-full cursor-pointer appearance-none grid-cols-2 items-center gap-y-4 border-b border-neutral-200 p-6 text-left"},et={class:"flex flex-col"},st={class:"text-sm text-neutral-400"},ot={class:"overflow-hidden text-ellipsis pr-4 font-black"},at={class:"flex flex-col items-end justify-center"},nt={class:"flex flex-col"},it={class:"text-sm text-neutral-400"},lt={class:"overflow-hidden text-ellipsis"},rt={class:"flex flex-col"},ct={class:"text-sm text-neutral-400"},dt={class:"overflow-hidden text-ellipsis font-black"},pt={class:"overflow-hidden text-ellipsis p-5"},yt={class:"overflow-hidden text-ellipsis p-5"},ut={class:"overflow-hidden text-ellipsis p-5"},ht={class:"overflow-hidden text-ellipsis p-5 text-right"},vt=B({__name:"points-history",setup(l){const{t:o}=N(),r=w(()=>[{id:"operation",title:o("loyalty.points-history.operation"),sortable:!1},{id:"operationType",title:o("loyalty.points-history.operation-type"),sortable:!1},{id:"createdDate",title:o("loyalty.points-history.date"),sortable:!1,classes:"!px-3"},{id:"amount",title:o("loyalty.points-history.amount"),sortable:!1,align:"right"}]),{fetchHistory:c,sort:u,loading:h,historyLogs:d,pages:m,page:n}=E(),{fetchLoyaltyBalance:L,loading:P,currentBalance:O}=G();async function R(t){n.value=t,window.scroll({top:0,behavior:"smooth"}),await c()}function b(t){return t.object?.type===W?t.object.orderNumber:t.object?.type==U?o("loyalty.points-history.registration"):t.object?.type}function T(t){return t.operationType===z?o("loyalty.points-history.redeemed"):t.operationType===Q?o("loyalty.points-history.earned"):t.operationType}return S(async()=>{await Promise.all([c(),L()])}),(t,ft)=>{const D=g("VcTypography"),C=g("VcTable"),V=g("VcWidget");return _(),f("div",null,[e("div",K,[v(D,{tag:"h1"},{default:y(()=>[x(s(t.$t("loyalty.points-history.meta.title")),1)]),_:1}),i(P)?A("",!0):(_(),f("div",Z,s(t.$t("loyalty.points-history.current-balance",{currentBalance:i(O)})),1))]),v(V,{size:"lg"},{"default-container":y(()=>[v(C,{loading:i(h),columns:r.value,items:i(d),sort:i(u),pages:i(m),page:i(n),"hide-default-footer":!1,"mobile-breakpoint":"lg",onPageChanged:R},{"mobile-item":y(a=>[e("div",tt,[e("div",et,[e("span",st,s(t.$t("loyalty.points-history.operation")),1),e("span",ot,s(b(a.item)),1)]),e("div",at,s(T(a.item)),1),e("div",nt,[e("span",it,s(t.$t("loyalty.points-history.date")),1),e("span",lt,s(t.$d(a.item?.createdDate)),1)]),e("div",rt,[e("span",ct,s(t.$t("loyalty.points-history.amount")),1),e("span",dt,s(a.item?.amount),1)])])]),"desktop-body":y(()=>[(_(!0),f(H,null,j(i(d),a=>(_(),f("tr",{key:a.id,class:"cursor-default even:bg-neutral-50 hover:bg-neutral-200"},[e("td",pt,s(b(a)),1),e("td",yt,s(T(a)),1),e("td",ut,s(t.$d(a?.createdDate)),1),e("td",ht,s(a.amount),1)]))),128))]),"page-limit-message":y(()=>[x(s(t.$t("ui_kit.reach_limit.page_limit_filters")),1)]),_:1},8,["loading","columns","items","sort","pages","page"])]),_:1})])}}});export{vt as default};
//# sourceMappingURL=points-history-BrzuIuvm.js.map
