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"./Card-DwQw0IZE.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"./EliminarEntregas-B8Xk3ag8.js";import"./PagosOrdenesM-CFGt5gfS.js";import{n as _,t as v}from"./scanner_qr-DImHxhH9.js";var y=e(t(),1);u();var b=e(l(),1),x=e(d(),1),S=n();function C(e){let{history:t,location:n}=e;b.default.locale(`es`),b.default.extend(x.default);let[l,u]=(0,y.useState)(!0),[d,h]=(0,y.useState)(``),[C,w]=(0,y.useState)(``),[T,E]=(0,y.useState)([]),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(null),[j,M]=(0,y.useState)(null);(0,y.useEffect)(()=>{N()},[]),(0,y.useEffect)(()=>{P()},[C,n]),(0,y.useEffect)(()=>{setTimeout(()=>{u(!1)},500)},[]);let N=()=>{try{a(r(i())).then(e=>{let{data:t}=e;h(t.tipo),w(t.email)}).catch(e=>{e.message===`Network Error`&&o.error(`Conexión al servidor no disponible`)})}catch(e){console.log(e)}},P=()=>{try{_().then(e=>{let{data:t}=e;E(F(t))}).catch(e=>{})}catch{}};function F(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,b.default)(e.createdAt).format(`DD/MM/YYYY hh:mm:ss A`)})}),t}let I=e=>{M(`Escanear QR`),A(e),O(!0)};return(0,S.jsxs)(S.Fragment,{children:[l?(0,S.jsx)(c,{}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(g,{title:`Visitas de mensajeros`,icon:p,onAddClick:()=>I((0,S.jsx)(v,{history:t,setShow:O})),addText:`Escanear QR`}),(0,S.jsx)(`div`,{children:T.map(e=>(0,S.jsx)(s,{className:`mb-3`,children:(0,S.jsxs)(s.Body,{children:[(0,S.jsxs)(s.Title,{children:[`Mensajero `,e.mensajero]}),(0,S.jsx)(`br`,{}),(0,S.jsxs)(s.Text,{children:[`Mensajero: `,e.doctor,(0,S.jsx)(`br`,{}),`Doctor: `,e.doctor,(0,S.jsx)(`br`,{}),`Fecha de visitsa: `,(0,b.default)(e.fechaCreacion).format(`LLL`),(0,S.jsx)(`br`,{}),`Estado: `,(0,S.jsx)(m,{bg:e.estado===`false`?`danger`:`success`,children:e.estado===`false`?`Deshabilitado`:`Activo`})]})]})},e.id))})]}),(0,S.jsxs)(f,{show:D,onClose:()=>O(!1),maxWidth:`xl`,children:[(0,S.jsx)(f.Header,{closeButton:!0,onClose:()=>O(!1),children:j}),(0,S.jsx)(f.Body,{children:k})]})]})}var w=h(C);export{w as default};