import{r as e}from"./chunk-QTnfLwEv.js";import{n as t,t as n}from"./jsx-runtime-BWRPWl8p.js";import{t as r}from"./dayjs.min-aszMaMjE.js";import{C as i,Di as a,Ei as o,G as s,S as c,W as l,_n as u,b as d,ha as f,ma as p,tr as m}from"./index-DccLTdzK.js";import{t as h}from"./PageHeader-DNnlanBD.js";import{t as g}from"./DataTable-KLBE0uXO.js";import{t as _}from"./useTheme-ClV7RdEj.js";import{t as v}from"./useMediaQuery-Diq4jKog.js";import{t as y}from"./recepcionCompra-BoAVnH0n.js";var b=e(t(),1);i();var x=e(r(),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,r]=(0,b.useState)(!1),[i,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 v(_().breakpoints.down(`sm`)),(0,C.jsxs)(C.Fragment,{children:[e&&(0,C.jsx)(l,{}),(0,C.jsx)(h,{title:`Recepciones de compra`,icon:u}),(0,C.jsx)(`div`,{className:`divTabla`,children:(0,C.jsx)(g,{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=>d(e.fecha)},{name:`PRODUCTOS`,selector:e=>e.productos,cell:e=>(0,C.jsx)(p,{variant:`link`,onClick:()=>P(e.productos),children:(0,C.jsx)(o,{icon:m,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)(f,{bg:t==`0`?`danger`:t==`1`?`success`:`warning`,children:n})}}]})}),(0,C.jsxs)(s,{show:M,onClose:()=>N(!1),maxWidth:`lg`,children:[(0,C.jsx)(s.Header,{closeButton:!0,onClose:()=>N(!1),children:`Detalles de productos`}),(0,C.jsx)(s.Body,{children:(0,C.jsxs)(a,{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)(p,{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};