import{a as e}from"./chunk-BNv3lrIs.js";import{n as t,t as n}from"./jsx-runtime-pmtNMKr4.js";import{t as r}from"./DropdownActions-DPd7qitt.js";import{t as i}from"./useMediaQuery-C_7KdS3g.js";import{t as a}from"./load-HIf6x4Qy.js";import{A as o,T as s,Vi as c,kr as l}from"./index-CBXvBSuP.js";import{t as u}from"./withRouter-BfV3B9Vo.js";import{t as d}from"./PageHeader-C3X_ZaAc.js";import{t as f}from"./DataTable-BuE1Zp8A.js";import{t as p}from"./useTheme-D5mB3Mad.js";import{i as m,r as h,t as g}from"./ConfiguracionRutas-DfE_DZxa.js";var _=e(t(),1),v=n();function y(e){let{location:t,history:n}=e,[u,y]=(0,_.useState)(!0);(0,_.useEffect)(()=>{setTimeout(()=>{y(!1)},500)},[]);let[x,S]=(0,_.useState)([]),C=()=>{try{s().then(e=>{let{data:t}=e;S(b(t))}).catch(e=>{})}catch{}};(0,_.useEffect)(()=>{C()},[t]);let[w,T]=(0,_.useState)(!0),[E,D]=(0,_.useState)([]),O=()=>{let e=setTimeout(()=>{D(x),T(!1)},0);return()=>clearTimeout(e)};(0,_.useEffect)(()=>{O()},[]);let[k,A]=(0,_.useState)(!1),[j,M]=(0,_.useState)(null),[N,P]=(0,_.useState)(null),F=e=>{P(`Registrar ruta`),M(e),A(!0)},I=e=>{P(`Modificar ruta`),M(e),A(!0)},L=e=>{P(`Eliminar ruta`),M(e),A(!0)};return i(p().breakpoints.down(`sm`)),(0,v.jsxs)(v.Fragment,{children:[u&&(0,v.jsx)(a,{}),(0,v.jsx)(d,{title:`Rutas`,icon:l,onAddClick:()=>F((0,v.jsx)(g,{history:n,setShow:A})),addText:`Agregar`}),(0,v.jsx)(`div`,{className:`divTabla`,style:{textTransform:`capitalize`},children:(0,v.jsx)(f,{title:`Lista de rutas registradas`,datos:x,columnas:[{name:`ID`,selector:e=>e.id,omit:!0},{name:`FOLIO`,selector:e=>e.folio,sortable:!0},{name:`NOMBRE`,selector:e=>e.nombre.join(` - `),sortable:!0},{name:`DESCRIPCION`,selector:e=>e.descripcion,sortable:!0},{name:`DIA`,selector:e=>e.dia,sortable:!0},{name:`STATUS`,selector:e=>e.estado,sortable:!0,cell:e=>(0,v.jsx)(c,{bg:e.estado==`true`?`success`:`danger`,children:e.estado==`true`?`activo`:`inhabilitado`})},{name:`ACCIONES`,cell:e=>{let t=[e.id,e.folio,e.nombre,e.descripcion,e.dia,e.estado];return(0,v.jsxs)(r,{buttonColor:`minimal`,icon:`fas fa-ellipsis-v`,children:[(0,v.jsx)(r.Button,{onClick:()=>I((0,v.jsx)(m,{history:n,setShow:A,data:t})),icon:`fas fa-pen`,color:`text-yellow-500`,children:`Modificar`}),(0,v.jsx)(r.Button,{onClick:()=>L((0,v.jsx)(h,{history:n,setShow:A,data:t})),icon:`fas fa-trash`,color:`text-red-500`,children:`Eliminar`})]})}}]})}),(0,v.jsxs)(o,{show:k,onClose:()=>A(!1),maxWidth:`xl`,children:[(0,v.jsx)(o.Header,{closeButton:!0,onClose:()=>A(!1),children:N}),(0,v.jsx)(o.Body,{children:j})]})]})}function b(e){let t=[];return e.forEach(e=>{t.push({id:e._id,folio:e.folio,nombre:e.nombre,descripcion:e.descripcion,dia:e.dia,estado:e.estado})}),t}var x=u(y);export{x as default};