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,Da as a,G as o,Ia as s,La as c,Ma as l,S as u,W as d,ha as f,qr as p}from"./index-DccLTdzK.js";import{t as m}from"./withRouter-CRkgdzqj.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{n as y,t as b}from"./scanner_qr-BeJWa-Ds.js";var x=e(t(),1);i();var S=e(r(),1),C=e(u(),1),w=n();function T(e){let{location:t,history:n}=e;S.default.locale(`es`),S.default.extend(C.default);let[r,i]=(0,x.useState)(!0),[u,m]=(0,x.useState)(``),[T,D]=(0,x.useState)(``),O=()=>{try{l(c(s())).then(e=>{let{data:t}=e;m(t.tipo),D(t.email)}).catch(e=>{e.message===`Network Error`&&a.error(`Conexión al servidor no disponible`)})}catch(e){console.log(e)}};(0,x.useEffect)(()=>{O()},[]),(0,x.useEffect)(()=>{setTimeout(()=>{i(!1)},500)},[]);let[k,A]=(0,x.useState)([]),j=()=>{try{y().then(e=>{let{data:t}=e;A(E(t))}).catch(e=>{})}catch{}};(0,x.useEffect)(()=>{j()},[t,T]);let[M,N]=(0,x.useState)(!0),[P,F]=(0,x.useState)([]),I=()=>{let e=setTimeout(()=>{F(k),N(!1)},0);return()=>clearTimeout(e)};(0,x.useEffect)(()=>{I()},[]);let[L,R]=(0,x.useState)(!1),[z,B]=(0,x.useState)(null),[V,H]=(0,x.useState)(null),U=e=>{H(`Escanear QR`),B(e),R(!0)};return v(_().breakpoints.down(`sm`)),(0,w.jsxs)(w.Fragment,{children:[r&&(0,w.jsx)(d,{}),(0,w.jsx)(h,{title:`Visitas de mensajeros`,icon:p,onAddClick:()=>U((0,w.jsx)(b,{history:n,setShow:R})),addText:`Escanear QR`}),(0,w.jsx)(`div`,{className:`divTabla`,style:{textTransform:`capitalize`},children:(0,w.jsx)(g,{title:`Lista de entregas registradas`,datos:k,columnas:[{name:`ID`,selector:e=>e.id,omit:!0},{name:`MENSAJERO`,selector:e=>e.mensajero,sortable:!0},{name:`DOCTOR`,selector:e=>e.doctor,sortable:!0},{name:`STATUS`,selector:e=>e.estado,sortable:!0,cell:e=>{let t=e.estado;return(0,w.jsx)(f,{bg:t==`false`?`danger`:`success`,children:t==`false`?`Deshabilitado`:`Activo`})}},{name:`FECHA DE CREACION`,selector:e=>e.fechaCreacion,sortable:!0}]})}),(0,w.jsxs)(o,{show:L,onClose:()=>R(!1),maxWidth:`xl`,children:[(0,w.jsx)(o.Header,{closeButton:!0,onClose:()=>R(!1),children:V}),(0,w.jsx)(o.Body,{children:z})]})]})}function E(e){let t=[];return e.forEach(e=>{t.push({id:e._id,idDoctor:e.idDoctor,idMensajero:e.idMensajero,doctor:e.doctor.nombre+` `+e.doctor.apellidoPaterno+` `+e.doctor.apellidoMaterno,mensajero:e.mensajero.nombre,estado:e.estado,fechaCreacion:(0,S.default)(e.createdAt).format(`DD/MM/YYYY hh:mm:ss A`)})}),t}var D=m(T);export{D as default};