import{r as t,R,A as O,a_ as U,l as g,B as m,j as i,z as B,y as L,a$ as M,D as k,n as F,o as G}from"./index-cc84e56a.js";import{g as S}from"./getSuperGridData-279f41e8.js";import{L as V,G as j,d as W}from"./Edit-5a622c9b.js";import{A as T}from"./AdmUsuarios-10c7fd6e.js";import{N as _}from"./NoRowsComponent-73b1b6ea.js";import"./ListItemIcon-77037982.js";import"./Divider-b784899a.js";const te=$=>{const[C,o]=t.useState([]),[w,r]=t.useState(null),[x,l]=R.useState(!1),{empresaActual:n}=t.useContext(O),[q,d]=t.useState(!0),[y,z]=t.useState(""),[H,N]=t.useState(""),[e,u]=t.useState({pageSize:20,page:0}),[p,h]=t.useState(0),[J,A]=t.useState(10),c=t.useCallback(U.debounce(async a=>{N(a);const s=await S("4",(n==null?void 0:n.empId)+"",a,[],e.page+1,(e.page+1)*e.pageSize-e.pageSize,e.pageSize);o(s.data.map(f=>({...f,id:f.Identificador})))},1200),[]),v=a=>{const s=a.target.value;z(s),c(s)};t.useEffect(()=>()=>{c.cancel()},[c]);const D=()=>{l(!0)},I=()=>{l(!1),r(null)},b=()=>{l(!0),r(void 0)},E=[{field:"Identificador",headerName:"Id",type:"string",width:100,align:"left",headerAlign:"left"},{field:"Usuario",headerName:"Usuario",type:"string",width:200,align:"left",headerAlign:"left"},{field:"Nombre",headerName:"Nombre",type:"string",width:200,align:"left",headerAlign:"left"},{field:"Sexo",headerName:"Sexo",type:"string",width:200,align:"left",headerAlign:"left"},{field:"Estado",headerName:"Estado",type:"string",width:200,align:"left",headerAlign:"left"},{field:"actions",type:"actions",headerName:"Acciones",width:100,cellClassName:"actions",getActions:({id:a,row:s})=>[i(j,{icon:i(W,{}),label:"Edit",className:"textPrimary",onClick:()=>{D(),r(s)},color:"inherit"},`ABMEdit${a}`)]}],P=async()=>{d(!0);const a=await S("4",(n==null?void 0:n.empId)+"","",[],e.page+1,(e.page+1)*e.pageSize-e.pageSize,e.pageSize);a.success?(o(a.data.map(s=>({...s,id:s.Identificador}))),h(a.total),d(!1)):(h(0),o([]),d(!1))};return t.useEffect(()=>{P()},[e]),g("div",{children:[g(m,{sx:{maxWidth:800},my:2,display:"flex",alignItems:"center",gap:2,children:[i(B,{sx:{color:"#FFF"},variant:"contained",size:"small",onClick:b,children:"Crear usuario"}),i(L,{fullWidth:!0,label:"Buscar...",variant:"outlined",value:y,onChange:v})]}),i(m,{sx:{height:600,width:"100%"},children:i(M,{rows:C,columns:E,editMode:"row",rowsPerPageOptions:[5,10,20,50,100],pagination:!0,paginationMode:"server",rowCount:p||20,page:e.page,components:{NoResultsOverlay:_,LoadingOverlay:V},onPageChange:a=>u({...e,page:a}),pageSize:e.pageSize,onPageSizeChange:a=>{A(a),u({...e,pageSize:a})}})}),g(k,{open:x,onClose:I,maxWidth:"lg",children:[i(F,{id:"scroll-dialog-title",children:"Administración de usuarios"}),i(G,{dividers:!0,children:i(T,{data:w})})]})]})};export{te as default};
