import{r as c,o as p,b as s,c as o,p as v,d as a,T as g,z as f,C as _,F as y,s as x,f as h,q as k,t as u,v as w,L as C}from"./main.84523976.js";import{u as N}from"./use-meta.97669149.js";import{g as B}from"./InventarioRepository.ec013a73.js";const L={class:"layout-px-spacing"},U={class:"row layout-top-spacing"},j={class:"col-12 layout-spacing"},A={class:"panel p-3"},M={class:"d-flex flex-wrap align-items-center gap-3 mb-3"},S={class:"widget widget-table-one"},T={class:"widget-content"},V={key:0,class:"text-center py-5"},z={key:1,class:"text-center text-muted py-5"},D={key:2,class:"table-responsive"},F={class:"table table-bordered"},G={__name:"alertas",setup(P){N({title:"Alertas de stock"});const r=c(!1),n=c([]),d=c({umbral:0});async function b(){var i,t,e;r.value=!0;try{const l={umbral:(i=d.value.umbral)!=null?i:0},m=await B(l);n.value=(e=(t=m.data)!=null?t:m)!=null?e:[]}catch(l){console.error(l),n.value=[]}finally{r.value=!1}}return p(async()=>{await b()}),(i,t)=>(s(),o("div",L,[(s(),v(g,{to:"#breadcrumb"},[t[2]||(t[2]=a("ul",{class:"navbar-nav flex-row"},[a("li",null,[a("div",{class:"page-header"},[a("nav",{class:"breadcrumb-one","aria-label":"breadcrumb"},[a("ol",{class:"breadcrumb"},[a("li",{class:"breadcrumb-item"},[a("a",{href:"javascript:;"},"Inventario")]),a("li",{class:"breadcrumb-item active","aria-current":"page"},[a("span",null,"Alertas de stock")])])])])])],-1))])),a("div",U,[a("div",j,[a("div",A,[a("div",M,[t[3]||(t[3]=a("label",{class:"mb-0"},"Umbral (\u2264)",-1)),f(a("input",{"onUpdate:modelValue":t[0]||(t[0]=e=>d.value.umbral=e),type:"number",min:"0",step:"0.01",class:"form-control w-auto",style:{"max-width":"120px"}},null,512),[[_,d.value.umbral,void 0,{number:!0}]]),a("button",{type:"button",class:"btn btn-primary",onClick:b},"Consultar")]),a("div",S,[t[5]||(t[5]=a("div",{class:"widget-heading"},[a("h5",null,"Productos con stock bajo o agotado")],-1)),a("div",T,[r.value?(s(),o("div",V,"Cargando...")):n.value.length?(s(),o("div",D,[a("table",F,[t[4]||(t[4]=a("thead",null,[a("tr",null,[a("th",null,"Producto"),a("th",null,"Sucursal"),a("th",{class:"text-end"},"Stock actual"),a("th",null,"Unidad")])],-1)),a("tbody",null,[(s(!0),o(y,null,x(n.value,e=>{var l;return s(),o("tr",{key:e.id},[a("td",null,u(e.nombre),1),a("td",null,u(((l=e.sucursal)==null?void 0:l.nombre)||"\u2014"),1),a("td",{class:w(["text-end",Number(e.stock_actual)===0?"text-danger fw-bold":""])},u(Number(e.stock_actual)),3),a("td",null,u(e.unidad_medida||"\u2014"),1)])}),128))])])])):(s(),o("div",z," No hay productos por debajo del umbral. "))])])])])]),h(k(C),{active:r.value,"onUpdate:active":t[1]||(t[1]=e=>r.value=e),"can-cancel":!1,"is-full-page":!0},null,8,["active"])]))}};export{G as default};
