import{c as b,s as g,a as d,b as w}from"./index-aOv36DCp.js";import{s as k}from"./index-CUzG0H3y.js";import{U as S,G as V,c as q,a as o,e as a,u as t,w as i,H as m,A as n,o as x,t as u}from"./index-0UBdiff-.js";const A={class:"page module-accent",style:{"--accent-color":"var(--module-stock)"}},B={class:"filter-bar card-block"},C={class:"card-block"},G={class:"mono"},N={class:"mono"},$={class:"mono"},T={class:"mono"},P={__name:"Stock",setup(U){const p=n([]),_=n([]),c=n(!0),s=n({product_group_id:null,search:""});async function h(){const{data:r}=await m.getProductGroups();_.value=r}async function v(){c.value=!0;const r={};s.value.product_group_id&&(r.product_group_id=s.value.product_group_id),s.value.search&&(r.search=s.value.search);const{data:l}=await m.getStock(r);p.value=l,c.value=!1}let y=null;S(s,()=>{clearTimeout(y),y=setTimeout(v,250)},{deep:!0});function f(r){return r<=0?"danger":r<100?"warn":"success"}return V(async()=>{await h(),await v()}),(r,l)=>(x(),q("div",A,[l[3]||(l[3]=o("div",{class:"page-header"},[o("div",null,[o("h1",null,"Stock"),o("p",{class:"page-subtitle"},"On-hand and allocated stock by style and warehouse bin.")])],-1)),o("div",B,[a(t(b),{modelValue:s.value.product_group_id,"onUpdate:modelValue":l[0]||(l[0]=e=>s.value.product_group_id=e),options:_.value,optionLabel:"name",optionValue:"id",placeholder:"All Product Groups",showClear:"",style:{"min-width":"220px"}},null,8,["modelValue","options"]),a(t(k),{modelValue:s.value.search,"onUpdate:modelValue":l[1]||(l[1]=e=>s.value.search=e),placeholder:"Search by style code or name...",style:{"min-width":"260px"}},null,8,["modelValue"])]),o("div",C,[a(t(g),{value:p.value,loading:c.value,dataKey:"id",stripedRows:"",responsiveLayout:"scroll"},{empty:i(()=>[...l[2]||(l[2]=[o("div",{class:"empty-state"},"No stock records match these filters.",-1)])]),default:i(()=>[a(t(d),{field:"style_code",header:"Style Code"},{body:i(({data:e})=>[o("span",G,u(e.style_code),1)]),_:1}),a(t(d),{field:"style_name",header:"Style Name"}),a(t(d),{field:"colour",header:"Colour"}),a(t(d),{field:"warehouse",header:"Warehouse"}),a(t(d),{field:"bin_location",header:"Bin"},{body:i(({data:e})=>[o("span",N,u(e.bin_location),1)]),_:1}),a(t(d),{field:"quantity_on_hand",header:"On Hand"},{body:i(({data:e})=>[o("span",$,u(e.quantity_on_hand),1)]),_:1}),a(t(d),{field:"quantity_allocated",header:"Allocated"},{body:i(({data:e})=>[o("span",T,u(e.quantity_allocated),1)]),_:1}),a(t(d),{field:"quantity_available",header:"Available"},{body:i(({data:e})=>[a(t(w),{value:e.quantity_available,severity:f(e.quantity_available)},null,8,["value","severity"])]),_:1})]),_:1},8,["value","loading"])])]))}};export{P as default};
