import{a as e}from"./chunk-BNv3lrIs.js";import{n as t,t as n}from"./jsx-runtime-pmtNMKr4.js";import{a as r,t as i}from"./auth-BMqSpi21.js";import{i as a}from"./usuarios-uLfQbCp9.js";import{n as o}from"./toast-hrvP3G3Q.js";import{t as s}from"./useMediaQuery-C_7KdS3g.js";import{t as c}from"./load-HIf6x4Qy.js";import{t as l}from"./dayjs.min-CvL7oEs_.js";import{t as u}from"./es-B8cbrmO0.js";import{t as d}from"./localizedFormat-CVLUt9Cf.js";import{A as f,Ar as p,Vi as m}from"./index-CBXvBSuP.js";import{t as h}from"./withRouter-BfV3B9Vo.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{n as y,t as b}from"./scanner_qr-DImHxhH9.js";var x=e(t(),1);u();var S=e(l(),1),C=e(d(),1),w=n();function T(e){let{location:t,history:n}=e;S.default.locale(`es`),S.default.extend(C.default);let[l,u]=(0,x.useState)(!0),[d,h]=(0,x.useState)(``),[T,D]=(0,x.useState)(``),O=()=>{try{a(r(i())).then(e=>{let{data:t}=e;h(t.tipo),D(t.email)}).catch(e=>{e.message===`Network Error`&&o.error(`Conexión al servidor no disponible`)})}catch(e){console.log(e)}};(0,x.useEffect)(()=>{O()},[]),(0,x.useEffect)(()=>{setTimeout(()=>{u(!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 s(v().breakpoints.down(`sm`)),(0,w.jsxs)(w.Fragment,{children:[l&&(0,w.jsx)(c,{}),(0,w.jsx)(g,{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)(_,{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)(m,{bg:t==`false`?`danger`:`success`,children:t==`false`?`Deshabilitado`:`Activo`})}},{name:`FECHA DE CREACION`,selector:e=>e.fechaCreacion,sortable:!0}]})}),(0,w.jsxs)(f,{show:L,onClose:()=>R(!1),maxWidth:`xl`,children:[(0,w.jsx)(f.Header,{closeButton:!0,onClose:()=>R(!1),children:V}),(0,w.jsx)(f.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=h(T);export{D as default};