import{x as D,B as P,y as $,r as V,K as G,Z as N,ag as A,S as y,L as r,M as a,V as k,P as F,T as m,X as K,W as n,b as o,N as q,O as x,U as s,aX as L}from"./vendor-bSWkQivH.js";import{V as M,D as O,i as U,S as W}from"./index-Dqv5IkpS.js";import{G as H}from"./usePurchaseRequestDocuments-BbQkBP-v.js";import{_ as Q}from"./from-file.vue_vue_type_style_index_0_lang-gredbb71.js";function X(i){return D(H,P(()=>{const{storeId:l,userId:d}=$(M());return{storeId:l,customerId:d,...$(i)}}),{notifyOnNetworkStatusChange:!0,fetchPolicy:"cache-and-network",nextFetchPolicy:"cache-first",keepPreviousResult:!0})}const z=5;function Z(){const i=V(z),l=V(1),d=V(O),{loading:b,result:p,refetch:v}=X(P(()=>({first:i.value,after:String((l.value-1)*i.value),sort:d.value.toString()}))),w=P(()=>{var u,c;return((c=(u=p.value)==null?void 0:u.purchaseRequests)==null?void 0:c.items)??[]}),h=P(()=>{var u,c;return Math.ceil((((c=(u=p.value)==null?void 0:u.purchaseRequests)==null?void 0:c.totalCount)??0)/i.value)});return{loading:b,purchaseRequests:w,itemsPerPage:i,page:l,pages:h,sort:d,refetch:v}}const j={key:1},J=["onClick","onKeyup"],Y={class:"flex flex-col"},ee={class:"text-sm text-neutral-400"},se={class:"overflow-hidden text-ellipsis pr-4 font-black"},te={class:"flex flex-col"},ae={class:"text-sm text-neutral-400"},re={class:"overflow-hidden text-ellipsis"},oe={class:"flex flex-col"},ne={class:"text-sm text-neutral-400"},le={class:"flex flex-col"},ue={class:"text-sm text-neutral-400"},ce=["onClick"],ie={class:"overflow-hidden text-ellipsis p-5"},de={class:"overflow-hidden text-ellipsis p-5"},ge=G({__name:"purchase-requests",setup(i){const{t:l}=N(),d=A();U({title:l("purchase_requests.meta.title")});const{loading:b,purchaseRequests:p,itemsPerPage:v,pages:w,page:h,sort:u}=Z(),c=V([{id:"number",title:l("purchase_requests.purchase_request_number_label"),sortable:!0},{id:"createdDate",title:l("purchase_requests.date_label"),sortable:!0}]);function C(e){u.value=new W(e.column,e.direction),h.value=1}function f(e){d.push({name:"PurchaseRequest",params:{purchaseRequestId:e.id}})}function R(e){h.value=e,window.scroll({top:0,behavior:"smooth"})}return(e,_)=>{const T=y("VcTypography"),S=y("VcEmptyView"),E=y("VcTable"),I=y("VcWidget");return a(),r("div",null,[k(T,{tag:"h1"},{default:m(()=>[K(n(e.$t("purchase_requests.title")),1)]),_:1}),!o(b)&&!o(p).length?(a(),F(S,{key:0,text:e.$t("purchase_requests.no_purchase_requests_message"),icon:"outline-order"},null,8,["text"])):(a(),r("div",j,[k(Q,{class:"mb-5"}),k(I,{size:"lg"},{"default-container":m(()=>[k(E,{loading:o(b),columns:c.value,sort:o(u),items:o(p),pages:o(w),page:o(h),description:e.$t("purchase_requests.meta.table_description"),onItemClick:f,onHeaderClick:C,onPageChanged:R},{"mobile-item":m(t=>{var g;return[s("div",{class:"grid cursor-pointer grid-cols-2 gap-y-4 border-b border-neutral-200 p-6",role:"button",tabindex:"0",onClick:B=>f(t.item),onKeyup:L(B=>f(t.item),["enter"])},[s("div",Y,[s("span",ee,n(e.$t("purchase_requests.purchase_request_number_label")),1),s("span",se,n(t.item.number),1)]),s("div",te,[s("span",ae,n(e.$t("purchase_requests.date_label")),1),s("span",re,n(e.$d((g=t.item)==null?void 0:g.createdDate)),1)])],40,J)]}),"mobile-skeleton":m(()=>[(a(!0),r(q,null,x(o(v),t=>(a(),r("div",{key:t,class:"grid grid-cols-2 gap-y-4 border-b border-neutral-200 p-6"},[s("div",oe,[s("span",ne,n(e.$t("purchase_requests.purchase_request_number_label")),1),_[0]||(_[0]=s("div",{class:"mr-4 h-6 animate-pulse bg-neutral-200"},null,-1))]),s("div",le,[s("span",ue,n(e.$t("purchase_requests.date_label")),1),_[1]||(_[1]=s("div",{class:"h-6 animate-pulse bg-neutral-200"},null,-1))])]))),128))]),"desktop-body":m(()=>[(a(!0),r(q,null,x(o(p),t=>(a(),r("tr",{key:t.id,class:"cursor-pointer even:bg-neutral-50 hover:bg-neutral-200",onClick:g=>f(t)},[s("td",ie,n(t.number),1),s("td",de,n(e.$d(t.createdDate)),1)],8,ce))),128))]),"desktop-skeleton":m(()=>[(a(!0),r(q,null,x(o(v),t=>(a(),r("tr",{key:t,class:"even:bg-neutral-50"},[(a(!0),r(q,null,x(c.value,g=>(a(),r("td",{key:g.id,class:"p-5"},_[2]||(_[2]=[s("div",{class:"h-6 animate-pulse bg-neutral-200"},null,-1)])))),128))]))),128))]),_:1},8,["loading","columns","sort","items","pages","page","description"])]),_:1})]))])}}});export{ge as default};
//# sourceMappingURL=purchase-requests-B-X0BNAl.js.map
