import{r as t,R,A as L,ag as M,o as g,B as m,j as i,M as O,L as U,bp as B,D as k,w as F,x as G}from"./index-e47c07e2.js";import{g as S}from"./getSuperGridData-19f85ad5.js";import{L as V,G as j,d as W}from"./Edit-7425426d.js";import{A as T}from"./AdmUsuarios-cd741ef1.js";import{N as _}from"./NoRowsComponent-7f6e8fc1.js";import"./ListItemIcon-49470498.js";const ae=$=>{const[C,o]=t.useState([]),[w,r]=t.useState(null),[x,l]=R.useState(!1),{empresaActual:n}=t.useContext(L),[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(M.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)},b=()=>{l(!1),r(null)},I=()=>{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(O,{sx:{color:"#FFF"},variant:"contained",size:"small",onClick:I,children:"Crear usuario"}),i(U,{fullWidth:!0,label:"Buscar...",variant:"outlined",value:y,onChange:v})]}),i(m,{sx:{height:600,width:"100%"},children:i(B,{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:b,maxWidth:"lg",children:[i(F,{id:"scroll-dialog-title",children:"Administración de usuarios"}),i(G,{dividers:!0,children:i(T,{data:w})})]})]})};export{ae as default};
