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