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