import{i as g}from"./emotion-use-insertion-effect-with-fallbacks.browser.esm-6809063d.js";import{j as c,a as i}from"./Tooltip-ae8d7992.js";import{g as w}from"./getSuperGridData-25a18199.js";import{A as M,l as k,n as B}from"./index-dfa17bed.js";import{A as F}from"./AdmUsuarios-4d450c77.js";import{N as L}from"./NoRowsComponent-ad54fc8b.js";const x=await g("react"),{useCallback:V,useContext:j,useEffect:C,useState:n}=x,{DataGrid:G,GridActionsCellItem:W}=await g("@mui/x-data-grid"),{Box:S,Button:T,Dialog:_,DialogContent:$,DialogTitle:q,LinearProgress:H,TextField:J}=await g("@mui/material"),oe=K=>{const[A,o]=n([]),[y,s]=n(null),[z,r]=x.useState(!1),{empresaActual:p}=j(M),[Q,l]=n(!0),[N,v]=n(""),[X,D]=n(""),[e,u]=n({pageSize:20,page:0}),[m,h]=n(0),[Y,I]=n(10),d=V(k.debounce(async a=>{D(a);const t=await w("4",p?.empId+"",a,[],e.page+1,(e.page+1)*e.pageSize-e.pageSize,e.pageSize);o(t.data.map(f=>({...f,id:f.Identificador})))},1200),[]),b=a=>{const t=a.target.value;v(t),d(t)};C(()=>()=>{d.cancel()},[d]);const P=()=>{r(!0)},R=()=>{r(!1),s(null)},E=()=>{r(!0),s(void 0)},O=[{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:t})=>[i(W,{icon:i(B,{}),label:"Edit",className:"textPrimary",onClick:()=>{console.log(t),P(),s(t)},color:"inherit"},`ABMEdit${a}`)]}],U=async()=>{l(!0);const a=await w("4",p?.empId+"","",[],e.page+1,(e.page+1)*e.pageSize-e.pageSize,e.pageSize);a.success?(o(a.data.map(t=>({...t,id:t.Identificador}))),h(a.total),l(!1)):(h(0),o([]),l(!1))};return C(()=>{U()},[e]),c("div",{children:[c(S,{sx:{maxWidth:800},my:2,display:"flex",alignItems:"center",gap:2,children:[i(T,{sx:{color:"#FFF"},variant:"contained",size:"small",onClick:E,children:"Crear usuario"}),i(J,{fullWidth:!0,label:"Buscar...",variant:"outlined",value:N,onChange:b})]}),i(S,{sx:{height:600,width:"100%"},children:i(G,{rows:A,columns:O,editMode:"row",rowsPerPageOptions:[5,10,20,50,100],pagination:!0,paginationMode:"server",rowCount:m||20,page:e.page,components:{NoResultsOverlay:L,LoadingOverlay:H},onPageChange:a=>u({...e,page:a}),pageSize:e.pageSize,onPageSizeChange:a=>{I(a),u({...e,pageSize:a})}})}),c(_,{open:z,onClose:R,maxWidth:"lg",children:[i(q,{id:"scroll-dialog-title",children:"Administración de usuarios"}),i($,{dividers:!0,children:i(F,{data:y})})]})]})};export{oe as default};
