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"./Card-DePL3JK2.js";import{t as i}from"./dayjs.min-aszMaMjE.js";import{C as a,Da as o,G as s,Ia as c,La as l,Ma as u,S as d,W as f,ha as p,qr as m}from"./index-DccLTdzK.js";import{t as h}from"./withRouter-CRkgdzqj.js";import{t as g}from"./PageHeader-DNnlanBD.js";import"./EliminarEntregas-BvTA0zxf.js";import"./PagosOrdenesM-xkUWKFcp.js";import{n as _,t as v}from"./scanner_qr-BeJWa-Ds.js";var y=e(t(),1);a();var b=e(i(),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[i,a]=(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(()=>{a(!1)},500)},[]);let N=()=>{try{u(l(c())).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:[i?(0,S.jsx)(f,{}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(g,{title:`Visitas de mensajeros`,icon:m,onAddClick:()=>I((0,S.jsx)(v,{history:t,setShow:O})),addText:`Escanear QR`}),(0,S.jsx)(`div`,{children:T.map(e=>(0,S.jsx)(r,{className:`mb-3`,children:(0,S.jsxs)(r.Body,{children:[(0,S.jsxs)(r.Title,{children:[`Mensajero `,e.mensajero]}),(0,S.jsx)(`br`,{}),(0,S.jsxs)(r.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)(p,{bg:e.estado===`false`?`danger`:`success`,children:e.estado===`false`?`Deshabilitado`:`Activo`})]})]})},e.id))})]}),(0,S.jsxs)(s,{show:D,onClose:()=>O(!1),maxWidth:`xl`,children:[(0,S.jsx)(s.Header,{closeButton:!0,onClose:()=>O(!1),children:j}),(0,S.jsx)(s.Body,{children:k})]})]})}var w=h(C);export{w as default};