import{k as F,q as P,m as C,r as V,C as G,V as N,ac as A,N as y,D as r,E as a,Q as k,K as B,O as m,S as K,R as n,u as o,F as q,J as x,P as t,aM as L}from"./vendor-BGtMsOoo.js";import{V as M,D as O,i as Q,S as H}from"./index-CRze-aDK.js";import{G as U}from"./usePurchaseRequestDocuments-Ccsx5AI0.js";import{_ as W}from"./from-file.vue_vue_type_style_index_0_lang-DtTPVP8O.js";import"./useFiles-DW9DMZJb.js";import"./constants-55usBUX1.js";function z(i){return F(U,P(()=>{const{storeId:l,userId:d}=C(M());return{storeId:l,customerId:d,...C(i)}}),{notifyOnNetworkStatusChange:!0,fetchPolicy:"cache-and-network",nextFetchPolicy:"cache-first",keepPreviousResult:!0})}const J=5;function j(){const i=V(J),l=V(1),d=V(O),{loading:b,result:p,refetch:v}=z(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 X={key:1},Y=["onClick","onKeyup"],Z={class:"flex flex-col"},ee={class:"text-sm text-neutral-400"},te={class:"overflow-hidden text-ellipsis pr-4 font-black"},se={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"},ve=G({__name:"purchase-requests",setup(i){const{t:l}=N(),d=A();Q({title:l("purchase_requests.meta.title")});const{loading:b,purchaseRequests:p,itemsPerPage:v,pages:w,page:h,sort:u}=j(),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 $(e){u.value=new H(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 S=y("VcTypography"),T=y("VcEmptyView"),E=y("VcTable"),D=y("VcWidget");return a(),r("div",null,[k(S,{tag:"h1"},{default:m(()=>[K(n(e.$t("purchase_requests.title")),1)]),_:1}),!o(b)&&!o(p).length?(a(),B(T,{key:0,text:e.$t("purchase_requests.no_purchase_requests_message"),icon:"outline-order"},null,8,["text"])):(a(),r("div",X,[k(W,{class:"mb-5"}),k(D,{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:$,onPageChanged:R},{"mobile-item":m(s=>{var g;return[t("div",{class:"grid cursor-pointer grid-cols-2 gap-y-4 border-b border-neutral-200 p-6",role:"button",tabindex:"0",onClick:I=>f(s.item),onKeyup:L(I=>f(s.item),["enter"])},[t("div",Z,[t("span",ee,n(e.$t("purchase_requests.purchase_request_number_label")),1),t("span",te,n(s.item.number),1)]),t("div",se,[t("span",ae,n(e.$t("purchase_requests.date_label")),1),t("span",re,n(e.$d((g=s.item)==null?void 0:g.createdDate)),1)])],40,Y)]}),"mobile-skeleton":m(()=>[(a(!0),r(q,null,x(o(v),s=>(a(),r("div",{key:s,class:"grid grid-cols-2 gap-y-4 border-b border-neutral-200 p-6"},[t("div",oe,[t("span",ne,n(e.$t("purchase_requests.purchase_request_number_label")),1),_[0]||(_[0]=t("div",{class:"mr-4 h-6 animate-pulse bg-neutral-200"},null,-1))]),t("div",le,[t("span",ue,n(e.$t("purchase_requests.date_label")),1),_[1]||(_[1]=t("div",{class:"h-6 animate-pulse bg-neutral-200"},null,-1))])]))),128))]),"desktop-body":m(()=>[(a(!0),r(q,null,x(o(p),s=>(a(),r("tr",{key:s.id,class:"cursor-pointer even:bg-neutral-50 hover:bg-neutral-200",onClick:g=>f(s)},[t("td",ie,n(s.number),1),t("td",de,n(e.$d(s.createdDate)),1)],8,ce))),128))]),"desktop-skeleton":m(()=>[(a(!0),r(q,null,x(o(v),s=>(a(),r("tr",{key:s,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]=[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{ve as default};
//# sourceMappingURL=purchase-requests-DlglQr9k.js.map
