import{c as G,l as _,be as B,a as F,sV as D,h as L,r as x,j as e,I as N,bw as O,M as f,bf as j,T as b,sA as r}from"./index-d9e0bbb9.js";import{T as R}from"./index-07650f16.js";import{T as H}from"./TopComponent-76fa20a1.js";import{M as U}from"./Menu-c23c1491.js";import{M as v}from"./MenuItem-086da23e.js";import"./TableCell-643437b4.js";import"./TableRow-113a14fe.js";import"./index-3220221a.js";import"./useMediaQuery-1b7ae287.js";import"./TableHead-2fc5d5a1.js";import"./createSvgIcon-c99d086f.js";import"./TablePagination-bee8c9bb.js";import"./Toolbar-eaf493cd.js";import"./Select-661ba76b.js";import"./OutlinedInput-8f17518b.js";import"./useFormControl-8bb67ca0.js";import"./isHostComponent-73d6e646.js";import"./useControlled-ba6710bb.js";import"./KeyboardArrowRight-80f086b2.js";import"./LastPage-cf4835f4.js";import"./yup-267c2267.js";import"./index.esm-97139da9.js";import"./CustomDatepicker-9495774a.js";import"./floating-ui.dom-cd6c919d.js";import"./InputAdornment-978b4608.js";import"./index-3bec8271.js";import"./index-1253245b.js";import"./InputLabel-8c8abfdd.js";import"./index-e61c8ded.js";import"./SectionDivider-95fcfa90.js";import"./resolveProps-ba55e2df.js";import"./composeClasses-b42b2e69.js";import"./toPropertyKey-720374c3.js";import"./popper-f3391c26.js";import"./styled-8fd62552.js";import"./PageBreadCrumb-ab23f357.js";import"./PageMetaData-c80444e2.js";import"./Breadcrumbs-359b714e.js";import"./useSlotProps-a7d9b3b8.js";import"./Link-3b5544a4.js";import"./ScrollableList-03cda798.js";import"./List-c3ed6b04.js";import"./index.esm-65c50bc3.js";import"./TextField-14942967.js";import"./FormControl-664346ce.js";import"./FilterOutlined-08135420.js";import"./AntdIcon-71a0f3e8.js";import"./objectSpread2-7f959c25.js";import"./Grow-ca477235.js";import"./dividerClasses-35463663.js";import"./listItemTextClasses-2867fd89.js";const Rt=()=>{const n=G(),d=_(),g=B(),{manageGroups:{profileList:z,profileParams:a,loading:C,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,i,s,l){return{index:t,title:i,user:s,actions:l}}const[p,u]=x.useState({}),I=(t,i)=>{u(s=>({...s,[i]:t.currentTarget}))},c=t=>{u(i=>({...i,[t]:null}))},T=z.map((t,i)=>{var h;const s=(a.page-1)*a.page_size+(i+1),l=e.jsxs(e.Fragment,{children:[e.jsx(N,{sx:{px:"6px"},tabIndex:i,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:e.jsx(O,{size:16})}),e.jsxs(U,{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&&e.jsx(v,{onClick:()=>{c(t!=null&&t.id?t.id:""),d("/pages/settings/manage-profile/"+t.id)},children:e.jsxs(f,{direction:"row",alignItems:"center",spacing:2,children:[e.jsx(j,{style:{cursor:"pointer",color:"#fc6f03",fontSize:"10px"}}),e.jsx(b,{children:"Edit"})]})}),e.jsx(v,{onClick:()=>{c(t!=null&&t.id?t.id:""),d("/pages/settings/datapermissions/"+t.id)},children:e.jsxs(f,{direction:"row",alignItems:"center",spacing:2,children:[e.jsx(j,{style:{cursor:"pointer",color:"#fc6f03",fontSize:"10px"}}),e.jsx(b,{children:"Data Permissions"})]})})]})]}),E=(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,E??"",l)}),k=({search:t})=>{n(r({search:t||"",page:1,page_size:10}))},y=(t,i)=>{n(r({...a,search:"",page:i+1}))},A=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")},[]),e.jsxs(e.Fragment,{children:[e.jsx(H,{permissionPreFix:"auth",permissionPostFix:"group",navigateLink:"/pages/settings/manage-profile/0",showAddButton:!0,addButtonName:"Add Group",handleSearch:k,showFilterButton:!1,filteredData:a}),e.jsx(R,{count:P,columns:S,rows:T,loading:C,page:a.page,pageSize:a.page_size,handleChangePage:y,handleChangeRowsPerPage:A})]})};export{Rt as default};
