import{z as B,m as q,B as $,r as x,F as D,ag as F,aw as G,P as v,Q as r,R as a,X as f,_ as A,a1 as p,a2 as N,a0 as n,e as o,a6 as y,a7 as k,T as s,aU as K}from"./vendor-CYDnlB7m.js";import{a5 as L,D as Q,f as U,S as z}from"./index-Dbx5Evda.js";import{G as H}from"./usePurchaseRequestDocuments-BVdrN2fX.js";import{_ as M}from"./from-file.vue_vue_type_style_index_0_lang-DmccjM7Z.js";import"./useFiles-COGJIciV.js";function O(u){return B(H,q(()=>{const{storeId:l,userId:c}=$(L());return{storeId:l,customerId:c,...$(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"},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=D({__name:"purchase-requests",setup(u){const{t:l}=F(),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 C(e){V.value=new z(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=v("VcTypography"),S=v("VcEmptyView"),E=v("VcTable"),I=v("VcWidget");return a(),r("div",null,[f(T,{tag:"h1"},{default:p(()=>[N(n(e.$t("purchase_requests.title")),1)]),_:1}),!o(m)&&!o(i).length?(a(),A(S,{key:0,text:e.$t("purchase_requests.no_purchase_requests_message"),icon:"outline-order"},null,8,["text"])):(a(),r("div",j,[f(M,{class:"mb-5"}),f(I,{size:"lg"},{"default-container":p(()=>[f(E,{loading:o(m),columns:w.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:K(b=>g(t.item),["enter"])},[s("div",Y,[s("span",Z,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,J)]),"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(w.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-HycFZfBi.js.map
