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,Cn as a,Da as o,G as s,Ia as c,La as l,Li as u,Ma as d,S as f,W as p,b as m,da as h,ha as g,ki as _}from"./index-DccLTdzK.js";import{t as v}from"./withRouter-CRkgdzqj.js";import{i as y,t as b}from"./asistencia-Br1MCnK_.js";import{t as x}from"./PageHeader-DNnlanBD.js";import{t as S}from"./DataTable-KLBE0uXO.js";import{t as C}from"./useTheme-ClV7RdEj.js";import{t as w}from"./useMediaQuery-Diq4jKog.js";import{t as T}from"./RegistroAsistencia-CqbXWhes.js";var E=e(t(),1),D=e(r(),1);i();var O=e(f(),1),k=n();function A(e){let{location:t,history:n}=e;D.default.locale(`es`),D.default.extend(O.default);let r=new Date,[i,f]=(0,E.useState)(`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,`0`)}-${String(r.getDate()).padStart(2,`0`)}`),[v,A]=(0,E.useState)(!0),[M,N]=(0,E.useState)(``),[P,F]=(0,E.useState)(``),I=()=>{try{d(l(c())).then(e=>{let{data:t}=e;N(t.tipo),F(t.departamento)}).catch(e=>{e.message===`Network Error`&&o.error(`Conexión al servidor no disponible`)})}catch(e){console.log(e)}};(0,E.useEffect)(()=>{I()},[]),(0,E.useEffect)(()=>{setTimeout(()=>{A(!1)},500)},[]);let[L,R]=(0,E.useState)([]),z=()=>{try{M==`administrador`?b(i).then(e=>{let{data:t}=e;R(j(t))}).catch(e=>{}):M==`departamento`&&y(P).then(e=>{let{data:t}=e;R(j(t))}).catch(e=>{})}catch{}};(0,E.useEffect)(()=>{z()},[t,P,i]);let[B,V]=(0,E.useState)(!0),[H,U]=(0,E.useState)([]),W=()=>{let e=setTimeout(()=>{U(L),V(!1)},0);return()=>clearTimeout(e)};(0,E.useEffect)(()=>{W()},[]);let[G,K]=(0,E.useState)(!1),[q,J]=(0,E.useState)(null),[Y,X]=(0,E.useState)(null),Z=e=>{X(`Registrar asistencia`),J(e),K(!0)};return w(C().breakpoints.down(`sm`)),(0,k.jsxs)(k.Fragment,{children:[v&&(0,k.jsx)(p,{}),(0,k.jsx)(x,{title:`Asistencia de empleados ${m(i)}`,icon:a,onAddClick:()=>Z((0,k.jsx)(T,{history:n,setShowModal:K})),addText:`Agregar`}),(0,k.jsx)(`div`,{className:`mr-3 ml-3`,children:(0,k.jsxs)(_,{children:[(0,k.jsxs)(h,{sm:12,md:{span:4,offset:2},lg:{span:4,offset:2},children:[(0,k.jsx)(u.Label,{children:`Selecciona un dia:`}),(0,k.jsx)(u.Control,{type:`date`,name:`fecha`,value:i,onChange:e=>f(e.target.value)})]}),(0,k.jsx)(h,{sm:12,md:6,lg:6,className:`d-flex align-items-end justify-content-start justify-content-md-end justify-content-lg-end`})]})}),(0,k.jsx)(`div`,{className:`divTabla`,children:(0,k.jsx)(S,{title:`Listado de asistencias de empleados registrados`,datos:L,columnas:[{name:`ID`,selector:e=>e.id,omit:!0},{name:`NOMBRE DEL EMPLEADO`,selector:e=>e.empleado,sortable:!0},{name:`DEPARTAMENTO`,selector:e=>e.usuario,sortable:!0},{name:`HORA DE REGISTRO`,selector:e=>e.fecha,sortable:!0,cell:e=>(0,k.jsx)(k.Fragment,{children:(0,D.default)(e.fecha).format(`h:mm A`)})},{name:`STATUS`,selector:e=>e.estado,sortable:!0,cell:e=>(0,k.jsx)(g,{bg:e.estado==`1`?`success`:`danger`,children:e.estado==`1`?`Activo`:`Inhabilitado`})}]})}),(0,k.jsxs)(s,{show:G,onClose:()=>K(!1),maxWidth:`xl`,children:[(0,k.jsx)(s.Header,{closeButton:!0,onClose:()=>K(!1),children:Y}),(0,k.jsx)(s.Body,{children:q})]})]})}function j(e){let t=[];return e.forEach(e=>{t.push({id:e._id,empleado:e.empleado,usuario:e.usuario,tipo:e.tipo,estado:e.estado,fecha:e.createdAt})}),t}var M=v(A);export{M as default};