import{r as t,R,A as O,bd as U,o as g,B as m,j as i,K as B,J as L,be as M,D as k,t as F,v as G}from"./index-62412d73.js";import{g as S}from"./getSuperGridData-10339467.js";import{L as V,G as j,d as W}from"./Edit-b0ca90dc.js";import{A as T}from"./AdmUsuarios-b29a49ac.js";import{N as J}from"./NoRowsComponent-60007845.js";import"./ListItemIcon-db4667b4.js";import"./Alert-00e531f3.js";const te=K=>{const[C,o]=t.useState([]),[w,r]=t.useState(null),[x,l]=R.useState(!1),{empresaActual:n}=t.useContext(O),[_,d]=t.useState(!0),[y,z]=t.useState(""),[$,N]=t.useState(""),[e,u]=t.useState({pageSize:20,page:0}),[p,h]=t.useState(0),[q,v]=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),[]),A=a=>{const s=a.target.value;z(s),c(s)};t.useEffect(()=>()=>{c.cancel()},[c]);const b=()=>{l(!0)},D=()=>{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:()=>{b(),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:I,children:"Crear usuario"}),i(L,{fullWidth:!0,label:"Buscar...",variant:"outlined",value:y,onChange:A})]}),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:J,LoadingOverlay:V},onPageChange:a=>u({...e,page:a}),pageSize:e.pageSize,onPageSizeChange:a=>{v(a),u({...e,pageSize:a})}})}),g(k,{open:x,onClose:D,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};
