import{c as _,l as B,be as F,a as D,sV as L,h as N,r as m,j as e,I as O,bw as R,M as j,bf as b,T as v,sA as c}from"./index-7d3dbb9c.js";import{T as H}from"./index-7a00ca34.js";import{T as U}from"./TopComponent-6b690561.js";import{M as V}from"./Menu-5245abf0.js";import{M as z}from"./MenuItem-02b6c30e.js";import"./TableCell-26014f2c.js";import"./TableRow-23a8435a.js";import"./index-3cd7bbe9.js";import"./useMediaQuery-77b67f07.js";import"./TableHead-ec26fced.js";import"./createSvgIcon-25cfe1a8.js";import"./TablePagination-f03db3c2.js";import"./Toolbar-b85f9581.js";import"./Select-762ec619.js";import"./OutlinedInput-e6d419ce.js";import"./useFormControl-7314cc67.js";import"./isHostComponent-73d6e646.js";import"./useControlled-338e346b.js";import"./KeyboardArrowRight-ff7c065c.js";import"./LastPage-7938a031.js";import"./yup-55e79238.js";import"./index.esm-12cc9f7b.js";import"./CustomDatepicker-6d5ad1ab.js";import"./floating-ui.dom-cd6c919d.js";import"./InputAdornment-bbfa18ee.js";import"./index-7976e00d.js";import"./index-e9cb9551.js";import"./InputLabel-ade41a0b.js";import"./index-b5c17d61.js";import"./SectionDivider-be0a23cf.js";import"./resolveProps-4b8623f7.js";import"./composeClasses-b42b2e69.js";import"./toPropertyKey-720374c3.js";import"./popper-f3391c26.js";import"./styled-446e5583.js";import"./PageBreadCrumb-6d7ee77a.js";import"./PageMetaData-69209ade.js";import"./Breadcrumbs-f8a93219.js";import"./useSlotProps-f2e72ab1.js";import"./Link-19ee87c9.js";import"./ScrollableList-ffeab0b0.js";import"./List-d7c020ab.js";import"./index.esm-9d396c5f.js";import"./TextField-a362d747.js";import"./FormControl-f3d9cdb4.js";import"./FilterOutlined-459a9fa1.js";import"./AntdIcon-2da3a123.js";import"./objectSpread2-947328ce.js";import"./Grow-1b15246b.js";import"./dividerClasses-59256fce.js";import"./listItemTextClasses-626eaddb.js";const Ht=()=>{const r=_(),g=B(),h=F(),{manageGroups:{profileList:C,profileParams:s,loading:T,listCount:P},system:{userAccessList:l}}=D(t=>({manageGroups:L(t),system:N(t)})),S=[{title:"S.No",width:100},{title:"Name",width:100},{title:"Users",width:100},{title:"Actions",width:100}];function M(t,i,n,u){return{index:t,title:i,user:n,actions:u}}const[p,x]=m.useState({}),E=(t,i)=>{x(n=>({...n,[i]:t.currentTarget}))},d=t=>{x(i=>({...i,[t]:null}))},I=C.map((t,i)=>{var f;const n=(s.page-1)*s.page_size+(i+1),u=e.jsxs(e.Fragment,{children:[e.jsx(O,{sx:{px:"6px"},tabIndex:i,onClick:o=>E(o,t.id?`${t.id}`:""),"aria-controls":p[t!=null&&t.id?t.id:""]?"account-menu":void 0,"aria-haspopup":"true","aria-expanded":p[t!=null&&t.id?t.id:""]?"true":void 0,children:e.jsx(R,{size:16})}),e.jsxs(V,{anchorEl:p[t!=null&&t.id?t.id:""],id:"account-menu",open:!!p[t!=null&&t.id?t.id:""],onClose:()=>d(t!=null&&t.id?t.id:""),PaperProps:{elevation:0,sx:{overflow:"visible",filter:"drop-shadow(0px 1px 2px rgba(185, 185, 185, 0.32))",mt:1.5,"& .MuiAvatar-root":{width:32,height:32,ml:-.5,mr:1},"&:before":{content:'""',display:"block",position:"absolute",top:0,right:14,width:10,height:10,bgcolor:"background.paper",transform:"translateY(-50%) rotate(45deg)",zIndex:0}}},transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},children:[(l==null?void 0:l.indexOf("auth.change_group"))!==-1&&e.jsx(z,{onClick:()=>{d(t!=null&&t.id?t.id:""),g("/pages/settings/manage-profile/"+t.id)},children:e.jsxs(j,{direction:"row",alignItems:"center",spacing:2,children:[e.jsx(b,{style:{cursor:"pointer",color:"#fc6f03",fontSize:"10px"}}),e.jsx(v,{children:"Edit"})]})}),e.jsx(z,{onClick:()=>{d(t!=null&&t.id?t.id:""),g("/pages/settings/datapermissions/"+t.id)},children:e.jsxs(j,{direction:"row",alignItems:"center",spacing:2,children:[e.jsx(b,{style:{cursor:"pointer",color:"#fc6f03",fontSize:"10px"}}),e.jsx(v,{children:"Data Permissions"})]})})]})]}),G=(f=t==null?void 0:t.users)==null?void 0:f.map(o=>o==null?void 0:o.fullname).join(", ");return M(n,t.name,G??"",u)}),a=m.useRef(null),k=({search:t})=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{r(c({search:t||"",page:1,page_size:10}))},500)};m.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]);const y=(t,i)=>{r(c({...s,search:"",page:i+1}))},A=t=>{r(c({...s,search:"",page:1,page_size:parseInt(t.target.value)}))};return m.useEffect(()=>{r(c({search:"",page:1,page_size:10})),h.setTitle("Manage Groups"),h.setSubtitle("Settings")},[]),e.jsxs(e.Fragment,{children:[e.jsx(U,{permissionPreFix:"auth",permissionPostFix:"group",navigateLink:"/pages/settings/manage-profile/0",showAddButton:!0,addButtonName:"Add Group",handleSearch:k,showFilterButton:!1,filteredData:s}),e.jsx(H,{count:P,columns:S,rows:I,loading:T,page:s.page,pageSize:s.page_size,handleChangePage:y,handleChangeRowsPerPage:A})]})};export{Ht as default};
