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