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"./Col-Cmv4fRfN.js";import{t as c}from"./useMediaQuery-C_7KdS3g.js";import{t as l}from"./load-HIf6x4Qy.js";import{t as u}from"./dayjs.min-CvL7oEs_.js";import{t as d}from"./es-B8cbrmO0.js";import{t as f}from"./localizedFormat-CVLUt9Cf.js";import{A as p,Vi as m,b as h,bi as g,fi as _,on as v}from"./index-CBXvBSuP.js";import{t as y}from"./withRouter-BfV3B9Vo.js";import{i as b,t as x}from"./asistencia-BcBPqwcr.js";import{t as S}from"./PageHeader-C3X_ZaAc.js";import{t as C}from"./DataTable-BuE1Zp8A.js";import{t as w}from"./useTheme-D5mB3Mad.js";import{t as T}from"./RegistroAsistencia-DjwUdtpQ.js";var E=e(t(),1),D=e(u(),1);d();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 u=new Date,[d,f]=(0,E.useState)(`${u.getFullYear()}-${String(u.getMonth()+1).padStart(2,`0`)}-${String(u.getDate()).padStart(2,`0`)}`),[y,A]=(0,E.useState)(!0),[M,N]=(0,E.useState)(``),[P,F]=(0,E.useState)(``),I=()=>{try{a(r(i())).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`?x(d).then(e=>{let{data:t}=e;R(j(t))}).catch(e=>{}):M==`departamento`&&b(P).then(e=>{let{data:t}=e;R(j(t))}).catch(e=>{})}catch{}};(0,E.useEffect)(()=>{z()},[t,P,d]);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 c(w().breakpoints.down(`sm`)),(0,k.jsxs)(k.Fragment,{children:[y&&(0,k.jsx)(l,{}),(0,k.jsx)(S,{title:`Asistencia de empleados ${h(d)}`,icon:v,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)(s,{sm:12,md:{span:4,offset:2},lg:{span:4,offset:2},children:[(0,k.jsx)(g.Label,{children:`Selecciona un dia:`}),(0,k.jsx)(g.Control,{type:`date`,name:`fecha`,value:d,onChange:e=>f(e.target.value)})]}),(0,k.jsx)(s,{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)(C,{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)(m,{bg:e.estado==`1`?`success`:`danger`,children:e.estado==`1`?`Activo`:`Inhabilitado`})}]})}),(0,k.jsxs)(p,{show:G,onClose:()=>K(!1),maxWidth:`xl`,children:[(0,k.jsx)(p.Header,{closeButton:!0,onClose:()=>K(!1),children:Y}),(0,k.jsx)(p.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=y(A);export{M as default};