import{r as t,R,A as O,aQ as U,f as g,B as f,j as i,m as B,l as L,an as M,ao as k,ap as F}from"./index-4e7882bc.js";import{g as S}from"./getSuperGridData-d8bcb04d.js";import{N as G,L as V,G as j,d as W}from"./NoRowsComponent-94f1c2bb.js";import{A as T}from"./AdmUsuarios-8b1dd2d5.js";import{D as Q}from"./DataGrid-c017cd02.js";import"./ListItemIcon-95e7eb22.js";import"./listItemTextClasses-0d3e3a1a.js";import"./Divider-5402fd42.js";import"./dividerClasses-9982a278.js";import"./toPropertyKey-4015efc6.js";const oe=_=>{const[C,n]=t.useState([]),[w,r]=t.useState(null),[x,l]=R.useState(!1),{empresaActual:o}=t.useContext(O),[$,d]=t.useState(!0),[y,z]=t.useState(""),[q,N]=t.useState(""),[e,p]=t.useState({pageSize:20,page:0}),[u,h]=t.useState(0),[H,A]=t.useState(10),c=t.useCallback(U.debounce(async a=>{N(a);const s=await S("4",(o==null?void 0:o.empId)+"",a,[],e.page+1,(e.page+1)*e.pageSize-e.pageSize,e.pageSize);n(s.data.map(m=>({...m,id:m.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",(o==null?void 0:o.empId)+"","",[],e.page+1,(e.page+1)*e.pageSize-e.pageSize,e.pageSize);a.success?(n(a.data.map(s=>({...s,id:s.Identificador}))),h(a.total),d(!1)):(h(0),n([]),d(!1))};return t.useEffect(()=>{P()},[e]),g("div",{children:[g(f,{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(f,{sx:{height:600,width:"100%"},children:i(Q,{rows:C,columns:E,editMode:"row",rowsPerPageOptions:[5,10,20,50,100],pagination:!0,paginationMode:"server",rowCount:u||20,page:e.page,components:{NoResultsOverlay:G,LoadingOverlay:V},onPageChange:a=>p({...e,page:a}),pageSize:e.pageSize,onPageSizeChange:a=>{A(a),p({...e,pageSize:a})}})}),g(M,{open:x,onClose:I,maxWidth:"lg",children:[i(k,{id:"scroll-dialog-title",children:"Administración de usuarios"}),i(F,{dividers:!0,children:i(T,{data:w})})]})]})};export{oe as default};
