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