import{c as G,l as _,bd as B,a as F,sQ as D,h as L,r as x,j as i,I as N,bv as O,M as f,be as j,T as b,sC as r}from"./index-1350aa97.js";import{T as R}from"./index-5a1f70d0.js";import{T as H}from"./TopComponent-189c1068.js";import{M as Q}from"./Menu-4f31c92d.js";import{M as v}from"./MenuItem-5b6ab204.js";import"./TableCell-a6f79ef2.js";import"./TableRow-c7fca392.js";import"./index-78814c8f.js";import"./useMediaQuery-a3126238.js";import"./TableHead-ad1c6add.js";import"./createSvgIcon-2e83c7e0.js";import"./TablePagination-e8711540.js";import"./Toolbar-d333937b.js";import"./Select-8eee5a8a.js";import"./OutlinedInput-8de92ced.js";import"./useFormControl-dd6168e4.js";import"./isHostComponent-73d6e646.js";import"./useControlled-39301d68.js";import"./KeyboardArrowRight-d6b7e992.js";import"./LastPage-718ed1f4.js";import"./yup-eafdc449.js";import"./index.esm-e43efa83.js";import"./CustomDatepicker-9019a583.js";import"./floating-ui.dom-cd6c919d.js";import"./InputAdornment-0139a25d.js";import"./index-dd1e751c.js";import"./index-8daffd3f.js";import"./InputLabel-13efa73d.js";import"./index-bd875dae.js";import"./SectionDivider-474af95d.js";import"./resolveProps-d26bdf8f.js";import"./composeClasses-b42b2e69.js";import"./toPropertyKey-d8419463.js";import"./typeof-7fd5df1e.js";import"./popper-f3391c26.js";import"./styled-a7d7cd46.js";import"./PageBreadCrumb-7473d003.js";import"./PageMetaData-88e17dcb.js";import"./Breadcrumbs-b905f8b1.js";import"./useSlotProps-618d2e24.js";import"./Link-93a82ccf.js";import"./ScrollableList-3f260516.js";import"./List-538d4780.js";import"./index.esm-74444d29.js";import"./TextField-db0e4632.js";import"./FormControl-08732dac.js";import"./FilterOutlined-57d28dd2.js";import"./AntdIcon-a757300e.js";import"./slicedToArray-f5e6f6d2.js";import"./defineProperty-83f36300.js";import"./objectSpread2-07822c35.js";import"./Grow-ffb74095.js";import"./dividerClasses-15d7c20c.js";import"./listItemTextClasses-8ebe873e.js";const Ut=()=>{const n=G(),d=_(),g=B(),{manageGroups:{profileList:C,profileParams:a,loading:z,listCount:P},system:{userAccessList:m}}=F(t=>({manageGroups:D(t),system:L(t)})),S=[{title:"S.No",width:100},{title:"Name",width:100},{title:"Users",width:100},{title:"Actions",width:100}];function M(t,e,s,l){return{index:t,title:e,user:s,actions:l}}const[p,u]=x.useState({}),I=(t,e)=>{u(s=>({...s,[e]:t.currentTarget}))},c=t=>{u(e=>({...e,[t]:null}))},T=C.map((t,e)=>{var h;const s=(a.page-1)*a.page_size+(e+1),l=i.jsxs(i.Fragment,{children:[i.jsx(N,{sx:{px:"6px"},tabIndex:e,onClick:o=>I(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:i.jsx(O,{size:16})}),i.jsxs(Q,{anchorEl:p[t!=null&&t.id?t.id:""],id:"account-menu",open:!!p[t!=null&&t.id?t.id:""],onClose:()=>c(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:[(m==null?void 0:m.indexOf("auth.change_group"))!==-1&&i.jsx(v,{onClick:()=>{c(t!=null&&t.id?t.id:""),d("/pages/settings/manage-profile/"+t.id)},children:i.jsxs(f,{direction:"row",alignItems:"center",spacing:2,children:[i.jsx(j,{style:{cursor:"pointer",color:"#fc6f03",fontSize:"10px"}}),i.jsx(b,{children:"Edit"})]})}),i.jsx(v,{onClick:()=>{c(t!=null&&t.id?t.id:""),d("/pages/settings/datapermissions/"+t.id)},children:i.jsxs(f,{direction:"row",alignItems:"center",spacing:2,children:[i.jsx(j,{style:{cursor:"pointer",color:"#fc6f03",fontSize:"10px"}}),i.jsx(b,{children:"Data Permissions"})]})})]})]}),A=(h=t==null?void 0:t.users)==null?void 0:h.map(o=>o==null?void 0:o.fullname).join(", ");return M(s,t.name,A??"",l)}),k=({search:t})=>{n(r({search:t||"",page:1,page_size:10}))},y=(t,e)=>{n(r({...a,search:"",page:e+1}))},E=t=>{n(r({...a,search:"",page:1,page_size:parseInt(t.target.value)}))};return x.useEffect(()=>{n(r({search:"",page:1,page_size:10})),g.setTitle("Manage Groups"),g.setSubtitle("Settings")},[]),i.jsxs(i.Fragment,{children:[i.jsx(H,{permissionPreFix:"auth",permissionPostFix:"group",navigateLink:"/pages/settings/manage-profile/0",showAddButton:!0,addButtonName:"Add Group",handleSearch:k,showFilterButton:!1,filteredData:a}),i.jsx(R,{count:P,columns:S,rows:T,loading:z,page:a.page,pageSize:a.page_size,handleChangePage:y,handleChangeRowsPerPage:E})]})};export{Ut as default};
