import{a as e}from"./chunk-BNv3lrIs.js";import{n as t,t as n}from"./jsx-runtime-pmtNMKr4.js";import{t as r}from"./Button-_yTP2B6J.js";import{t as i}from"./useMediaQuery-C_7KdS3g.js";import{t as a}from"./load-HIf6x4Qy.js";import{t as o}from"./dayjs.min-CvL7oEs_.js";import{t as s}from"./es-B8cbrmO0.js";import{t as c}from"./localizedFormat-CVLUt9Cf.js";import{A as l,Rn as u,Vi as d,b as f,en as p,li as m,ui as h}from"./index-CBXvBSuP.js";import{t as g}from"./PageHeader-C3X_ZaAc.js";import{t as _}from"./DataTable-BuE1Zp8A.js";import{t as v}from"./useTheme-D5mB3Mad.js";import{t as y}from"./recepcionCompra-Dgt5DRy0.js";var b=e(t(),1);s();var x=e(o(),1),S=e(c(),1),C=n(),w=()=>{let[e,t]=(0,b.useState)(!0);x.default.locale(`es`),x.default.extend(S.default),(0,b.useEffect)(()=>{setTimeout(()=>{t(!1)},500)},[]);let[n,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(null),[w,E]=(0,b.useState)(null),[D,O]=(0,b.useState)([]),k=()=>{try{y().then(e=>{let{data:t}=e;console.log(t),O(T(t))}).catch(e=>{})}catch{}};(0,b.useEffect)(()=>{k(),console.log(`hola`)},[]),console.log(D);let[A,j]=(0,b.useState)([]),[M,N]=(0,b.useState)(!1),P=e=>{j(Array.isArray(e)?e:[]),N(!0)};return i(v().breakpoints.down(`sm`)),(0,C.jsxs)(C.Fragment,{children:[e&&(0,C.jsx)(a,{}),(0,C.jsx)(g,{title:`Recepciones de compra`,icon:p}),(0,C.jsx)(`div`,{className:`divTabla`,children:(0,C.jsx)(_,{title:`Lista de ordenes de recepciones de compra registradas`,datos:D,columnas:[{name:`ID`,selector:e=>e.id,omit:!0},{name:`FOLIO`,selector:e=>e.folio,sortable:!0},{name:`FECHA`,selector:e=>e.fecha,sortable:!0,cell:e=>f(e.fecha)},{name:`PRODUCTOS`,selector:e=>e.productos,cell:e=>(0,C.jsx)(r,{variant:`link`,onClick:()=>P(e.productos),children:(0,C.jsx)(m,{icon:u,style:{color:`#000080`}})})},{name:`ELABORÓ`,selector:e=>e.elaboro,sortable:!0},{name:`AUTORIZÓ`,selector:e=>e.autorizo,sortable:!0},{name:`STATUS`,selector:e=>e.estado,sortable:!0,cell:e=>{let t=e.estado,n=``;return t==`0`?n=`Cancelada`:t==`1`?n=`Recibida`:t==`2`&&(n=`Activa`),(0,C.jsx)(d,{bg:t==`0`?`danger`:t==`1`?`success`:`warning`,children:n})}}]})}),(0,C.jsxs)(l,{show:M,onClose:()=>N(!1),maxWidth:`lg`,children:[(0,C.jsx)(l.Header,{closeButton:!0,onClose:()=>N(!1),children:`Detalles de productos`}),(0,C.jsx)(l.Body,{children:(0,C.jsxs)(h,{striped:!0,bordered:!0,hover:!0,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{children:[(0,C.jsx)(`th`,{children:`Producto`}),(0,C.jsx)(`th`,{children:`UM`}),(0,C.jsx)(`th`,{children:`Cantidad`})]})}),(0,C.jsx)(`tbody`,{children:A.map((e,t)=>(0,C.jsxs)(`tr`,{children:[(0,C.jsx)(`td`,{children:e.producto}),(0,C.jsx)(`td`,{children:e.unidadMedida}),(0,C.jsx)(`td`,{children:e.cantidad})]},t))})]})}),(0,C.jsx)(`div`,{className:`flex justify-end p-4 border-t`,children:(0,C.jsx)(r,{variant:`secondary`,onClick:()=>N(!1),children:`Cerrar`})})]})]})};function T(e){let t=[];return e.forEach(e=>{t.push({id:e._id,folio:e.folio,fecha:e.fecha,productos:e.productos,iva:e.iva,subtotal:e.subtotal,total:e.total,autorizo:e.autorizo,elaboro:e.elaboro,estado:e.estado})}),t}export{w as default};